From 250a5e5363af3462693c80227e0666d0b5b75a8f Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 22 Dec 2005 20:10:54 +0000 Subject: As announced, I brought FontTriplet to more life by making it Serializable and using it to transport the information about the font in use through the area tree. This has small effects on the test cases as the values in the generated XML are slightly different. While refactoring I saw that there's some room for optimization. Too many objects are still created. It should be quite easy now with the FontTriplet to create a small cache. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@358613 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/render/ps/PSTextPainter.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/java/org/apache/fop/render/ps/PSTextPainter.java') diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index 7153ea4f5..aba67759c 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -48,6 +48,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontTriplet; /** * Renders the attributed character iterator of a TextNode. @@ -384,19 +385,22 @@ public class PSTextPainter implements TextPainter { }*/ fontFamily = fam.getFamilyName(); if (fontInfo.hasFont(fontFamily, style, weight)) { - String fname = fontInfo.fontLookup( + FontTriplet triplet = fontInfo.fontLookup( fontFamily, style, weight); + String fname = fontInfo.getInternalFontKey(triplet); + fontInfo.useFont(fname); FontMetrics metrics = fontInfo.getMetricsFor(fname); int fsize = (int)(fontSize.floatValue() * 1000); - return new Font(fname, metrics, fsize); + return new Font(fname, triplet, metrics, fsize); } } } - String fname = fontInfo.fontLookup( - "any", style, Font.NORMAL); + FontTriplet triplet = fontInfo.fontLookup("any", style, Font.NORMAL); + String fname = fontInfo.getInternalFontKey(triplet); + fontInfo.useFont(fname); FontMetrics metrics = fontInfo.getMetricsFor(fname); int fsize = (int)(fontSize.floatValue() * 1000); - return new Font(fname, metrics, fsize); + return new Font(fname, triplet, metrics, fsize); } private java.awt.Font makeAWTFont(AttributedCharacterIterator aci, Font font) { -- cgit v1.2.3