You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2003/03/27 12:17:46 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/pdf FontSetup.java

jeremias    2003/03/27 03:17:46

  Modified:    src/java/org/apache/fop/render/pdf FontSetup.java
  Log:
  Added method for build a font list from an Avalon Configuration object.
  
  Revision  Changes    Path
  1.2       +34 -2     xml-fop/src/java/org/apache/fop/render/pdf/FontSetup.java
  
  Index: FontSetup.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/FontSetup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FontSetup.java	11 Mar 2003 13:05:13 -0000	1.1
  +++ FontSetup.java	27 Mar 2003 11:17:46 -0000	1.2
  @@ -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 @@
               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;
       }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org