diff options
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFResources.java')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFResources.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index 76f303113..ead46edaa 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.java @@ -50,6 +50,10 @@ */ package org.apache.fop.pdf; +import org.apache.fop.apps.Document; +import org.apache.fop.fonts.Typeface; +import org.apache.fop.fonts.FontDescriptor; + // Java import java.util.Iterator; import java.util.Map; @@ -111,6 +115,27 @@ public class PDFResources extends PDFObject { } /** + * Add the fonts in the font info to this PDF document's Font Resources. + * + * @param doc PDF document to add fonts to + * @param fontInfo font info object to get font information from + */ + public void addFonts(PDFDocument doc, Document fontInfo) { + Map fonts = fontInfo.getUsedFonts(); + Iterator e = fonts.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; + } + addFont(doc.getFactory().makeFont( + f, font.getFontName(), font.getEncoding(), font, desc)); + } + } + + /** * Add a PDFGState to the resources. * * @param gs the PDFGState to add |