< prev index next >

src/java.desktop/share/classes/sun/font/FileFontStrike.java

Print this page




  97      * outline retrieved. This assumes that bounds then outline will always
  98      * be retrieved for a glyph rather than retrieving bounds for all glyphs
  99      * then outlines for all glyphs.
 100      */
 101     ConcurrentHashMap<Integer, Rectangle2D.Float> boundsMap;
 102     SoftReference<ConcurrentHashMap<Integer, Point2D.Float>>
 103         glyphMetricsMapRef;
 104 
 105     AffineTransform invertDevTx;
 106 
 107     boolean useNatives;
 108     NativeStrike[] nativeStrikes;
 109 
 110     /* Used only for communication to native layer */
 111     private int intPtSize;
 112 
 113     /* Perform global initialisation needed for Windows native rasterizer */
 114     private static native boolean initNative();
 115     private static boolean isXPorLater = false;
 116     static {
 117         if (FontUtilities.isWindows && !FontUtilities.useT2K &&
 118             !GraphicsEnvironment.isHeadless()) {
 119             isXPorLater = initNative();
 120         }
 121     }
 122 
 123     FileFontStrike(FileFont fileFont, FontStrikeDesc desc) {
 124         super(fileFont, desc);
 125         this.fileFont = fileFont;
 126 
 127         if (desc.style != fileFont.style) {
 128           /* If using algorithmic styling, the base values are
 129            * boldness = 1.0, italic = 0.0. The superclass constructor
 130            * initialises these.
 131            */
 132             if ((desc.style & Font.ITALIC) == Font.ITALIC &&
 133                 (fileFont.style & Font.ITALIC) == 0) {
 134                 algoStyle = true;
 135                 italic = 0.7f;
 136             }
 137             if ((desc.style & Font.BOLD) == Font.BOLD &&


 211          *     other hand getting NULL here seems to be extremely unlikely.
 212          */
 213         if (pScalerContext == 0L) {
 214             /* REMIND: when the code is updated to install cache objects
 215              * rather than using a switch this will be more efficient.
 216              */
 217             this.disposer = new FontStrikeDisposer(fileFont, desc);
 218             initGlyphCache();
 219             pScalerContext = NullFontScaler.getNullScalerContext();
 220             SunFontManager.getInstance().deRegisterBadFont(fileFont);
 221             return;
 222         }
 223         /* First, see if native code should be used to create the glyph.
 224          * GDI will return the integer metrics, not fractional metrics, which
 225          * may be requested for this strike, so we would require here that :
 226          * desc.fmHint != INTVAL_FRACTIONALMETRICS_ON
 227          * except that the advance returned by GDI is always overwritten by
 228          * the JDK rasteriser supplied one (see getGlyphImageFromWindows()).
 229          */
 230         if (FontUtilities.isWindows && isXPorLater &&
 231             !FontUtilities.useT2K &&
 232             !GraphicsEnvironment.isHeadless() &&
 233             !fileFont.useJavaRasterizer &&
 234             (desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB ||
 235              desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HBGR) &&
 236             (matrix[1] == 0.0 && matrix[2] == 0.0 &&
 237              matrix[0] == matrix[3] &&
 238              matrix[0] >= 3.0 && matrix[0] <= 100.0) &&
 239             !((TrueTypeFont)fileFont).useEmbeddedBitmapsForSize(intPtSize)) {
 240             useNatives = true;
 241         }
 242         else if (fileFont.checkUseNatives() && desc.aaHint==0 && !algoStyle) {
 243             /* Check its a simple scale of a pt size in the range
 244              * where native bitmaps typically exist (6-36 pts) */
 245             if (matrix[1] == 0.0 && matrix[2] == 0.0 &&
 246                 matrix[0] >= 6.0 && matrix[0] <= 36.0 &&
 247                 matrix[0] == matrix[3]) {
 248                 useNatives = true;
 249                 int numNatives = fileFont.nativeFonts.length;
 250                 nativeStrikes = new NativeStrike[numNatives];
 251                 /* Maybe initialise these strikes lazily?. But we




  97      * outline retrieved. This assumes that bounds then outline will always
  98      * be retrieved for a glyph rather than retrieving bounds for all glyphs
  99      * then outlines for all glyphs.
 100      */
 101     ConcurrentHashMap<Integer, Rectangle2D.Float> boundsMap;
 102     SoftReference<ConcurrentHashMap<Integer, Point2D.Float>>
 103         glyphMetricsMapRef;
 104 
 105     AffineTransform invertDevTx;
 106 
 107     boolean useNatives;
 108     NativeStrike[] nativeStrikes;
 109 
 110     /* Used only for communication to native layer */
 111     private int intPtSize;
 112 
 113     /* Perform global initialisation needed for Windows native rasterizer */
 114     private static native boolean initNative();
 115     private static boolean isXPorLater = false;
 116     static {
 117         if (FontUtilities.isWindows && !FontUtilities.useJDKScaler &&
 118             !GraphicsEnvironment.isHeadless()) {
 119             isXPorLater = initNative();
 120         }
 121     }
 122 
 123     FileFontStrike(FileFont fileFont, FontStrikeDesc desc) {
 124         super(fileFont, desc);
 125         this.fileFont = fileFont;
 126 
 127         if (desc.style != fileFont.style) {
 128           /* If using algorithmic styling, the base values are
 129            * boldness = 1.0, italic = 0.0. The superclass constructor
 130            * initialises these.
 131            */
 132             if ((desc.style & Font.ITALIC) == Font.ITALIC &&
 133                 (fileFont.style & Font.ITALIC) == 0) {
 134                 algoStyle = true;
 135                 italic = 0.7f;
 136             }
 137             if ((desc.style & Font.BOLD) == Font.BOLD &&


 211          *     other hand getting NULL here seems to be extremely unlikely.
 212          */
 213         if (pScalerContext == 0L) {
 214             /* REMIND: when the code is updated to install cache objects
 215              * rather than using a switch this will be more efficient.
 216              */
 217             this.disposer = new FontStrikeDisposer(fileFont, desc);
 218             initGlyphCache();
 219             pScalerContext = NullFontScaler.getNullScalerContext();
 220             SunFontManager.getInstance().deRegisterBadFont(fileFont);
 221             return;
 222         }
 223         /* First, see if native code should be used to create the glyph.
 224          * GDI will return the integer metrics, not fractional metrics, which
 225          * may be requested for this strike, so we would require here that :
 226          * desc.fmHint != INTVAL_FRACTIONALMETRICS_ON
 227          * except that the advance returned by GDI is always overwritten by
 228          * the JDK rasteriser supplied one (see getGlyphImageFromWindows()).
 229          */
 230         if (FontUtilities.isWindows && isXPorLater &&
 231             !FontUtilities.useJDKScaler &&
 232             !GraphicsEnvironment.isHeadless() &&
 233             !fileFont.useJavaRasterizer &&
 234             (desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB ||
 235              desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HBGR) &&
 236             (matrix[1] == 0.0 && matrix[2] == 0.0 &&
 237              matrix[0] == matrix[3] &&
 238              matrix[0] >= 3.0 && matrix[0] <= 100.0) &&
 239             !((TrueTypeFont)fileFont).useEmbeddedBitmapsForSize(intPtSize)) {
 240             useNatives = true;
 241         }
 242         else if (fileFont.checkUseNatives() && desc.aaHint==0 && !algoStyle) {
 243             /* Check its a simple scale of a pt size in the range
 244              * where native bitmaps typically exist (6-36 pts) */
 245             if (matrix[1] == 0.0 && matrix[2] == 0.0 &&
 246                 matrix[0] >= 6.0 && matrix[0] <= 36.0 &&
 247                 matrix[0] == matrix[3]) {
 248                 useNatives = true;
 249                 int numNatives = fileFont.nativeFonts.length;
 250                 nativeStrikes = new NativeStrike[numNatives];
 251                 /* Maybe initialise these strikes lazily?. But we


< prev index next >