src/solaris/classes/sun/font/NativeFont.java

Print this page
rev 1379 : [mq]: fontmanager.patch


 225     public static boolean fontExists(String xlfd) {
 226         byte[] bytes = null;
 227         try {
 228             bytes = xlfd.getBytes("UTF-8");
 229         } catch (UnsupportedEncodingException e) {
 230             bytes = xlfd.getBytes();
 231         }
 232         return fontExists(bytes);
 233     }
 234 
 235     private static native boolean haveBitmapFonts(byte[] xlfd);
 236     private static native boolean fontExists(byte[] xlfd);
 237 
 238     public CharToGlyphMapper getMapper() {
 239         if (mapper == null) {
 240             if (isBitmapDelegate) {
 241                 /* we are a delegate */
 242                 mapper = new NativeGlyphMapper(this);
 243             } else {
 244                 /* we need to delegate */
 245                 delegateFont = FontManager.getDefaultPhysicalFont();

 246                 mapper = delegateFont.getMapper();
 247             }
 248         }
 249         return mapper;
 250     }
 251 
 252     FontStrike createStrike(FontStrikeDesc desc) {
 253         if (isBitmapDelegate) {
 254             return new NativeStrike(this, desc);
 255         } else {
 256             if (delegateFont == null) {
 257                 delegateFont = FontManager.getDefaultPhysicalFont();

 258             }
 259             /* If no FileFont's are found, delegate font may be
 260              * a NativeFont, so we need to avoid recursing here.
 261              */
 262             if (delegateFont instanceof NativeFont) {
 263                 return new NativeStrike((NativeFont)delegateFont, desc);
 264             }
 265             FontStrike delegate = delegateFont.createStrike(desc);
 266             return new DelegateStrike(this, desc, delegate);
 267         }
 268     }
 269 
 270     public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
 271             return null;
 272     }
 273 
 274     native StrikeMetrics getFontMetrics(long pScalerContext);
 275 
 276     native float getGlyphAdvance(long pContext, int glyphCode);
 277 


 297     }
 298 
 299     public  GeneralPath getGlyphVectorOutline(long pScalerContext,
 300                                               int[] glyphs, int numGlyphs,
 301                                               float x,  float y) {
 302         return null;
 303     }
 304 
 305     private native int countGlyphs(byte[] platformNameBytes, int ptSize);
 306 
 307     public int getNumGlyphs() {
 308         if (numGlyphs == -1) {
 309             byte[] bytes = getPlatformNameBytes(8);
 310             numGlyphs = countGlyphs(bytes, 8);
 311         }
 312         return numGlyphs;
 313     }
 314 
 315     PhysicalFont getDelegateFont() {
 316         if (delegateFont == null) {
 317             delegateFont = FontManager.getDefaultPhysicalFont();

 318         }
 319         return delegateFont;
 320     }
 321 
 322     /* Specify that the dpi is 72x72, as this corresponds to JDK's
 323      * default user space. These are the 10th and 11th fields in the XLFD.
 324      * ptSize in XLFD is in 10th's of a point so multiply by 10,
 325      * Replace the 9th field in the XLFD (ie after the 8th hyphen)
 326      * with this pt size (this corresponds to the field that's "%d" in the
 327      * font configuration files). Wild card the other numeric fields.
 328      * ie to request 12 pt Times New Roman italic font, use an XLFD like :
 329      * -monotype-times new roman-regular-i---*-120-72-72-p-*-iso8859-1
 330      */
 331     byte[] getPlatformNameBytes(int ptSize) {
 332         int[] hPos = new int[14];
 333         int hyphenCnt = 1;
 334         int pos = 1;
 335 
 336         while (pos != -1 && hyphenCnt < 14) {
 337             pos = platName.indexOf('-', pos);




 225     public static boolean fontExists(String xlfd) {
 226         byte[] bytes = null;
 227         try {
 228             bytes = xlfd.getBytes("UTF-8");
 229         } catch (UnsupportedEncodingException e) {
 230             bytes = xlfd.getBytes();
 231         }
 232         return fontExists(bytes);
 233     }
 234 
 235     private static native boolean haveBitmapFonts(byte[] xlfd);
 236     private static native boolean fontExists(byte[] xlfd);
 237 
 238     public CharToGlyphMapper getMapper() {
 239         if (mapper == null) {
 240             if (isBitmapDelegate) {
 241                 /* we are a delegate */
 242                 mapper = new NativeGlyphMapper(this);
 243             } else {
 244                 /* we need to delegate */
 245                 SunFontManager fm = SunFontManager.getInstance();
 246                 delegateFont = fm.getDefaultPhysicalFont();
 247                 mapper = delegateFont.getMapper();
 248             }
 249         }
 250         return mapper;
 251     }
 252 
 253     FontStrike createStrike(FontStrikeDesc desc) {
 254         if (isBitmapDelegate) {
 255             return new NativeStrike(this, desc);
 256         } else {
 257             if (delegateFont == null) {
 258                 SunFontManager fm = SunFontManager.getInstance();
 259                 delegateFont = fm.getDefaultPhysicalFont();
 260             }
 261             /* If no FileFont's are found, delegate font may be
 262              * a NativeFont, so we need to avoid recursing here.
 263              */
 264             if (delegateFont instanceof NativeFont) {
 265                 return new NativeStrike((NativeFont)delegateFont, desc);
 266             }
 267             FontStrike delegate = delegateFont.createStrike(desc);
 268             return new DelegateStrike(this, desc, delegate);
 269         }
 270     }
 271 
 272     public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
 273             return null;
 274     }
 275 
 276     native StrikeMetrics getFontMetrics(long pScalerContext);
 277 
 278     native float getGlyphAdvance(long pContext, int glyphCode);
 279 


 299     }
 300 
 301     public  GeneralPath getGlyphVectorOutline(long pScalerContext,
 302                                               int[] glyphs, int numGlyphs,
 303                                               float x,  float y) {
 304         return null;
 305     }
 306 
 307     private native int countGlyphs(byte[] platformNameBytes, int ptSize);
 308 
 309     public int getNumGlyphs() {
 310         if (numGlyphs == -1) {
 311             byte[] bytes = getPlatformNameBytes(8);
 312             numGlyphs = countGlyphs(bytes, 8);
 313         }
 314         return numGlyphs;
 315     }
 316 
 317     PhysicalFont getDelegateFont() {
 318         if (delegateFont == null) {
 319             SunFontManager fm = SunFontManager.getInstance();
 320             delegateFont = fm.getDefaultPhysicalFont();
 321         }
 322         return delegateFont;
 323     }
 324 
 325     /* Specify that the dpi is 72x72, as this corresponds to JDK's
 326      * default user space. These are the 10th and 11th fields in the XLFD.
 327      * ptSize in XLFD is in 10th's of a point so multiply by 10,
 328      * Replace the 9th field in the XLFD (ie after the 8th hyphen)
 329      * with this pt size (this corresponds to the field that's "%d" in the
 330      * font configuration files). Wild card the other numeric fields.
 331      * ie to request 12 pt Times New Roman italic font, use an XLFD like :
 332      * -monotype-times new roman-regular-i---*-120-72-72-p-*-iso8859-1
 333      */
 334     byte[] getPlatformNameBytes(int ptSize) {
 335         int[] hPos = new int[14];
 336         int hyphenCnt = 1;
 337         int pos = 1;
 338 
 339         while (pos != -1 && hyphenCnt < 14) {
 340             pos = platName.indexOf('-', pos);