diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-03-27 11:17:46 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-03-27 11:17:46 +0000 |
commit | 16062b1a765977989c3544abf0438f4463ff66c8 (patch) | |
tree | da55fa03e2ff2e23927e701fbf20086f3d2fea4f /src/java/org | |
parent | 3c4cc0bb1f07556e12f2f9db9cf437e54210f21c (diff) | |
download | xmlgraphics-fop-16062b1a765977989c3544abf0438f4463ff66c8.tar.gz xmlgraphics-fop-16062b1a765977989c3544abf0438f4463ff66c8.zip |
Added method for build a font list from an Avalon Configuration object.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196173 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/render/pdf/FontSetup.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/render/pdf/FontSetup.java b/src/java/org/apache/fop/render/pdf/FontSetup.java index 684fa3652..d2bd02e12 100644 --- a/src/java/org/apache/fop/render/pdf/FontSetup.java +++ b/src/java/org/apache/fop/render/pdf/FontSetup.java @@ -51,6 +51,8 @@ package org.apache.fop.render.pdf; // FOP +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontDescriptor; import org.apache.fop.fonts.LazyFont; @@ -262,9 +264,39 @@ public class FontSetup { if (font instanceof FontDescriptor) { desc = (FontDescriptor)font; } - resources.addFont(doc.makeFont(f, font.getFontName(), - font.getEncoding(), font, desc)); + resources.addFont(doc.getFactory().makeFont( + f, font.getFontName(), font.getEncoding(), font, desc)); } } + + + /** + * Builds a list of EmbedFontInfo objects for use with the setup() method. + * @param cfg Configuration object + * @return List the newly created list of fonts + * @throws ConfigurationException if something's wrong with the config data + */ + public static List buildFontListFromConfiguration(Configuration cfg) + throws ConfigurationException { + List fontList = new java.util.ArrayList(); + Configuration[] font = cfg.getChildren("font"); + for (int i = 0; i < font.length; i++) { + Configuration[] triple = font[i].getChildren("font-triplet"); + List tripleList = new java.util.ArrayList(); + for (int j = 0; j < triple.length; j++) { + tripleList.add(new FontTriplet(triple[j].getAttribute("name"), + triple[j].getAttribute("weight"), + triple[j].getAttribute("style"))); + } + + EmbedFontInfo efi; + efi = new EmbedFontInfo(font[i].getAttribute("metrics-url"), + font[i].getAttributeAsBoolean("kerning"), + tripleList, font[i].getAttribute("embed-url")); + + fontList.add(efi); + } + return fontList; + } } |