aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/svg/PDFTextPainter.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-02-10 14:39:34 +0000
committerJeremias Maerki <jeremias@apache.org>2006-02-10 14:39:34 +0000
commit17094f3329733ab1e0b68b8e9b3c302382572f25 (patch)
tree848c68e3210147b900273d3a6da29825ccc3753a /src/java/org/apache/fop/svg/PDFTextPainter.java
parent77f908f5cce1fea0b4b5f694b31a4070bd33cfb8 (diff)
downloadxmlgraphics-fop-17094f3329733ab1e0b68b8e9b3c302382572f25.tar.gz
xmlgraphics-fop-17094f3329733ab1e0b68b8e9b3c302382572f25.zip
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
Diffstat (limited to 'src/java/org/apache/fop/svg/PDFTextPainter.java')
-rw-r--r--src/java/org/apache/fop/svg/PDFTextPainter.java15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java
index c9c4a0c64..6747b8409 100644
--- a/src/java/org/apache/fop/svg/PDFTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFTextPainter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,6 @@ import org.apache.batik.gvt.font.GVTFontFamily;
import org.apache.batik.bridge.SVGFontFamily;
import org.apache.batik.gvt.renderer.StrokingTextPainter;
-import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
@@ -58,7 +57,7 @@ import org.apache.fop.fonts.FontTriplet;
* (todo) use drawString(AttributedCharacterIterator iterator...) for some
*
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @version $Id: PDFTextPainter.java,v 1.16 2003/03/07 09:51:25 jeremias Exp $
+ * @version $Id$
*/
public class PDFTextPainter implements TextPainter {
private FontInfo fontInfo;
@@ -179,11 +178,8 @@ public class PDFTextPainter implements TextPainter {
if (fi.hasFont(fontFamily, style, weight)) {
FontTriplet triplet = fontInfo.fontLookup(fontFamily, style,
weight);
- String fname = fontInfo.getInternalFontKey(triplet);
- fontInfo.useFont(fname);
- FontMetrics metrics = fontInfo.getMetricsFor(fname);
int fsize = (int)(size.floatValue() * 1000);
- fontState = new Font(fname, triplet, metrics, fsize);
+ fontState = fontInfo.getFontInstance(triplet, fsize);
found = true;
break;
}
@@ -191,11 +187,8 @@ public class PDFTextPainter implements TextPainter {
}
if (!found) {
FontTriplet triplet = fontInfo.fontLookup("any", style, Font.NORMAL);
- String fname = fontInfo.getInternalFontKey(triplet);
- fontInfo.useFont(fname);
- FontMetrics metrics = fontInfo.getMetricsFor(fname);
int fsize = (int)(size.floatValue() * 1000);
- fontState = new Font(fname, triplet, metrics, fsize);
+ fontState = fontInfo.getFontInstance(triplet, fsize);
} else {
if (g2d instanceof PDFGraphics2D) {
((PDFGraphics2D) g2d).setOverrideFontState(fontState);