cvs commit: xml-fop/src/java/org/apache/fop/render/pdf FontSetup.java
jeremias2003/07/04 12:25:51 Modified:src/java/org/apache/fop/render/pdf FontSetup.java Log: Use code from the new FontUtil class. Revision ChangesPath 1.4 +2 -21 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FontSetup.java3 Apr 2003 12:51:27 - 1.3 +++ FontSetup.java4 Jul 2003 19:25:51 - 1.4 @@ -55,6 +55,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontDescriptor; +import org.apache.fop.fonts.FontUtil; import org.apache.fop.fonts.LazyFont; import org.apache.fop.layout.FontInfo; import org.apache.fop.pdf.PDFDocument; @@ -229,27 +230,7 @@ for (int c = 0; c triplets.size(); c++) { FontTriplet triplet = (FontTriplet)triplets.get(c); -int weight = 400; -try { -weight = Integer.parseInt(triplet.getWeight()); -weight = ((int)weight / 100) * 100; -weight = Math.max(weight, 100); -weight = Math.min(weight, 900); -} catch (NumberFormatException nfe) { -//weight is no number, so convert smybolic name to number -if (triplet.getWeight().equals(normal)) { -weight = 400; -} else if (triplet.getWeight().equals(bold)) { -weight = 700; -} else { -throw new IllegalArgumentException( -Illegal value for font weight: ' -+ triplet.getWeight() -+ '. Use one of: 100, 200, 300, -+ 400, 500, 600, 700, 800, 900, -+ normal (=400), bold (=700)); -} -} +int weight = FontUtil.parseCSS2FontWeight(triplet.getWeight()); //System.out.println(Registering: +triplet+ weight=+weight); fontInfo.addFontProperties(internalName, triplet.getName(), - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/java/org/apache/fop/render/pdf FontSetup.java
jeremias2003/04/03 04:51:27 Modified:src/java/org/apache/fop/render/pdf FontSetup.java Log: Fix font registration (normal and bold work again, invalid values get barked at) Make the kerning and embedding-url attributes optional as it should be Revision ChangesPath 1.3 +18 -5 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FontSetup.java27 Mar 2003 11:17:46 - 1.2 +++ FontSetup.java3 Apr 2003 12:51:27 - 1.3 @@ -233,11 +233,24 @@ try { weight = Integer.parseInt(triplet.getWeight()); weight = ((int)weight / 100) * 100; -weight = Math.min(weight, 100); -weight = Math.max(weight, 900); +weight = Math.max(weight, 100); +weight = Math.min(weight, 900); } catch (NumberFormatException nfe) { -/[EMAIL PROTECTED] log this exception */ +//weight is no number, so convert smybolic name to number +if (triplet.getWeight().equals(normal)) { +weight = 400; +} else if (triplet.getWeight().equals(bold)) { +weight = 700; +} else { +throw new IllegalArgumentException( +Illegal value for font weight: ' ++ triplet.getWeight() ++ '. Use one of: 100, 200, 300, ++ 400, 500, 600, 700, 800, 900, ++ normal (=400), bold (=700)); +} } +//System.out.println(Registering: +triplet+ weight=+weight); fontInfo.addFontProperties(internalName, triplet.getName(), triplet.getStyle(), @@ -291,8 +304,8 @@ EmbedFontInfo efi; efi = new EmbedFontInfo(font[i].getAttribute(metrics-url), -font[i].getAttributeAsBoolean(kerning), -tripleList, font[i].getAttribute(embed-url)); +font[i].getAttributeAsBoolean(kerning, false), +tripleList, font[i].getAttribute(embed-url, null)); fontList.add(efi); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/java/org/apache/fop/render/pdf FontSetup.java
jeremias2003/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 ChangesPath 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.java11 Mar 2003 13:05:13 - 1.1 +++ FontSetup.java27 Mar 2003 11:17:46 - 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]