src/share/classes/sun/awt/PlatformFont.java

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:


 126 
 127     /**
 128      * make a array of CharsetString with given char array.
 129      * @param str The char array to convert.
 130      * @param offset offset of first character of interest
 131      * @param len number of characters to convert
 132      * @param allowDefault whether to allow the default char.
 133      * Setting this to true overloads the meaning of this method to
 134      * return non-null only if all chars can be converted.
 135      * @return array of CharsetString or if allowDefault is false and any
 136      * of the returned chars would have been converted to a default char,
 137      * then return null.
 138      * This is used to choose alternative means of displaying the text.
 139      */
 140     public CharsetString[] makeMultiCharsetString(char str[], int offset, int len,
 141                                                   boolean allowDefault) {
 142 
 143         if (len < 1) {
 144             return new CharsetString[0];
 145         }
 146         Vector mcs = null;
 147         char[] tmpStr = new char[len];
 148         char tmpChar = defaultChar;
 149         boolean encoded = false;
 150 
 151         FontDescriptor currentFont = defaultFont;
 152 
 153 
 154         for (int i = 0; i < componentFonts.length; i++) {
 155             if (componentFonts[i].isExcluded(str[offset])){
 156                 continue;
 157             }
 158 
 159             /* Need "encoded" variable to distinguish the case when
 160              * the default char is the same as the encoded char.
 161              * The defaultChar on Linux is '?' so it is needed there.
 162              */
 163             if (componentFonts[i].encoder.canEncode(str[offset])){
 164                 currentFont = componentFonts[i];
 165                 tmpChar = str[offset];
 166                 encoded = true;


 181             encoded = false;
 182             for (int j = 0; j < componentFonts.length; j++){
 183                 if (componentFonts[j].isExcluded(ch)){
 184                     continue;
 185                 }
 186 
 187                 if (componentFonts[j].encoder.canEncode(ch)){
 188                     fd = componentFonts[j];
 189                     tmpChar = ch;
 190                     encoded = true;
 191                     break;
 192                 }
 193             }
 194             if (!allowDefault && !encoded) {
 195                 return null;
 196             } else {
 197                 tmpStr[i] = tmpChar;
 198             }
 199             if (currentFont != fd){
 200                 if (mcs == null) {
 201                     mcs = new Vector(3);
 202                 }
 203                 mcs.addElement(new CharsetString(tmpStr, lastIndex,
 204                                                  i-lastIndex, currentFont));
 205                 currentFont = fd;
 206                 fd = defaultFont;
 207                 lastIndex = i;
 208             }
 209         }
 210         CharsetString[] result;
 211         CharsetString cs = new CharsetString(tmpStr, lastIndex,
 212                                             len-lastIndex, currentFont);
 213         if (mcs == null) {
 214             result = new CharsetString[1];
 215             result[0] = cs;
 216         } else {
 217             mcs.addElement(cs);
 218             result = new CharsetString[mcs.size()];
 219             for (int i = 0; i < mcs.size(); i++){
 220                 result[i] = (CharsetString)mcs.elementAt(i);
 221             }
 222         }
 223         return result;
 224     }
 225 
 226     /**
 227      * Is it possible that this font's metrics require the multi-font calls?
 228      * This might be true, for example, if the font supports kerning.
 229     **/
 230     public boolean mightHaveMultiFontMetrics() {
 231         return fontConfig != null;
 232     }
 233 
 234     /**
 235      * Specialized fast path string conversion for AWT.
 236      */
 237     public Object[] makeConvertedMultiFontString(String str)
 238     {
 239         return makeConvertedMultiFontChars(str.toCharArray(),0,str.length());
 240     }
 241 




 126 
 127     /**
 128      * make a array of CharsetString with given char array.
 129      * @param str The char array to convert.
 130      * @param offset offset of first character of interest
 131      * @param len number of characters to convert
 132      * @param allowDefault whether to allow the default char.
 133      * Setting this to true overloads the meaning of this method to
 134      * return non-null only if all chars can be converted.
 135      * @return array of CharsetString or if allowDefault is false and any
 136      * of the returned chars would have been converted to a default char,
 137      * then return null.
 138      * This is used to choose alternative means of displaying the text.
 139      */
 140     public CharsetString[] makeMultiCharsetString(char str[], int offset, int len,
 141                                                   boolean allowDefault) {
 142 
 143         if (len < 1) {
 144             return new CharsetString[0];
 145         }
 146         Vector<CharsetString> mcs = null;
 147         char[] tmpStr = new char[len];
 148         char tmpChar = defaultChar;
 149         boolean encoded = false;
 150 
 151         FontDescriptor currentFont = defaultFont;
 152 
 153 
 154         for (int i = 0; i < componentFonts.length; i++) {
 155             if (componentFonts[i].isExcluded(str[offset])){
 156                 continue;
 157             }
 158 
 159             /* Need "encoded" variable to distinguish the case when
 160              * the default char is the same as the encoded char.
 161              * The defaultChar on Linux is '?' so it is needed there.
 162              */
 163             if (componentFonts[i].encoder.canEncode(str[offset])){
 164                 currentFont = componentFonts[i];
 165                 tmpChar = str[offset];
 166                 encoded = true;


 181             encoded = false;
 182             for (int j = 0; j < componentFonts.length; j++){
 183                 if (componentFonts[j].isExcluded(ch)){
 184                     continue;
 185                 }
 186 
 187                 if (componentFonts[j].encoder.canEncode(ch)){
 188                     fd = componentFonts[j];
 189                     tmpChar = ch;
 190                     encoded = true;
 191                     break;
 192                 }
 193             }
 194             if (!allowDefault && !encoded) {
 195                 return null;
 196             } else {
 197                 tmpStr[i] = tmpChar;
 198             }
 199             if (currentFont != fd){
 200                 if (mcs == null) {
 201                     mcs = new Vector<>(3);
 202                 }
 203                 mcs.addElement(new CharsetString(tmpStr, lastIndex,
 204                                                  i-lastIndex, currentFont));
 205                 currentFont = fd;
 206                 fd = defaultFont;
 207                 lastIndex = i;
 208             }
 209         }
 210         CharsetString[] result;
 211         CharsetString cs = new CharsetString(tmpStr, lastIndex,
 212                                              len-lastIndex, currentFont);
 213         if (mcs == null) {
 214             result = new CharsetString[1];
 215             result[0] = cs;
 216         } else {
 217             mcs.addElement(cs);
 218             result = mcs.toArray(new CharsetString[mcs.size()]);



 219         }
 220         return result;
 221     }
 222 
 223     /**
 224      * Is it possible that this font's metrics require the multi-font calls?
 225      * This might be true, for example, if the font supports kerning.
 226     **/
 227     public boolean mightHaveMultiFontMetrics() {
 228         return fontConfig != null;
 229     }
 230 
 231     /**
 232      * Specialized fast path string conversion for AWT.
 233      */
 234     public Object[] makeConvertedMultiFontString(String str)
 235     {
 236         return makeConvertedMultiFontChars(str.toCharArray(),0,str.length());
 237     }
 238