From 17094f3329733ab1e0b68b8e9b3c302382572f25 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 10 Feb 2006 14:39:34 +0000 Subject: Creation of Font instances centralized in FontInfo and added a cache for them. This removes duplicate code in a number of places, improves speed a little and saves memory. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@376706 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/svg/PDFGraphics2D.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/java/org/apache/fop/svg/PDFGraphics2D.java') diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 732cd95bd..9a8ef1d7a 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -35,7 +35,6 @@ import org.apache.fop.pdf.BitmapImage; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontSetup; -import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.fonts.LazyFont; import org.apache.fop.image.JpegImage; @@ -1396,14 +1395,10 @@ public class PDFGraphics2D extends AbstractGraphics2D { String style = gFont.isItalic() ? "italic" : "normal"; int weight = gFont.isBold() ? Font.BOLD : Font.NORMAL; FontTriplet triplet = fontInfo.fontLookup(n, style, weight); - String fname = fontInfo.getInternalFontKey(triplet); - fontInfo.useFont(fname); - FontMetrics metrics = fontInfo.getMetricsFor(fname); - fontState = new Font(fname, triplet, metrics, siz * 1000); + fontState = fontInfo.getFontInstance(triplet, siz * 1000); } else { - FontMetrics metrics = fontInfo.getMetricsFor(ovFontState.getFontName()); - fontState = new Font(ovFontState.getFontName(), ovFontState.getFontTriplet(), - metrics, ovFontState.getFontSize()); + fontState = fontInfo.getFontInstance( + ovFontState.getFontTriplet(), ovFontState.getFontSize()); ovFontState = null; } String name; -- cgit v1.2.3