--- old/src/windows/classes/sun/awt/windows/WPathGraphics.java Wed Aug 5 18:17:42 2009 +++ new/src/windows/classes/sun/awt/windows/WPathGraphics.java Wed Aug 5 18:17:40 2009 @@ -65,6 +65,8 @@ import sun.font.CompositeFont; import sun.font.Font2D; import sun.font.FontManager; +import sun.font.FontManagerFactory; +import sun.font.FontUtilities; import sun.font.PhysicalFont; import sun.font.TrueTypeFont; @@ -294,7 +296,7 @@ * fail that case. Just do a quick check whether its a TrueTypeFont * - ie not a Type1 font etc, and let drawString() resolve the rest. */ - Font2D font2D = FontManager.getFont2D(font); + Font2D font2D = FontUtilities.getFont2D(font); if (font2D instanceof CompositeFont || font2D instanceof TrueTypeFont) { return 1; @@ -320,7 +322,7 @@ */ private boolean strNeedsTextLayout(String str, Font font) { char[] chars = str.toCharArray(); - boolean isComplex = FontManager.isComplexText(chars, 0, chars.length); + boolean isComplex = FontUtilities.isComplexText(chars, 0, chars.length); if (!isComplex) { return false; } else if (!useGDITextLayout) { @@ -327,7 +329,7 @@ return true; } else { if (preferGDITextLayout || - (isXP() && FontManager.textLayoutIsCompatible(font))) { + (isXP() && textLayoutIsCompatible(font))) { return false; } else { return true; @@ -335,6 +337,26 @@ } } + /** + * Used by windows printing to assess if a font is likely to + * be layout compatible with JDK + * TrueType fonts should be, but if they have no GPOS table, + * but do have a GSUB table, then they are probably older + * fonts GDI handles differently. + */ + private boolean textLayoutIsCompatible(Font font) { + + Font2D font2D = FontUtilities.getFont2D(font); + if (font2D instanceof TrueTypeFont) { + TrueTypeFont ttf = (TrueTypeFont)font2D; + return + ttf.getDirectoryEntry(TrueTypeFont.GSUBTag) == null || + ttf.getDirectoryEntry(TrueTypeFont.GPOSTag) != null; + } else { + return false; + } + } + private int getAngle(Point2D.Double pt) { /* Get the rotation in 1/10'ths degree (as needed by Windows) * so that GDI can draw the text rotated. @@ -498,7 +520,7 @@ float awScale = getAwScale(scaleFactorX, scaleFactorY); int iangle = getAngle(ptx); - Font2D font2D = FontManager.getFont2D(font); + Font2D font2D = FontUtilities.getFont2D(font); if (font2D instanceof TrueTypeFont) { textOut(str, font, (TrueTypeFont)font2D, frc, scaledFontSizeY, iangle, awScale, @@ -693,7 +715,7 @@ glyphAdvPos, 0, //destination glyphPos.length/2); //num points - Font2D font2D = FontManager.getFont2D(font); + Font2D font2D = FontUtilities.getFont2D(font); if (font2D instanceof TrueTypeFont) { String family = font2D.getFamilyName(null); int style = font.getStyle() | font2D.getStyle(); @@ -792,7 +814,7 @@ char[] chars = str.toCharArray(); int len = chars.length; GlyphVector gv = null; - if (!FontManager.isComplexText(chars, 0, len)) { + if (!FontUtilities.isComplexText(chars, 0, len)) { gv = font.createGlyphVector(frc, str); } if (gv == null) {