From 16062b1a765977989c3544abf0438f4463ff66c8 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 27 Mar 2003 11:17:46 +0000 Subject: [PATCH] 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 --- .../org/apache/fop/render/pdf/FontSetup.java | 36 +++++++++++++++++-- 1 file 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; + } } -- 2.39.5