src/windows/classes/sun/awt/windows/WPathGraphics.java

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

*** 63,72 **** --- 63,74 ---- import sun.font.CharToGlyphMapper; 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; import sun.print.PathGraphics; import sun.print.ProxyGraphics2D;
*** 292,302 **** * unknown to GDI. Those can be registered too, although that * code does not exist yet, it can be added too, so we should not * 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); if (font2D instanceof CompositeFont || font2D instanceof TrueTypeFont) { return 1; } else { return 0; --- 294,304 ---- * unknown to GDI. Those can be registered too, although that * code does not exist yet, it can be added too, so we should not * 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 = FontUtilities.getFont2D(font); if (font2D instanceof CompositeFont || font2D instanceof TrueTypeFont) { return 1; } else { return 0;
*** 318,342 **** * be drawn via TextLayout, which in is rendered as runs of * GlyphVectors, to which we can assign positions for each glyph. */ private boolean strNeedsTextLayout(String str, Font font) { char[] chars = str.toCharArray(); ! boolean isComplex = FontManager.isComplexText(chars, 0, chars.length); if (!isComplex) { return false; } else if (!useGDITextLayout) { return true; } else { if (preferGDITextLayout || ! (isXP() && FontManager.textLayoutIsCompatible(font))) { return false; } else { return true; } } } 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. * This calculation is only valid for a uniform scale, no shearing. */ --- 320,364 ---- * be drawn via TextLayout, which in is rendered as runs of * GlyphVectors, to which we can assign positions for each glyph. */ private boolean strNeedsTextLayout(String str, Font font) { char[] chars = str.toCharArray(); ! boolean isComplex = FontUtilities.isComplexText(chars, 0, chars.length); if (!isComplex) { return false; } else if (!useGDITextLayout) { return true; } else { if (preferGDITextLayout || ! (isXP() && textLayoutIsCompatible(font))) { return false; } else { return true; } } } + /** + * 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. * This calculation is only valid for a uniform scale, no shearing. */
*** 496,506 **** float scaledFontSizeX = (float)(fontSize * scaleFactorX); float awScale = getAwScale(scaleFactorX, scaleFactorY); int iangle = getAngle(ptx); ! Font2D font2D = FontManager.getFont2D(font); if (font2D instanceof TrueTypeFont) { textOut(str, font, (TrueTypeFont)font2D, frc, scaledFontSizeY, iangle, awScale, deviceTransform, scaleFactorX, x, y, devpos.x, devpos.y, targetW); --- 518,528 ---- float scaledFontSizeX = (float)(fontSize * scaleFactorX); float awScale = getAwScale(scaleFactorX, scaleFactorY); int iangle = getAngle(ptx); ! Font2D font2D = FontUtilities.getFont2D(font); if (font2D instanceof TrueTypeFont) { textOut(str, font, (TrueTypeFont)font2D, frc, scaledFontSizeY, iangle, awScale, deviceTransform, scaleFactorX, x, y, devpos.x, devpos.y, targetW);
*** 691,701 **** advanceTransform.transform(glyphPos, 0, //source glyphAdvPos, 0, //destination glyphPos.length/2); //num points ! Font2D font2D = FontManager.getFont2D(font); if (font2D instanceof TrueTypeFont) { String family = font2D.getFamilyName(null); int style = font.getStyle() | font2D.getStyle(); if (!wPrinterJob.setFont(family, scaledFontSizeY, style, iangle, awScale)) { --- 713,723 ---- advanceTransform.transform(glyphPos, 0, //source glyphAdvPos, 0, //destination glyphPos.length/2); //num points ! Font2D font2D = FontUtilities.getFont2D(font); if (font2D instanceof TrueTypeFont) { String family = font2D.getFamilyName(null); int style = font.getStyle() | font2D.getStyle(); if (!wPrinterJob.setFont(family, scaledFontSizeY, style, iangle, awScale)) {
*** 790,800 **** */ str = wPrinterJob.removeControlChars(str); char[] chars = str.toCharArray(); int len = chars.length; GlyphVector gv = null; ! if (!FontManager.isComplexText(chars, 0, len)) { gv = font.createGlyphVector(frc, str); } if (gv == null) { super.drawString(str, userx, usery, font, frc, targetW); return; --- 812,822 ---- */ str = wPrinterJob.removeControlChars(str); char[] chars = str.toCharArray(); int len = chars.length; GlyphVector gv = null; ! if (!FontUtilities.isComplexText(chars, 0, len)) { gv = font.createGlyphVector(frc, str); } if (gv == null) { super.drawString(str, userx, usery, font, frc, targetW); return;