diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-11-03 10:51:31 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-11-03 10:51:31 +0000 |
commit | 281ac8bcab030f3cb9646f4eb3895f320a1abb6b (patch) | |
tree | 691fef15e6dd437269f05c030adde096d2f72a22 /src/java/org/apache/fop/pdf/PDFResources.java | |
parent | b58bd2b16672a0a39ac5d3d4d24291569fad6697 (diff) | |
download | xmlgraphics-fop-281ac8bcab030f3cb9646f4eb3895f320a1abb6b.tar.gz xmlgraphics-fop-281ac8bcab030f3cb9646f4eb3895f320a1abb6b.zip |
More fine-grained mechanism to detect if a font has been used or not. If a font list is given for a text run and each character should be painted in the right font, it might be accessed but never really used. Needed for PDF text painting improvements.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@591583 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFResources.java')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFResources.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index 310f8d8d0..d9420946a 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.java @@ -19,17 +19,16 @@ package org.apache.fop.pdf; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.Typeface; -import org.apache.fop.fonts.FontDescriptor; -import org.apache.fop.util.ColorProfileUtil; - -// Java +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; -import java.util.HashMap; -import java.util.HashSet; + +import org.apache.fop.fonts.FontDescriptor; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.Typeface; +import org.apache.fop.util.ColorProfileUtil; /** * class representing a /Resources object. @@ -97,17 +96,22 @@ public class PDFResources extends PDFObject { * @param fontInfo font info object to get font information from */ public void addFonts(PDFDocument doc, FontInfo fontInfo) { - Map fonts = fontInfo.getUsedFonts(); - Iterator e = fonts.keySet().iterator(); + Map usedFonts = fontInfo.getUsedFonts(); + Iterator e = usedFonts.keySet().iterator(); while (e.hasNext()) { String f = (String)e.next(); - Typeface font = (Typeface)fonts.get(f); - FontDescriptor desc = null; - if (font instanceof FontDescriptor) { - desc = (FontDescriptor)font; + Typeface font = (Typeface)usedFonts.get(f); + + //Check if the font actually had any mapping operations. If not, it is an indication + //that it has never actually been used and therefore doesn't have to be embedded. + if (font.hadMappingOperations()) { + FontDescriptor desc = null; + if (font instanceof FontDescriptor) { + desc = (FontDescriptor)font; + } + addFont(doc.getFactory().makeFont( + f, font.getFontName(), font.getEncoding(), font, desc)); } - addFont(doc.getFactory().makeFont( - f, font.getFontName(), font.getEncoding(), font, desc)); } } |