]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added method for build a font list from an Avalon Configuration object.
authorJeremias Maerki <jeremias@apache.org>
Thu, 27 Mar 2003 11:17:46 +0000 (11:17 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 27 Mar 2003 11:17:46 +0000 (11:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196173 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/pdf/FontSetup.java

index 684fa3652f020aacc40f96591c5e59cb5ebed022..d2bd02e12a7f8eba773f739a2d63b780899d658a 100644 (file)
@@ -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;
+    }
 }