You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Glenn Adams <gl...@skynav.com> on 2014/11/11 08:59:11 UTC

Re: svn commit: r1637817 - in /xmlgraphics/fop/trunk: src/foschema/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/ src/java/org/apache/fop/fonts/type1/ src/java/org/apache/fop/render/java2d/ test/java/org/apache/fop/fonts/

Your commit broke the build (junit). Getting an NPE at highlight diff below
when fontUris is null when running

Testsuite: org.apache.fop.BasicTranscoderTestSuite
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.131 sec
Testcase: testGenericPDFTranscoder took 1.578 sec
        Caused an ERROR
Error while setting up PDFDocumentGraphics2D
Enclosed Exception:
null
org.apache.batik.transcoder.TranscoderException: Error while setting up
PDFDocumentGraphics2D
Enclosed Exception:
null
     at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:137)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown
Source)
at
org.apache.fop.AbstractBasicTranscoderTest.testGenericPDFTranscoder(AbstractBasicTranscoderTest.java:71)

@@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
      * @return true if the font is embedded, false if it is referenced.
      */
     public boolean isEmbedded() {
-        if (embedURI == null) {
+        if (fontUris.getEmbed() == null) {
             return false;
         } else {
             return this.embedded;


On Mon, Nov 10, 2014 at 6:18 PM, <lb...@apache.org> wrote:

> Author: lbernardo
> Date: Mon Nov 10 11:18:43 2014
> New Revision: 1637817
>
> URL: http://svn.apache.org/r1637817
> Log:
> FOP-2424: Allow for type1 afm/pfm files to be in a different path than the
> pfb file
>
> Added:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>  (with props)
> Modified:
>     xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>
> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>
> Modified: xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd (original)
> +++ xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd Mon Nov 10
> 11:18:43 2014
> @@ -283,6 +283,8 @@
>      </xsd:sequence>
>      <xsd:attribute name="metrics-url" type="xsd:anyURI" use="optional"/>
>      <xsd:attribute name="embed-url" type="xsd:anyURI" use="optional"/>
> +    <xsd:attribute name="embed-url-afm" type="xsd:anyURI" use="optional"/>
> +    <xsd:attribute name="embed-url-pfm" type="xsd:anyURI" use="optional"/>
>      <xsd:attribute name="sub-font" type="xsd:string" use="optional"/>
>      <xsd:attribute name="embedding-mode" use="optional">
>        <xsd:simpleType>
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
> (original)
> +++
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
> Mon Nov 10 11:18:43 2014
> @@ -108,11 +108,13 @@ public final class DefaultFontConfig imp
>                              strict);
>                      continue;
>                  }
> -                Font font = new Font(fontCfg.getAttribute("metrics-url",
> null), embed,
> -                        fontCfg.getAttribute("sub-font", null),
> fontCfg.getAttributeAsBoolean(
> -                                "kerning", true),
> fontCfg.getAttributeAsBoolean("advanced", true),
> -                        fontCfg.getAttribute("encoding-mode",
> EncodingMode.AUTO.getName()),
> -                        fontCfg.getAttribute("embedding-mode",
> EncodingMode.AUTO.getName()));
> +                Font font = new Font(fontCfg.getAttribute("metrics-url",
> null), embed, fontCfg.getAttribute(
> +                        "embed-url-afm", null),
> fontCfg.getAttribute("embed-url-pfm", null),
> +                        fontCfg.getAttribute("sub-font", null),
> +                        fontCfg.getAttributeAsBoolean("kerning", true),
> fontCfg.getAttributeAsBoolean(
> +                                "advanced", true),
> fontCfg.getAttribute("encoding-mode",
> +                                EncodingMode.AUTO.getName()),
> fontCfg.getAttribute("embedding-mode",
> +                                EncodingMode.AUTO.getName()));
>                  instance.fonts.add(font);
>                  boolean hasTriplets = false;
>                  for (Configuration tripletCfg :
> fontCfg.getChildren("font-triplet")) {
> @@ -269,6 +271,10 @@ public final class DefaultFontConfig imp
>
>          private final String embedUri;
>
> +        private String afm;
> +
> +        private String pfm;
> +
>          private final String subFont;
>
>          private final boolean kerning;
> @@ -289,10 +295,12 @@ public final class DefaultFontConfig imp
>              return Collections.unmodifiableList(tripletList);
>          }
>
> -        private Font(String metrics, String embed, String subFont,
> boolean kerning,
> +        private Font(String metrics, String embed, String afm, String
> pfm, String subFont, boolean kerning,
>                  boolean advanced, String encodingMode, String
> embeddingMode) {
>              this.metrics = metrics;
>              this.embedUri = embed;
> +            this.afm = afm;
> +            this.pfm = pfm;
>              this.subFont = subFont;
>              this.kerning = kerning;
>              this.advanced = advanced;
> @@ -339,5 +347,13 @@ public final class DefaultFontConfig imp
>          public String getEmbeddingMode() {
>              return embeddingMode;
>          }
> +
> +        public String getAfm() {
> +            return afm;
> +        }
> +
> +        public String getPfm() {
> +            return pfm;
> +        }
>      }
>  }
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
> (original)
> +++
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
> Mon Nov 10 11:18:43 2014
> @@ -144,10 +144,16 @@ public class DefaultFontConfigurator imp
>              throws FOPException, URISyntaxException {
>          String embed = font.getEmbedURI();
>          String metrics = font.getMetrics();
> -        String subFont = font.getSubFont();
> -        URI metricsUri = metrics == null ? null :
> InternalResourceResolver.cleanURI(metrics);
> +        String afm = font.getAfm();
> +        String pfm = font.getPfm();
>          URI embedUri = InternalResourceResolver.cleanURI(embed);
> +        URI metricsUri = metrics == null ? null :
> InternalResourceResolver.cleanURI(metrics);
> +        URI afmUri = (afm == null) ? null :
> InternalResourceResolver.cleanURI(afm);
> +        URI pfmUri = (pfm == null) ? null :
> InternalResourceResolver.cleanURI(pfm);
> +        FontUris fontUris = (afmUri != null || pfmUri != null) ? new
> FontUris(embedUri, metricsUri, afmUri,
> +                pfmUri) : new FontUris(embedUri, metricsUri);
>
> +        String subFont = font.getSubFont();
>          List<FontTriplet> tripletList = font.getTripletList();
>
>          // no font triplet info
> @@ -160,8 +166,8 @@ public class DefaultFontConfigurator imp
>          }
>          EncodingMode encodingMode =
> EncodingMode.getValue(font.getEncodingMode());
>          EmbeddingMode embeddingMode =
> EmbeddingMode.getValue(font.getEmbeddingMode());
> -        EmbedFontInfo embedFontInfo = new EmbedFontInfo(metricsUri,
> font.isKerning(),
> -                font.isAdvanced(), tripletList, embedUri, subFont,
> encodingMode, embeddingMode);
> +        EmbedFontInfo embedFontInfo = new EmbedFontInfo(fontUris,
> font.isKerning(), font.isAdvanced(),
> +                tripletList, subFont, encodingMode, embeddingMode);
>          if (fontCache != null) {
>              if (!fontCache.containsFont(embedFontInfo)) {
>                  fontCache.addFont(embedFontInfo, resourceResolver);
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
> (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
> Mon Nov 10 11:18:43 2014
> @@ -34,8 +34,6 @@ public class EmbedFontInfo implements Se
>      /** Serialization Version UID */
>      private static final long serialVersionUID = 8755432068669997369L;
>
> -    protected final URI metricsURI;
> -    protected final URI embedURI;
>      /** false, to disable kerning */
>      protected final boolean kerning;
>      /** false, to disable advanced typographic features */
> @@ -55,6 +53,8 @@ public class EmbedFontInfo implements Se
>
>      private transient boolean embedded = true;
>
> +    private FontUris fontUris;
> +
>      /**
>       * Main constructor
>       * @param metricsURI the URI of the XML resource containing font
> metrics
> @@ -65,26 +65,42 @@ public class EmbedFontInfo implements Se
>       * @param subFontName the sub-fontname used for TrueType Collections
> (null otherwise)
>       * @param encodingMode the encoding mode to use for this font
>       */
> -    public EmbedFontInfo(URI metricsURI, boolean kerning, boolean
> advanced,
> -            List<FontTriplet> fontTriplets, URI embedURI, String
> subFontName,
> +    public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean
> advanced,
> +            List<FontTriplet> fontTriplets, String subFontName,
>              EncodingMode encodingMode, EmbeddingMode embeddingMode) {
> -        this.metricsURI = metricsURI;
> -        this.embedURI = embedURI;
>          this.kerning = kerning;
>          this.advanced = advanced;
>          this.fontTriplets = fontTriplets;
>          this.subFontName = subFontName;
>          this.encodingMode = encodingMode;
>          this.embeddingMode = embeddingMode;
> +        this.fontUris = fontUris;
> +    }
> +
> +    /**
> +<<<<<<< HEAD
> +=======
> +     * Main constructor
> +     * @param metricsURI the URI of the XML resource containing font
> metrics
> +     * @param kerning True if kerning should be enabled
> +     * @param fontTriplets List of font triplets to associate with this
> font
> +     * @param embedURI Path to the embeddable font file (may be null)
> +     * @param subFontName the sub-fontname used for TrueType Collections
> (null otherwise)
> +     */
> +    public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean
> advanced,
> +            List<FontTriplet> fontTriplets, String subFontName) {
> +        this(fontUris, kerning, advanced, fontTriplets, subFontName,
> EncodingMode.AUTO,
> +                EmbeddingMode.AUTO);
>      }
>
>      /**
> +>>>>>>> 9c3c942... added uris for afm and pfm font files
>       * Returns the URI of the metrics XML resource
>       *
>       * @return the metrics file path
>       */
>      public URI getMetricsURI() {
> -        return metricsURI;
> +        return fontUris.getMetrics();
>      }
>
>      /**
> @@ -93,7 +109,7 @@ public class EmbedFontInfo implements Se
>       * @return the font resource URI
>       */
>      public URI getEmbedURI() {
> -        return embedURI;
> +        return fontUris.getEmbed();
>      }
>
>      /**
> @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>       * @return true if the font is embedded, false if it is referenced.
>       */
>      public boolean isEmbedded() {
> -        if (embedURI == null) {
> +        if (fontUris.getEmbed() == null) {
>              return false;
>          } else {
>              return this.embedded;
> @@ -189,7 +205,7 @@ public class EmbedFontInfo implements Se
>
>      /** {@inheritDoc} */
>      public String toString() {
> -        return "metrics-uri=" + metricsURI + ", embed-uri=" + embedURI
> +        return "metrics-uri=" + fontUris.getMetrics() + ", embed-uri=" +
> fontUris.getEmbed()
>              + ", kerning=" + kerning
>              + ", advanced=" + advanced
>              + ", enc-mode=" + encodingMode
> @@ -198,4 +214,7 @@ public class EmbedFontInfo implements Se
>              + (isEmbedded() ? "" : ", NOT embedded");
>      }
>
> +    public FontUris getFontUris() {
> +        return fontUris;
> +    }
>  }
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
> (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
> Mon Nov 10 11:18:43 2014
> @@ -89,20 +89,20 @@ public abstract class FontLoader {
>       * @return the newly loaded font
>       * @throws IOException In case of an I/O error
>       */
> -    public static CustomFont loadFont(URI fontFileURI, String subFontName,
> +    public static CustomFont loadFont(FontUris fontUris, String
> subFontName,
>              boolean embedded, EmbeddingMode embeddingMode, EncodingMode
> encodingMode,
>              boolean useKerning, boolean useAdvanced,
> InternalResourceResolver resourceResolver) throws IOException {
> -        boolean type1 = isType1(fontFileURI);
> +        boolean type1 = isType1(fontUris.getEmbed());
>          FontLoader loader;
>          if (type1) {
>              if (encodingMode == EncodingMode.CID) {
>                  throw new IllegalArgumentException(
>                          "CID encoding mode not supported for Type 1
> fonts");
>              }
> -            loader = new Type1FontLoader(fontFileURI, embedded,
> embeddingMode, useKerning,
> +            loader = new Type1FontLoader(fontUris, embedded,
> embeddingMode, useKerning,
>                      resourceResolver);
>          } else {
> -            loader = new OFFontLoader(fontFileURI, subFontName, embedded,
> embeddingMode,
> +            loader = new OFFontLoader(fontUris.getEmbed(), subFontName,
> embedded, embeddingMode,
>                      encodingMode, useKerning, useAdvanced,
> resourceResolver);
>          }
>          return loader.getFont();
>
> Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java?rev=1637817&view=auto
>
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
> (added)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java Mon
> Nov 10 11:18:43 2014
> @@ -0,0 +1,65 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +/* $Id$ */
> +
> +package org.apache.fop.fonts;
> +
> +import java.io.Serializable;
> +import java.net.URI;
> +
> +public class FontUris implements Serializable {
> +
> +    private static final long serialVersionUID = 8571060588775532701L;
> +
> +    private final URI embed;
> +    private final URI metrics;
> +    private final URI afm;
> +    private final URI pfm;
> +
> +    public FontUris(URI embed, URI metrics, URI afm, URI pfm) {
> +        this.embed = embed;
> +        this.metrics = metrics;
> +        this.afm = afm;
> +        this.pfm = pfm;
> +    }
> +
> +    public FontUris(URI embed, URI metrics) {
> +        this.embed = embed;
> +        this.metrics = metrics;
> +        this.afm = null;
> +        this.pfm = null;
> +    }
> +
> +    public URI getEmbed() {
> +        return embed;
> +    }
> +
> +    public URI getMetrics() {
> +        return metrics;
> +    }
> +
> +    public URI getAfm() {
> +        return afm;
> +    }
> +
> +    public URI getPfm() {
> +        return pfm;
> +    }
> +
> +}
> +
>
> Propchange:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>
> ------------------------------------------------------------------------------
>     svn:mime-type = text/plain
>
> Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
> (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java Mon
> Nov 10 11:18:43 2014
> @@ -43,8 +43,8 @@ public class LazyFont extends Typeface i
>
>      private static Log log = LogFactory.getLog(LazyFont.class);
>
> -    private final URI metricsURI;
> -    private final URI fontEmbedURI;
> +    private final FontUris fontUris;
> +
>      private final boolean useKerning;
>      private final boolean useAdvanced;
>      private final EncodingMode encodingMode;
> @@ -64,8 +64,8 @@ public class LazyFont extends Typeface i
>       */
>      public LazyFont(EmbedFontInfo fontInfo, InternalResourceResolver
> resourceResolver,
>              boolean useComplexScripts) {
> -        this.metricsURI = fontInfo.getMetricsURI();
> -        this.fontEmbedURI = fontInfo.getEmbedURI();
> +
> +        this.fontUris = fontInfo.getFontUris();
>          this.useKerning = fontInfo.getKerning();
>          if (resourceResolver != null) {
>              this.useAdvanced = useComplexScripts;
> @@ -85,8 +85,8 @@ public class LazyFont extends Typeface i
>      public String toString() {
>          StringBuffer sbuf = new StringBuffer(super.toString());
>          sbuf.append('{');
> -        sbuf.append("metrics-url=" + metricsURI);
> -        sbuf.append(",embed-url=" + fontEmbedURI);
> +        sbuf.append("metrics-url=" + fontUris.getMetrics());
> +        sbuf.append(",embed-url=" + fontUris.getEmbed());
>          sbuf.append(",kerning=" + useKerning);
>          sbuf.append(",advanced=" + useAdvanced);
>          sbuf.append('}');
> @@ -96,36 +96,36 @@ public class LazyFont extends Typeface i
>      private void load(boolean fail) {
>          if (!isMetricsLoaded) {
>              try {
> -                if (metricsURI != null) {
> +                if (fontUris.getMetrics() != null) {
>                      /**@todo Possible thread problem here */
>                      FontReader reader = null;
> -                    InputStream in =
> resourceResolver.getResource(metricsURI);
> +                    InputStream in =
> resourceResolver.getResource(fontUris.getMetrics());
>                      InputSource src = new InputSource(in);
> -                    src.setSystemId(metricsURI.toASCIIString());
> +
> src.setSystemId(fontUris.getMetrics().toASCIIString());
>                      reader = new FontReader(src, resourceResolver);
>                      reader.setKerningEnabled(useKerning);
>                      reader.setAdvancedEnabled(useAdvanced);
>                      if (this.embedded) {
> -                        reader.setFontEmbedURI(fontEmbedURI);
> +                        reader.setFontEmbedURI(fontUris.getEmbed());
>                      }
>                      realFont = reader.getFont();
>                  } else {
> -                    if (fontEmbedURI == null) {
> +                    if (fontUris.getEmbed() == null) {
>                          throw new RuntimeException("Cannot load font. No
> font URIs available.");
>                      }
> -                    realFont = FontLoader.loadFont(fontEmbedURI,
> subFontName, embedded,
> +                    realFont = FontLoader.loadFont(fontUris, subFontName,
> embedded,
>                              embeddingMode, encodingMode, useKerning,
> useAdvanced, resourceResolver);
>                  }
>                  if (realFont instanceof FontDescriptor) {
>                      realFontDescriptor = (FontDescriptor) realFont;
>                  }
>              } catch (FOPException fopex) {
> -                log.error("Failed to read font metrics file " +
> metricsURI, fopex);
> +                log.error("Failed to read font metrics file " +
> fontUris.getMetrics(), fopex);
>                  if (fail) {
>                      throw new RuntimeException(fopex);
>                  }
>              } catch (IOException ioex) {
> -                log.error("Failed to read font metrics file " +
> metricsURI, ioex);
> +                log.error("Failed to read font metrics file " +
> fontUris.getMetrics(), ioex);
>                  if (fail) {
>                      throw new RuntimeException(ioex);
>                  }
> @@ -498,6 +498,5 @@ public class LazyFont extends Typeface i
>          }
>          return realFont.isMultiByte();
>      }
> -
>  }
>
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
> (original)
> +++
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
> Mon Nov 10 11:18:43 2014
> @@ -40,6 +40,7 @@ import org.apache.fop.fonts.FontCache;
>  import org.apache.fop.fonts.FontEventListener;
>  import org.apache.fop.fonts.FontLoader;
>  import org.apache.fop.fonts.FontTriplet;
> +import org.apache.fop.fonts.FontUris;
>  import org.apache.fop.fonts.FontUtil;
>  import org.apache.fop.fonts.MultiByteFont;
>  import org.apache.fop.fonts.truetype.FontFileReader;
> @@ -141,14 +142,15 @@ public class FontInfoFinder {
>       */
>      private EmbedFontInfo getFontInfoFromCustomFont(URI fontUri,
> CustomFont customFont,
>              FontCache fontCache, InternalResourceResolver
> resourceResolver) {
> +        FontUris fontUris = new FontUris(fontUri, null);
>          List<FontTriplet> fontTripletList = new
> java.util.ArrayList<FontTriplet>();
>          generateTripletsFromFont(customFont, fontTripletList);
>          String subFontName = null;
>          if (customFont instanceof MultiByteFont) {
>              subFontName = ((MultiByteFont) customFont).getTTCName();
>          }
> -        EmbedFontInfo fontInfo = new EmbedFontInfo(null,
> customFont.isKerningEnabled(),
> -                customFont.isAdvancedEnabled(), fontTripletList, fontUri,
> subFontName,
> +        EmbedFontInfo fontInfo = new EmbedFontInfo(fontUris,
> customFont.isKerningEnabled(),
> +                customFont.isAdvancedEnabled(), fontTripletList,
> subFontName,
>                  EncodingMode.AUTO, EmbeddingMode.AUTO);
>          fontInfo.setPostScriptName(customFont.getFontName());
>          if (fontCache != null) {
> @@ -248,8 +250,9 @@ public class FontInfoFinder {
>          } else {
>              // The normal case
>              try {
> -                customFont = FontLoader.loadFont(fontURI, null, true,
> EmbeddingMode.AUTO,
> -                        EncodingMode.AUTO, useKerning, useAdvanced,
> resourceResolver);
> +                FontUris fontUris = new FontUris(fontURI, null);
> +                customFont = FontLoader.loadFont(fontUris, null, true,
> EmbeddingMode.AUTO, EncodingMode.AUTO,
> +                        useKerning, useAdvanced, resourceResolver);
>                  if (this.eventListener != null) {
>                      customFont.setEventListener(this.eventListener);
>                  }
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
> (original)
> +++
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
> Mon Nov 10 11:18:43 2014
> @@ -22,7 +22,6 @@ package org.apache.fop.fonts.type1;
>  import java.awt.geom.RectangularShape;
>  import java.io.IOException;
>  import java.io.InputStream;
> -import java.net.URI;
>  import java.net.URISyntaxException;
>  import java.util.HashSet;
>  import java.util.List;
> @@ -37,6 +36,7 @@ import org.apache.fop.fonts.CodePointMap
>  import org.apache.fop.fonts.EmbeddingMode;
>  import org.apache.fop.fonts.FontLoader;
>  import org.apache.fop.fonts.FontType;
> +import org.apache.fop.fonts.FontUris;
>  import org.apache.fop.fonts.SingleByteEncoding;
>  import org.apache.fop.fonts.SingleByteFont;
>
> @@ -51,6 +51,8 @@ public class Type1FontLoader extends Fon
>
>      private EmbeddingMode embeddingMode;
>
> +    private final FontUris fontUris;
> +
>      /**
>       * Constructs a new Type 1 font loader.
>       * @param fontFileURI the URI to the PFB file of a Type 1 font
> @@ -59,10 +61,11 @@ public class Type1FontLoader extends Fon
>       * @param resourceResolver the font resolver used to resolve URIs
>       * @throws IOException In case of an I/O error
>       */
> -    public Type1FontLoader(URI fontFileURI, boolean embedded,
> EmbeddingMode embeddingMode,
> +    public Type1FontLoader(FontUris fontUris, boolean embedded,
> EmbeddingMode embeddingMode,
>              boolean useKerning, InternalResourceResolver
> resourceResolver) throws IOException {
> -        super(fontFileURI, embedded, useKerning, true, resourceResolver);
> +        super(fontUris.getEmbed(), embedded, useKerning, true,
> resourceResolver);
>          this.embeddingMode = embeddingMode;
> +        this.fontUris = fontUris;
>      }
>
>      private String getPFMURI(String pfbURI) {
> @@ -83,18 +86,26 @@ public class Type1FontLoader extends Fon
>          InputStream afmIn = null;
>          String fontFileStr = fontFileURI.toASCIIString();
>          String partialAfmUri = fontFileStr.substring(0,
> fontFileStr.length() - 4);
> -        String afmUri = null;
> -        for (String afmExtension : AFM_EXTENSIONS) {
> +        String afmUri = (fontUris.getAfm() != null) ?
> fontUris.getAfm().toASCIIString() : null;
> +        if (afmUri == null) {
> +            for (String afmExtension : AFM_EXTENSIONS) {
> +                try {
> +                    afmUri = partialAfmUri + afmExtension;
> +                    afmIn = resourceResolver.getResource(afmUri);
> +                    if (afmIn != null) {
> +                        break;
> +                    }
> +                } catch (IOException ioe) {
> +                    // Ignore, AFM probably not available under the URI
> +                } catch (URISyntaxException e) {
> +                    // Ignore, AFM probably not available under the URI
> +                }
> +            }
> +        } else {
>              try {
> -                afmUri = partialAfmUri + afmExtension;
>                  afmIn = resourceResolver.getResource(afmUri);
> -                if (afmIn != null) {
> -                    break;
> -                }
> -            } catch (IOException ioe) {
> -                // Ignore, AFM probably not available under the URI
>              } catch (URISyntaxException e) {
> -                // Ignore, AFM probably not available under the URI
> +                throw new IOException(e);
>              }
>          }
>          if (afmIn != null) {
> @@ -106,7 +117,8 @@ public class Type1FontLoader extends Fon
>              }
>          }
>
> -        String pfmUri = getPFMURI(fontFileStr);
> +        String pfmUri = (fontUris.getPfm() == null) ?
> getPFMURI(fontFileStr) : fontUris.getPfm()
> +                .toASCIIString();
>          InputStream pfmIn = null;
>          try {
>              pfmIn = resourceResolver.getResource(pfmUri);
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
> (original)
> +++
> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
> Mon Nov 10 11:18:43 2014
> @@ -33,6 +33,7 @@ import org.apache.fop.fonts.FontCollecti
>  import org.apache.fop.fonts.FontInfo;
>  import org.apache.fop.fonts.FontLoader;
>  import org.apache.fop.fonts.FontTriplet;
> +import org.apache.fop.fonts.FontUris;
>  import org.apache.fop.fonts.LazyFont;
>
>  /**
> @@ -81,10 +82,10 @@ public class ConfiguredFontCollection im
>                      InputStream fontSource =
> resourceResolver.getResource(fontURI);
>                      font = new CustomFontMetricsMapper(fontMetrics,
> fontSource);
>                  } else {
> -                    CustomFont fontMetrics = FontLoader.loadFont(fontURI,
> null, true,
> +                    FontUris fontUris = new FontUris(fontURI, null);
> +                    CustomFont fontMetrics =
> FontLoader.loadFont(fontUris, null, true,
>                              configFontInfo.getEmbeddingMode(),
> configFontInfo.getEncodingMode(),
> -                            configFontInfo.getKerning(),
> configFontInfo.getAdvanced(),
> -                            resourceResolver);
> +                            configFontInfo.getKerning(),
> configFontInfo.getAdvanced(), resourceResolver);
>                      font = new CustomFontMetricsMapper(fontMetrics);
>                  }
>
>
> Modified:
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
> (original)
> +++
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
> Mon Nov 10 11:18:43 2014
> @@ -47,7 +47,8 @@ public class DejaVuLGCSerifTestCase {
>      @Before
>      public void setUp() throws Exception {
>          File file = new
> File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
> -        font = FontLoader.loadFont(file.toURI(), "", true,
> EmbeddingMode.AUTO, EncodingMode.AUTO,
> +        FontUris fontUris = new FontUris(file.toURI(), null);
> +        font = FontLoader.loadFont(fontUris, "", true,
> EmbeddingMode.AUTO, EncodingMode.AUTO,
>                  false, false, resolver);
>      }
>
>
> Modified:
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
> (original)
> +++
> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
> Mon Nov 10 11:18:43 2014
> @@ -52,8 +52,8 @@ public class EmbedFontInfoTestCase {
>      public void setUp() {
>          List<FontTriplet> triplets = new ArrayList<FontTriplet>();
>          triplets.add(triplet);
> -        sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced,
> triplets, embedURI, subFontName,
> -                encMode, embedMode);
> +        FontUris fontUris = new FontUris(embedURI, metricsURI);
> +        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, triplets,
> subFontName, encMode, embedMode);
>      }
>
>      @Test
> @@ -82,8 +82,9 @@ public class EmbedFontInfoTestCase {
>
>      @Test
>      public void testQuirkyBoundaryCasesIsEmbedded() {
> -        sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced,
> sut.getFontTriplets(), null,
> -                subFontName, encMode, embedMode);
> +        FontUris fontUris = new FontUris(null, metricsURI);
> +        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced,
> sut.getFontTriplets(), subFontName, encMode,
> +                embedMode);
>          sut.setEmbedded(true);
>          assertFalse(sut.isEmbedded());
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
>
>

Re: svn commit: r1637817 - in /xmlgraphics/fop/trunk: src/foschema/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/ src/java/org/apache/fop/fonts/type1/ src/java/org/apache/fop/render/java2d/ test/java/org/apache/fop/fonts/

Posted by Glenn Adams <gl...@skynav.com>.
maybe, but that isn't good enough; i think you need to code for the case
that the cache wasn't removed, and do the cleanup if it hasn't

On Tue, Nov 11, 2014 at 4:49 PM, Luis Bernardo <lm...@gmail.com>
wrote:

>
> You need to remove the cache (the .fop directory under your home).
>
>
> On 11/11/14, 8:23 AM, Glenn Adams wrote:
>
> I fixed the problem below, but still getting other NPEs, so it looks
> pretty broken. I'm reverting your commit. I guess you didn't run junit
> before doing the commit.
>
> On Tue, Nov 11, 2014 at 2:59 PM, Glenn Adams <gl...@skynav.com> wrote:
>
>> Your commit broke the build (junit). Getting an NPE at highlight diff
>> below when fontUris is null when running
>>
>> Testsuite: org.apache.fop.BasicTranscoderTestSuite
>> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.131 sec
>> Testcase: testGenericPDFTranscoder took 1.578 sec
>>         Caused an ERROR
>> Error while setting up PDFDocumentGraphics2D
>> Enclosed Exception:
>> null
>> org.apache.batik.transcoder.TranscoderException: Error while setting up
>> PDFDocumentGraphics2D
>> Enclosed Exception:
>> null
>>      at
>> org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:137)
>> at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
>> Source)
>> at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown
>> Source)
>> at
>> org.apache.fop.AbstractBasicTranscoderTest.testGenericPDFTranscoder(AbstractBasicTranscoderTest.java:71)
>>
>>  @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>>       * @return true if the font is embedded, false if it is referenced.
>>       */
>>      public boolean isEmbedded() {
>> -        if (embedURI == null) {
>> +        if (fontUris.getEmbed() == null) {
>>              return false;
>>          } else {
>>              return this.embedded;
>>
>>
>> On Mon, Nov 10, 2014 at 6:18 PM, <lb...@apache.org> wrote:
>>
>>> Author: lbernardo
>>> Date: Mon Nov 10 11:18:43 2014
>>> New Revision: 1637817
>>>
>>> URL: http://svn.apache.org/r1637817
>>> Log:
>>> FOP-2424: Allow for type1 afm/pfm files to be in a different path than
>>> the pfb file
>>>
>>> Added:
>>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>>  (with props)
>>> Modified:
>>>     xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>>>
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>>>
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>>>
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>>>
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>>>
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>>>
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>>>
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>>>
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>>>
>>> Modified: xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> --- xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd (original)
>>> +++ xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd Mon Nov 10
>>> 11:18:43 2014
>>> @@ -283,6 +283,8 @@
>>>      </xsd:sequence>
>>>      <xsd:attribute name="metrics-url" type="xsd:anyURI" use="optional"/>
>>>      <xsd:attribute name="embed-url" type="xsd:anyURI" use="optional"/>
>>> +    <xsd:attribute name="embed-url-afm" type="xsd:anyURI"
>>> use="optional"/>
>>> +    <xsd:attribute name="embed-url-pfm" type="xsd:anyURI"
>>> use="optional"/>
>>>      <xsd:attribute name="sub-font" type="xsd:string" use="optional"/>
>>>      <xsd:attribute name="embedding-mode" use="optional">
>>>        <xsd:simpleType>
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -108,11 +108,13 @@ public final class DefaultFontConfig imp
>>>                              strict);
>>>                      continue;
>>>                  }
>>> -                Font font = new
>>> Font(fontCfg.getAttribute("metrics-url", null), embed,
>>> -                        fontCfg.getAttribute("sub-font", null),
>>> fontCfg.getAttributeAsBoolean(
>>> -                                "kerning", true),
>>> fontCfg.getAttributeAsBoolean("advanced", true),
>>> -                        fontCfg.getAttribute("encoding-mode",
>>> EncodingMode.AUTO.getName()),
>>> -                        fontCfg.getAttribute("embedding-mode",
>>> EncodingMode.AUTO.getName()));
>>> +                Font font = new
>>> Font(fontCfg.getAttribute("metrics-url", null), embed, fontCfg.getAttribute(
>>> +                        "embed-url-afm", null),
>>> fontCfg.getAttribute("embed-url-pfm", null),
>>> +                        fontCfg.getAttribute("sub-font", null),
>>> +                        fontCfg.getAttributeAsBoolean("kerning", true),
>>> fontCfg.getAttributeAsBoolean(
>>> +                                "advanced", true),
>>> fontCfg.getAttribute("encoding-mode",
>>> +                                EncodingMode.AUTO.getName()),
>>> fontCfg.getAttribute("embedding-mode",
>>> +                                EncodingMode.AUTO.getName()));
>>>                  instance.fonts.add(font);
>>>                  boolean hasTriplets = false;
>>>                  for (Configuration tripletCfg :
>>> fontCfg.getChildren("font-triplet")) {
>>> @@ -269,6 +271,10 @@ public final class DefaultFontConfig imp
>>>
>>>          private final String embedUri;
>>>
>>> +        private String afm;
>>> +
>>> +        private String pfm;
>>> +
>>>          private final String subFont;
>>>
>>>          private final boolean kerning;
>>> @@ -289,10 +295,12 @@ public final class DefaultFontConfig imp
>>>              return Collections.unmodifiableList(tripletList);
>>>          }
>>>
>>> -        private Font(String metrics, String embed, String subFont,
>>> boolean kerning,
>>> +        private Font(String metrics, String embed, String afm, String
>>> pfm, String subFont, boolean kerning,
>>>                  boolean advanced, String encodingMode, String
>>> embeddingMode) {
>>>              this.metrics = metrics;
>>>              this.embedUri = embed;
>>> +            this.afm = afm;
>>> +            this.pfm = pfm;
>>>              this.subFont = subFont;
>>>              this.kerning = kerning;
>>>              this.advanced = advanced;
>>> @@ -339,5 +347,13 @@ public final class DefaultFontConfig imp
>>>          public String getEmbeddingMode() {
>>>              return embeddingMode;
>>>          }
>>> +
>>> +        public String getAfm() {
>>> +            return afm;
>>> +        }
>>> +
>>> +        public String getPfm() {
>>> +            return pfm;
>>> +        }
>>>      }
>>>  }
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -144,10 +144,16 @@ public class DefaultFontConfigurator imp
>>>              throws FOPException, URISyntaxException {
>>>          String embed = font.getEmbedURI();
>>>          String metrics = font.getMetrics();
>>> -        String subFont = font.getSubFont();
>>> -        URI metricsUri = metrics == null ? null :
>>> InternalResourceResolver.cleanURI(metrics);
>>> +        String afm = font.getAfm();
>>> +        String pfm = font.getPfm();
>>>          URI embedUri = InternalResourceResolver.cleanURI(embed);
>>> +        URI metricsUri = metrics == null ? null :
>>> InternalResourceResolver.cleanURI(metrics);
>>> +        URI afmUri = (afm == null) ? null :
>>> InternalResourceResolver.cleanURI(afm);
>>> +        URI pfmUri = (pfm == null) ? null :
>>> InternalResourceResolver.cleanURI(pfm);
>>> +        FontUris fontUris = (afmUri != null || pfmUri != null) ? new
>>> FontUris(embedUri, metricsUri, afmUri,
>>> +                pfmUri) : new FontUris(embedUri, metricsUri);
>>>
>>> +        String subFont = font.getSubFont();
>>>          List<FontTriplet> tripletList = font.getTripletList();
>>>
>>>          // no font triplet info
>>> @@ -160,8 +166,8 @@ public class DefaultFontConfigurator imp
>>>          }
>>>          EncodingMode encodingMode =
>>> EncodingMode.getValue(font.getEncodingMode());
>>>          EmbeddingMode embeddingMode =
>>> EmbeddingMode.getValue(font.getEmbeddingMode());
>>> -        EmbedFontInfo embedFontInfo = new EmbedFontInfo(metricsUri,
>>> font.isKerning(),
>>> -                font.isAdvanced(), tripletList, embedUri, subFont,
>>> encodingMode, embeddingMode);
>>> +        EmbedFontInfo embedFontInfo = new EmbedFontInfo(fontUris,
>>> font.isKerning(), font.isAdvanced(),
>>> +                tripletList, subFont, encodingMode, embeddingMode);
>>>          if (fontCache != null) {
>>>              if (!fontCache.containsFont(embedFontInfo)) {
>>>                  fontCache.addFont(embedFontInfo, resourceResolver);
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java Mon
>>> Nov 10 11:18:43 2014
>>> @@ -34,8 +34,6 @@ public class EmbedFontInfo implements Se
>>>      /** Serialization Version UID */
>>>      private static final long serialVersionUID = 8755432068669997369L;
>>>
>>> -    protected final URI metricsURI;
>>> -    protected final URI embedURI;
>>>      /** false, to disable kerning */
>>>      protected final boolean kerning;
>>>      /** false, to disable advanced typographic features */
>>> @@ -55,6 +53,8 @@ public class EmbedFontInfo implements Se
>>>
>>>      private transient boolean embedded = true;
>>>
>>> +    private FontUris fontUris;
>>> +
>>>      /**
>>>       * Main constructor
>>>       * @param metricsURI the URI of the XML resource containing font
>>> metrics
>>> @@ -65,26 +65,42 @@ public class EmbedFontInfo implements Se
>>>       * @param subFontName the sub-fontname used for TrueType
>>> Collections (null otherwise)
>>>       * @param encodingMode the encoding mode to use for this font
>>>       */
>>> -    public EmbedFontInfo(URI metricsURI, boolean kerning, boolean
>>> advanced,
>>> -            List<FontTriplet> fontTriplets, URI embedURI, String
>>> subFontName,
>>> +    public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean
>>> advanced,
>>> +            List<FontTriplet> fontTriplets, String subFontName,
>>>              EncodingMode encodingMode, EmbeddingMode embeddingMode) {
>>> -        this.metricsURI = metricsURI;
>>> -        this.embedURI = embedURI;
>>>          this.kerning = kerning;
>>>          this.advanced = advanced;
>>>          this.fontTriplets = fontTriplets;
>>>          this.subFontName = subFontName;
>>>          this.encodingMode = encodingMode;
>>>          this.embeddingMode = embeddingMode;
>>> +        this.fontUris = fontUris;
>>> +    }
>>> +
>>> +    /**
>>> +<<<<<<< HEAD
>>> +=======
>>> +     * Main constructor
>>> +     * @param metricsURI the URI of the XML resource containing font
>>> metrics
>>> +     * @param kerning True if kerning should be enabled
>>> +     * @param fontTriplets List of font triplets to associate with this
>>> font
>>> +     * @param embedURI Path to the embeddable font file (may be null)
>>> +     * @param subFontName the sub-fontname used for TrueType
>>> Collections (null otherwise)
>>> +     */
>>> +    public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean
>>> advanced,
>>> +            List<FontTriplet> fontTriplets, String subFontName) {
>>> +        this(fontUris, kerning, advanced, fontTriplets, subFontName,
>>> EncodingMode.AUTO,
>>> +                EmbeddingMode.AUTO);
>>>      }
>>>
>>>      /**
>>> +>>>>>>> 9c3c942... added uris for afm and pfm font files
>>>       * Returns the URI of the metrics XML resource
>>>       *
>>>       * @return the metrics file path
>>>       */
>>>      public URI getMetricsURI() {
>>> -        return metricsURI;
>>> +        return fontUris.getMetrics();
>>>      }
>>>
>>>      /**
>>> @@ -93,7 +109,7 @@ public class EmbedFontInfo implements Se
>>>       * @return the font resource URI
>>>       */
>>>      public URI getEmbedURI() {
>>> -        return embedURI;
>>> +        return fontUris.getEmbed();
>>>      }
>>>
>>>      /**
>>> @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>>>       * @return true if the font is embedded, false if it is referenced.
>>>       */
>>>      public boolean isEmbedded() {
>>> -        if (embedURI == null) {
>>> +        if (fontUris.getEmbed() == null) {
>>>              return false;
>>>          } else {
>>>              return this.embedded;
>>> @@ -189,7 +205,7 @@ public class EmbedFontInfo implements Se
>>>
>>>      /** {@inheritDoc} */
>>>      public String toString() {
>>> -        return "metrics-uri=" + metricsURI + ", embed-uri=" + embedURI
>>> +        return "metrics-uri=" + fontUris.getMetrics() + ", embed-uri="
>>> + fontUris.getEmbed()
>>>              + ", kerning=" + kerning
>>>              + ", advanced=" + advanced
>>>              + ", enc-mode=" + encodingMode
>>> @@ -198,4 +214,7 @@ public class EmbedFontInfo implements Se
>>>              + (isEmbedded() ? "" : ", NOT embedded");
>>>      }
>>>
>>> +    public FontUris getFontUris() {
>>> +        return fontUris;
>>> +    }
>>>  }
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>>> (original)
>>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -89,20 +89,20 @@ public abstract class FontLoader {
>>>       * @return the newly loaded font
>>>       * @throws IOException In case of an I/O error
>>>       */
>>> -    public static CustomFont loadFont(URI fontFileURI, String
>>> subFontName,
>>> +    public static CustomFont loadFont(FontUris fontUris, String
>>> subFontName,
>>>              boolean embedded, EmbeddingMode embeddingMode, EncodingMode
>>> encodingMode,
>>>              boolean useKerning, boolean useAdvanced,
>>> InternalResourceResolver resourceResolver) throws IOException {
>>> -        boolean type1 = isType1(fontFileURI);
>>> +        boolean type1 = isType1(fontUris.getEmbed());
>>>          FontLoader loader;
>>>          if (type1) {
>>>              if (encodingMode == EncodingMode.CID) {
>>>                  throw new IllegalArgumentException(
>>>                          "CID encoding mode not supported for Type 1
>>> fonts");
>>>              }
>>> -            loader = new Type1FontLoader(fontFileURI, embedded,
>>> embeddingMode, useKerning,
>>> +            loader = new Type1FontLoader(fontUris, embedded,
>>> embeddingMode, useKerning,
>>>                      resourceResolver);
>>>          } else {
>>> -            loader = new OFFontLoader(fontFileURI, subFontName,
>>> embedded, embeddingMode,
>>> +            loader = new OFFontLoader(fontUris.getEmbed(), subFontName,
>>> embedded, embeddingMode,
>>>                      encodingMode, useKerning, useAdvanced,
>>> resourceResolver);
>>>          }
>>>          return loader.getFont();
>>>
>>> Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java?rev=1637817&view=auto
>>>
>>> ==============================================================================
>>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>> (added)
>>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -0,0 +1,65 @@
>>> +/*
>>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>>> + * contributor license agreements.  See the NOTICE file distributed with
>>> + * this work for additional information regarding copyright ownership.
>>> + * The ASF licenses this file to You under the Apache License, Version
>>> 2.0
>>> + * (the "License"); you may not use this file except in compliance with
>>> + * the License.  You may obtain a copy of the License at
>>> + *
>>> + *      http://www.apache.org/licenses/LICENSE-2.0
>>> + *
>>> + * Unless required by applicable law or agreed to in writing, software
>>> + * distributed under the License is distributed on an "AS IS" BASIS,
>>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> + * See the License for the specific language governing permissions and
>>> + * limitations under the License.
>>> + */
>>> +
>>> +/* $Id$ */
>>> +
>>> +package org.apache.fop.fonts;
>>> +
>>> +import java.io.Serializable;
>>> +import java.net.URI;
>>> +
>>> +public class FontUris implements Serializable {
>>> +
>>> +    private static final long serialVersionUID = 8571060588775532701L;
>>> +
>>> +    private final URI embed;
>>> +    private final URI metrics;
>>> +    private final URI afm;
>>> +    private final URI pfm;
>>> +
>>> +    public FontUris(URI embed, URI metrics, URI afm, URI pfm) {
>>> +        this.embed = embed;
>>> +        this.metrics = metrics;
>>> +        this.afm = afm;
>>> +        this.pfm = pfm;
>>> +    }
>>> +
>>> +    public FontUris(URI embed, URI metrics) {
>>> +        this.embed = embed;
>>> +        this.metrics = metrics;
>>> +        this.afm = null;
>>> +        this.pfm = null;
>>> +    }
>>> +
>>> +    public URI getEmbed() {
>>> +        return embed;
>>> +    }
>>> +
>>> +    public URI getMetrics() {
>>> +        return metrics;
>>> +    }
>>> +
>>> +    public URI getAfm() {
>>> +        return afm;
>>> +    }
>>> +
>>> +    public URI getPfm() {
>>> +        return pfm;
>>> +    }
>>> +
>>> +}
>>> +
>>>
>>> Propchange:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>>
>>> ------------------------------------------------------------------------------
>>>     svn:mime-type = text/plain
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>>> (original)
>>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -43,8 +43,8 @@ public class LazyFont extends Typeface i
>>>
>>>      private static Log log = LogFactory.getLog(LazyFont.class);
>>>
>>> -    private final URI metricsURI;
>>> -    private final URI fontEmbedURI;
>>> +    private final FontUris fontUris;
>>> +
>>>      private final boolean useKerning;
>>>      private final boolean useAdvanced;
>>>      private final EncodingMode encodingMode;
>>> @@ -64,8 +64,8 @@ public class LazyFont extends Typeface i
>>>       */
>>>      public LazyFont(EmbedFontInfo fontInfo, InternalResourceResolver
>>> resourceResolver,
>>>              boolean useComplexScripts) {
>>> -        this.metricsURI = fontInfo.getMetricsURI();
>>> -        this.fontEmbedURI = fontInfo.getEmbedURI();
>>> +
>>> +        this.fontUris = fontInfo.getFontUris();
>>>          this.useKerning = fontInfo.getKerning();
>>>          if (resourceResolver != null) {
>>>              this.useAdvanced = useComplexScripts;
>>> @@ -85,8 +85,8 @@ public class LazyFont extends Typeface i
>>>      public String toString() {
>>>          StringBuffer sbuf = new StringBuffer(super.toString());
>>>          sbuf.append('{');
>>> -        sbuf.append("metrics-url=" + metricsURI);
>>> -        sbuf.append(",embed-url=" + fontEmbedURI);
>>> +        sbuf.append("metrics-url=" + fontUris.getMetrics());
>>> +        sbuf.append(",embed-url=" + fontUris.getEmbed());
>>>          sbuf.append(",kerning=" + useKerning);
>>>          sbuf.append(",advanced=" + useAdvanced);
>>>          sbuf.append('}');
>>> @@ -96,36 +96,36 @@ public class LazyFont extends Typeface i
>>>      private void load(boolean fail) {
>>>          if (!isMetricsLoaded) {
>>>              try {
>>> -                if (metricsURI != null) {
>>> +                if (fontUris.getMetrics() != null) {
>>>                      /**@todo Possible thread problem here */
>>>                      FontReader reader = null;
>>> -                    InputStream in =
>>> resourceResolver.getResource(metricsURI);
>>> +                    InputStream in =
>>> resourceResolver.getResource(fontUris.getMetrics());
>>>                      InputSource src = new InputSource(in);
>>> -                    src.setSystemId(metricsURI.toASCIIString());
>>> +
>>> src.setSystemId(fontUris.getMetrics().toASCIIString());
>>>                      reader = new FontReader(src, resourceResolver);
>>>                      reader.setKerningEnabled(useKerning);
>>>                      reader.setAdvancedEnabled(useAdvanced);
>>>                      if (this.embedded) {
>>> -                        reader.setFontEmbedURI(fontEmbedURI);
>>> +                        reader.setFontEmbedURI(fontUris.getEmbed());
>>>                      }
>>>                      realFont = reader.getFont();
>>>                  } else {
>>> -                    if (fontEmbedURI == null) {
>>> +                    if (fontUris.getEmbed() == null) {
>>>                          throw new RuntimeException("Cannot load font.
>>> No font URIs available.");
>>>                      }
>>> -                    realFont = FontLoader.loadFont(fontEmbedURI,
>>> subFontName, embedded,
>>> +                    realFont = FontLoader.loadFont(fontUris,
>>> subFontName, embedded,
>>>                              embeddingMode, encodingMode, useKerning,
>>> useAdvanced, resourceResolver);
>>>                  }
>>>                  if (realFont instanceof FontDescriptor) {
>>>                      realFontDescriptor = (FontDescriptor) realFont;
>>>                  }
>>>              } catch (FOPException fopex) {
>>> -                log.error("Failed to read font metrics file " +
>>> metricsURI, fopex);
>>> +                log.error("Failed to read font metrics file " +
>>> fontUris.getMetrics(), fopex);
>>>                  if (fail) {
>>>                      throw new RuntimeException(fopex);
>>>                  }
>>>              } catch (IOException ioex) {
>>> -                log.error("Failed to read font metrics file " +
>>> metricsURI, ioex);
>>> +                log.error("Failed to read font metrics file " +
>>> fontUris.getMetrics(), ioex);
>>>                  if (fail) {
>>>                      throw new RuntimeException(ioex);
>>>                  }
>>> @@ -498,6 +498,5 @@ public class LazyFont extends Typeface i
>>>          }
>>>          return realFont.isMultiByte();
>>>      }
>>> -
>>>  }
>>>
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -40,6 +40,7 @@ import org.apache.fop.fonts.FontCache;
>>>  import org.apache.fop.fonts.FontEventListener;
>>>  import org.apache.fop.fonts.FontLoader;
>>>  import org.apache.fop.fonts.FontTriplet;
>>> +import org.apache.fop.fonts.FontUris;
>>>  import org.apache.fop.fonts.FontUtil;
>>>  import org.apache.fop.fonts.MultiByteFont;
>>>  import org.apache.fop.fonts.truetype.FontFileReader;
>>> @@ -141,14 +142,15 @@ public class FontInfoFinder {
>>>       */
>>>      private EmbedFontInfo getFontInfoFromCustomFont(URI fontUri,
>>> CustomFont customFont,
>>>              FontCache fontCache, InternalResourceResolver
>>> resourceResolver) {
>>> +        FontUris fontUris = new FontUris(fontUri, null);
>>>          List<FontTriplet> fontTripletList = new
>>> java.util.ArrayList<FontTriplet>();
>>>          generateTripletsFromFont(customFont, fontTripletList);
>>>          String subFontName = null;
>>>          if (customFont instanceof MultiByteFont) {
>>>              subFontName = ((MultiByteFont) customFont).getTTCName();
>>>          }
>>> -        EmbedFontInfo fontInfo = new EmbedFontInfo(null,
>>> customFont.isKerningEnabled(),
>>> -                customFont.isAdvancedEnabled(), fontTripletList,
>>> fontUri, subFontName,
>>> +        EmbedFontInfo fontInfo = new EmbedFontInfo(fontUris,
>>> customFont.isKerningEnabled(),
>>> +                customFont.isAdvancedEnabled(), fontTripletList,
>>> subFontName,
>>>                  EncodingMode.AUTO, EmbeddingMode.AUTO);
>>>          fontInfo.setPostScriptName(customFont.getFontName());
>>>          if (fontCache != null) {
>>> @@ -248,8 +250,9 @@ public class FontInfoFinder {
>>>          } else {
>>>              // The normal case
>>>              try {
>>> -                customFont = FontLoader.loadFont(fontURI, null, true,
>>> EmbeddingMode.AUTO,
>>> -                        EncodingMode.AUTO, useKerning, useAdvanced,
>>> resourceResolver);
>>> +                FontUris fontUris = new FontUris(fontURI, null);
>>> +                customFont = FontLoader.loadFont(fontUris, null, true,
>>> EmbeddingMode.AUTO, EncodingMode.AUTO,
>>> +                        useKerning, useAdvanced, resourceResolver);
>>>                  if (this.eventListener != null) {
>>>                      customFont.setEventListener(this.eventListener);
>>>                  }
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -22,7 +22,6 @@ package org.apache.fop.fonts.type1;
>>>  import java.awt.geom.RectangularShape;
>>>  import java.io.IOException;
>>>  import java.io.InputStream;
>>> -import java.net.URI;
>>>  import java.net.URISyntaxException;
>>>  import java.util.HashSet;
>>>  import java.util.List;
>>> @@ -37,6 +36,7 @@ import org.apache.fop.fonts.CodePointMap
>>>  import org.apache.fop.fonts.EmbeddingMode;
>>>  import org.apache.fop.fonts.FontLoader;
>>>  import org.apache.fop.fonts.FontType;
>>> +import org.apache.fop.fonts.FontUris;
>>>  import org.apache.fop.fonts.SingleByteEncoding;
>>>  import org.apache.fop.fonts.SingleByteFont;
>>>
>>> @@ -51,6 +51,8 @@ public class Type1FontLoader extends Fon
>>>
>>>      private EmbeddingMode embeddingMode;
>>>
>>> +    private final FontUris fontUris;
>>> +
>>>      /**
>>>       * Constructs a new Type 1 font loader.
>>>       * @param fontFileURI the URI to the PFB file of a Type 1 font
>>> @@ -59,10 +61,11 @@ public class Type1FontLoader extends Fon
>>>       * @param resourceResolver the font resolver used to resolve URIs
>>>       * @throws IOException In case of an I/O error
>>>       */
>>> -    public Type1FontLoader(URI fontFileURI, boolean embedded,
>>> EmbeddingMode embeddingMode,
>>> +    public Type1FontLoader(FontUris fontUris, boolean embedded,
>>> EmbeddingMode embeddingMode,
>>>              boolean useKerning, InternalResourceResolver
>>> resourceResolver) throws IOException {
>>> -        super(fontFileURI, embedded, useKerning, true,
>>> resourceResolver);
>>> +        super(fontUris.getEmbed(), embedded, useKerning, true,
>>> resourceResolver);
>>>          this.embeddingMode = embeddingMode;
>>> +        this.fontUris = fontUris;
>>>      }
>>>
>>>      private String getPFMURI(String pfbURI) {
>>> @@ -83,18 +86,26 @@ public class Type1FontLoader extends Fon
>>>          InputStream afmIn = null;
>>>          String fontFileStr = fontFileURI.toASCIIString();
>>>          String partialAfmUri = fontFileStr.substring(0,
>>> fontFileStr.length() - 4);
>>> -        String afmUri = null;
>>> -        for (String afmExtension : AFM_EXTENSIONS) {
>>> +        String afmUri = (fontUris.getAfm() != null) ?
>>> fontUris.getAfm().toASCIIString() : null;
>>> +        if (afmUri == null) {
>>> +            for (String afmExtension : AFM_EXTENSIONS) {
>>> +                try {
>>> +                    afmUri = partialAfmUri + afmExtension;
>>> +                    afmIn = resourceResolver.getResource(afmUri);
>>> +                    if (afmIn != null) {
>>> +                        break;
>>> +                    }
>>> +                } catch (IOException ioe) {
>>> +                    // Ignore, AFM probably not available under the URI
>>> +                } catch (URISyntaxException e) {
>>> +                    // Ignore, AFM probably not available under the URI
>>> +                }
>>> +            }
>>> +        } else {
>>>              try {
>>> -                afmUri = partialAfmUri + afmExtension;
>>>                  afmIn = resourceResolver.getResource(afmUri);
>>> -                if (afmIn != null) {
>>> -                    break;
>>> -                }
>>> -            } catch (IOException ioe) {
>>> -                // Ignore, AFM probably not available under the URI
>>>              } catch (URISyntaxException e) {
>>> -                // Ignore, AFM probably not available under the URI
>>> +                throw new IOException(e);
>>>              }
>>>          }
>>>          if (afmIn != null) {
>>> @@ -106,7 +117,8 @@ public class Type1FontLoader extends Fon
>>>              }
>>>          }
>>>
>>> -        String pfmUri = getPFMURI(fontFileStr);
>>> +        String pfmUri = (fontUris.getPfm() == null) ?
>>> getPFMURI(fontFileStr) : fontUris.getPfm()
>>> +                .toASCIIString();
>>>          InputStream pfmIn = null;
>>>          try {
>>>              pfmIn = resourceResolver.getResource(pfmUri);
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -33,6 +33,7 @@ import org.apache.fop.fonts.FontCollecti
>>>  import org.apache.fop.fonts.FontInfo;
>>>  import org.apache.fop.fonts.FontLoader;
>>>  import org.apache.fop.fonts.FontTriplet;
>>> +import org.apache.fop.fonts.FontUris;
>>>  import org.apache.fop.fonts.LazyFont;
>>>
>>>  /**
>>> @@ -81,10 +82,10 @@ public class ConfiguredFontCollection im
>>>                      InputStream fontSource =
>>> resourceResolver.getResource(fontURI);
>>>                      font = new CustomFontMetricsMapper(fontMetrics,
>>> fontSource);
>>>                  } else {
>>> -                    CustomFont fontMetrics =
>>> FontLoader.loadFont(fontURI, null, true,
>>> +                    FontUris fontUris = new FontUris(fontURI, null);
>>> +                    CustomFont fontMetrics =
>>> FontLoader.loadFont(fontUris, null, true,
>>>                              configFontInfo.getEmbeddingMode(),
>>> configFontInfo.getEncodingMode(),
>>> -                            configFontInfo.getKerning(),
>>> configFontInfo.getAdvanced(),
>>> -                            resourceResolver);
>>> +                            configFontInfo.getKerning(),
>>> configFontInfo.getAdvanced(), resourceResolver);
>>>                      font = new CustomFontMetricsMapper(fontMetrics);
>>>                  }
>>>
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -47,7 +47,8 @@ public class DejaVuLGCSerifTestCase {
>>>      @Before
>>>      public void setUp() throws Exception {
>>>          File file = new
>>> File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
>>> -        font = FontLoader.loadFont(file.toURI(), "", true,
>>> EmbeddingMode.AUTO, EncodingMode.AUTO,
>>> +        FontUris fontUris = new FontUris(file.toURI(), null);
>>> +        font = FontLoader.loadFont(fontUris, "", true,
>>> EmbeddingMode.AUTO, EncodingMode.AUTO,
>>>                  false, false, resolver);
>>>      }
>>>
>>>
>>> Modified:
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>>> URL:
>>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>>> (original)
>>> +++
>>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>>> Mon Nov 10 11:18:43 2014
>>> @@ -52,8 +52,8 @@ public class EmbedFontInfoTestCase {
>>>      public void setUp() {
>>>          List<FontTriplet> triplets = new ArrayList<FontTriplet>();
>>>          triplets.add(triplet);
>>> -        sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced,
>>> triplets, embedURI, subFontName,
>>> -                encMode, embedMode);
>>> +        FontUris fontUris = new FontUris(embedURI, metricsURI);
>>> +        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced,
>>> triplets, subFontName, encMode, embedMode);
>>>      }
>>>
>>>      @Test
>>> @@ -82,8 +82,9 @@ public class EmbedFontInfoTestCase {
>>>
>>>      @Test
>>>      public void testQuirkyBoundaryCasesIsEmbedded() {
>>> -        sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced,
>>> sut.getFontTriplets(), null,
>>> -                subFontName, encMode, embedMode);
>>> +        FontUris fontUris = new FontUris(null, metricsURI);
>>> +        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced,
>>> sut.getFontTriplets(), subFontName, encMode,
>>> +                embedMode);
>>>          sut.setEmbedded(true);
>>>          assertFalse(sut.isEmbedded());
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
>>> For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
>>>
>>>
>>
>
>

Re: svn commit: r1637817 - in /xmlgraphics/fop/trunk: src/foschema/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/ src/java/org/apache/fop/fonts/type1/ src/java/org/apache/fop/render/java2d/ test/java/org/apache/fop/fonts/

Posted by Luis Bernardo <lm...@gmail.com>.
You need to remove the cache (the .fop directory under your home).

On 11/11/14, 8:23 AM, Glenn Adams wrote:
> I fixed the problem below, but still getting other NPEs, so it looks 
> pretty broken. I'm reverting your commit. I guess you didn't run junit 
> before doing the commit.
>
> On Tue, Nov 11, 2014 at 2:59 PM, Glenn Adams <glenn@skynav.com 
> <ma...@skynav.com>> wrote:
>
>     Your commit broke the build (junit). Getting an NPE at highlight
>     diff below when fontUris is null when running
>
>     Testsuite: org.apache.fop.BasicTranscoderTestSuite
>     Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
>     2.131 sec
>     Testcase: testGenericPDFTranscoder took 1.578 sec
>             Caused an ERROR
>     Error while setting up PDFDocumentGraphics2D
>     Enclosed Exception:
>     null
>     org.apache.batik.transcoder.TranscoderException: Error while
>     setting up PDFDocumentGraphics2D
>     Enclosed Exception:
>     null
>     at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:137)
>     at
>     org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
>     at
>     org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
>     at
>     org.apache.fop.AbstractBasicTranscoderTest.testGenericPDFTranscoder(AbstractBasicTranscoderTest.java:71)
>
>
>     @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>         * @return true if the font is embedded, false if it is referenced.
>         */
>        public boolean isEmbedded() {
>     -       if (embedURI == null) {
>     +       if (fontUris.getEmbed() == null) {
>                return false;
>            } else {
>                return this.embedded;
>
>
>     On Mon, Nov 10, 2014 at 6:18 PM, <lbernardo@apache.org
>     <ma...@apache.org>> wrote:
>
>         Author: lbernardo
>         Date: Mon Nov 10 11:18:43 2014
>         New Revision: 1637817
>
>         URL: http://svn.apache.org/r1637817
>         Log:
>         FOP-2424: Allow for type1 afm/pfm files to be in a different
>         path than the pfb file
>
>         Added:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>          (with props)
>         Modified:
>         xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>
>         Modified: xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         --- xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>         (original)
>         +++ xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>         Mon Nov 10 11:18:43 2014
>         @@ -283,6 +283,8 @@
>              </xsd:sequence>
>              <xsd:attribute name="metrics-url" type="xsd:anyURI"
>         use="optional"/>
>              <xsd:attribute name="embed-url" type="xsd:anyURI"
>         use="optional"/>
>         +    <xsd:attribute name="embed-url-afm" type="xsd:anyURI"
>         use="optional"/>
>         +    <xsd:attribute name="embed-url-pfm" type="xsd:anyURI"
>         use="optional"/>
>              <xsd:attribute name="sub-font" type="xsd:string"
>         use="optional"/>
>              <xsd:attribute name="embedding-mode" use="optional">
>                <xsd:simpleType>
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>         Mon Nov 10 11:18:43 2014
>         @@ -108,11 +108,13 @@ public final class DefaultFontConfig imp
>                                      strict);
>                              continue;
>                          }
>         -                Font font = new
>         Font(fontCfg.getAttribute("metrics-url", null), embed,
>         - fontCfg.getAttribute("sub-font", null),
>         fontCfg.getAttributeAsBoolean(
>         -                                "kerning", true),
>         fontCfg.getAttributeAsBoolean("advanced", true),
>         - fontCfg.getAttribute("encoding-mode",
>         EncodingMode.AUTO.getName()),
>         - fontCfg.getAttribute("embedding-mode",
>         EncodingMode.AUTO.getName()));
>         +                Font font = new
>         Font(fontCfg.getAttribute("metrics-url", null), embed,
>         fontCfg.getAttribute(
>         +                        "embed-url-afm", null),
>         fontCfg.getAttribute("embed-url-pfm", null),
>         + fontCfg.getAttribute("sub-font", null),
>         + fontCfg.getAttributeAsBoolean("kerning", true),
>         fontCfg.getAttributeAsBoolean(
>         +                                "advanced", true),
>         fontCfg.getAttribute("encoding-mode",
>         + EncodingMode.AUTO.getName()),
>         fontCfg.getAttribute("embedding-mode",
>         + EncodingMode.AUTO.getName()));
>                          instance.fonts.add(font);
>                          boolean hasTriplets = false;
>                          for (Configuration tripletCfg :
>         fontCfg.getChildren("font-triplet")) {
>         @@ -269,6 +271,10 @@ public final class DefaultFontConfig imp
>
>                  private final String embedUri;
>
>         +        private String afm;
>         +
>         +        private String pfm;
>         +
>                  private final String subFont;
>
>                  private final boolean kerning;
>         @@ -289,10 +295,12 @@ public final class DefaultFontConfig imp
>                      return Collections.unmodifiableList(tripletList);
>                  }
>
>         -        private Font(String metrics, String embed, String
>         subFont, boolean kerning,
>         +        private Font(String metrics, String embed, String
>         afm, String pfm, String subFont, boolean kerning,
>                          boolean advanced, String encodingMode, String
>         embeddingMode) {
>                      this.metrics = metrics;
>                      this.embedUri = embed;
>         +            this.afm = afm;
>         +            this.pfm = pfm;
>                      this.subFont = subFont;
>                      this.kerning = kerning;
>                      this.advanced = advanced;
>         @@ -339,5 +347,13 @@ public final class DefaultFontConfig imp
>                  public String getEmbeddingMode() {
>                      return embeddingMode;
>                  }
>         +
>         +        public String getAfm() {
>         +            return afm;
>         +        }
>         +
>         +        public String getPfm() {
>         +            return pfm;
>         +        }
>              }
>          }
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>         Mon Nov 10 11:18:43 2014
>         @@ -144,10 +144,16 @@ public class DefaultFontConfigurator imp
>                      throws FOPException, URISyntaxException {
>                  String embed = font.getEmbedURI();
>                  String metrics = font.getMetrics();
>         -        String subFont = font.getSubFont();
>         -        URI metricsUri = metrics == null ? null :
>         InternalResourceResolver.cleanURI(metrics);
>         +        String afm = font.getAfm();
>         +        String pfm = font.getPfm();
>                  URI embedUri = InternalResourceResolver.cleanURI(embed);
>         +        URI metricsUri = metrics == null ? null :
>         InternalResourceResolver.cleanURI(metrics);
>         +        URI afmUri = (afm == null) ? null :
>         InternalResourceResolver.cleanURI(afm);
>         +        URI pfmUri = (pfm == null) ? null :
>         InternalResourceResolver.cleanURI(pfm);
>         +        FontUris fontUris = (afmUri != null || pfmUri !=
>         null) ? new FontUris(embedUri, metricsUri, afmUri,
>         +                pfmUri) : new FontUris(embedUri, metricsUri);
>
>         +        String subFont = font.getSubFont();
>                  List<FontTriplet> tripletList = font.getTripletList();
>
>                  // no font triplet info
>         @@ -160,8 +166,8 @@ public class DefaultFontConfigurator imp
>                  }
>                  EncodingMode encodingMode =
>         EncodingMode.getValue(font.getEncodingMode());
>                  EmbeddingMode embeddingMode =
>         EmbeddingMode.getValue(font.getEmbeddingMode());
>         -        EmbedFontInfo embedFontInfo = new
>         EmbedFontInfo(metricsUri, font.isKerning(),
>         -                font.isAdvanced(), tripletList, embedUri,
>         subFont, encodingMode, embeddingMode);
>         +        EmbedFontInfo embedFontInfo = new
>         EmbedFontInfo(fontUris, font.isKerning(), font.isAdvanced(),
>         +                tripletList, subFont, encodingMode,
>         embeddingMode);
>                  if (fontCache != null) {
>                      if (!fontCache.containsFont(embedFontInfo)) {
>                          fontCache.addFont(embedFontInfo,
>         resourceResolver);
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>         Mon Nov 10 11:18:43 2014
>         @@ -34,8 +34,6 @@ public class EmbedFontInfo implements Se
>              /** Serialization Version UID */
>              private static final long serialVersionUID =
>         8755432068669997369L;
>
>         -    protected final URI metricsURI;
>         -    protected final URI embedURI;
>              /** false, to disable kerning */
>              protected final boolean kerning;
>              /** false, to disable advanced typographic features */
>         @@ -55,6 +53,8 @@ public class EmbedFontInfo implements Se
>
>              private transient boolean embedded = true;
>
>         +    private FontUris fontUris;
>         +
>              /**
>               * Main constructor
>               * @param metricsURI the URI of the XML resource
>         containing font metrics
>         @@ -65,26 +65,42 @@ public class EmbedFontInfo implements Se
>               * @param subFontName the sub-fontname used for TrueType
>         Collections (null otherwise)
>               * @param encodingMode the encoding mode to use for this font
>               */
>         -    public EmbedFontInfo(URI metricsURI, boolean kerning,
>         boolean advanced,
>         -            List<FontTriplet> fontTriplets, URI embedURI,
>         String subFontName,
>         +    public EmbedFontInfo(FontUris fontUris, boolean kerning,
>         boolean advanced,
>         +            List<FontTriplet> fontTriplets, String subFontName,
>                      EncodingMode encodingMode, EmbeddingMode
>         embeddingMode) {
>         -        this.metricsURI = metricsURI;
>         -        this.embedURI = embedURI;
>                  this.kerning = kerning;
>                  this.advanced = advanced;
>                  this.fontTriplets = fontTriplets;
>                  this.subFontName = subFontName;
>                  this.encodingMode = encodingMode;
>                  this.embeddingMode = embeddingMode;
>         +        this.fontUris = fontUris;
>         +    }
>         +
>         +    /**
>         +<<<<<<< HEAD
>         +=======
>         +     * Main constructor
>         +     * @param metricsURI the URI of the XML resource
>         containing font metrics
>         +     * @param kerning True if kerning should be enabled
>         +     * @param fontTriplets List of font triplets to associate
>         with this font
>         +     * @param embedURI Path to the embeddable font file (may
>         be null)
>         +     * @param subFontName the sub-fontname used for TrueType
>         Collections (null otherwise)
>         +     */
>         +    public EmbedFontInfo(FontUris fontUris, boolean kerning,
>         boolean advanced,
>         +            List<FontTriplet> fontTriplets, String subFontName) {
>         +        this(fontUris, kerning, advanced, fontTriplets,
>         subFontName, EncodingMode.AUTO,
>         +                EmbeddingMode.AUTO);
>              }
>
>              /**
>         +>>>>>>> 9c3c942... added uris for afm and pfm font files
>               * Returns the URI of the metrics XML resource
>               *
>               * @return the metrics file path
>               */
>              public URI getMetricsURI() {
>         -        return metricsURI;
>         +        return fontUris.getMetrics();
>              }
>
>              /**
>         @@ -93,7 +109,7 @@ public class EmbedFontInfo implements Se
>               * @return the font resource URI
>               */
>              public URI getEmbedURI() {
>         -        return embedURI;
>         +        return fontUris.getEmbed();
>              }
>
>              /**
>         @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>               * @return true if the font is embedded, false if it is
>         referenced.
>               */
>              public boolean isEmbedded() {
>         -        if (embedURI == null) {
>         +        if (fontUris.getEmbed() == null) {
>                      return false;
>                  } else {
>                      return this.embedded;
>         @@ -189,7 +205,7 @@ public class EmbedFontInfo implements Se
>
>              /** {@inheritDoc} */
>              public String toString() {
>         -        return "metrics-uri=" + metricsURI + ", embed-uri=" +
>         embedURI
>         +        return "metrics-uri=" + fontUris.getMetrics() + ",
>         embed-uri=" + fontUris.getEmbed()
>                      + ", kerning=" + kerning
>                      + ", advanced=" + advanced
>                      + ", enc-mode=" + encodingMode
>         @@ -198,4 +214,7 @@ public class EmbedFontInfo implements Se
>                      + (isEmbedded() ? "" : ", NOT embedded");
>              }
>
>         +    public FontUris getFontUris() {
>         +        return fontUris;
>         +    }
>          }
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>         Mon Nov 10 11:18:43 2014
>         @@ -89,20 +89,20 @@ public abstract class FontLoader {
>               * @return the newly loaded font
>               * @throws IOException In case of an I/O error
>               */
>         -    public static CustomFont loadFont(URI fontFileURI, String
>         subFontName,
>         +    public static CustomFont loadFont(FontUris fontUris,
>         String subFontName,
>                      boolean embedded, EmbeddingMode embeddingMode,
>         EncodingMode encodingMode,
>                      boolean useKerning, boolean useAdvanced,
>         InternalResourceResolver resourceResolver) throws IOException {
>         -        boolean type1 = isType1(fontFileURI);
>         +        boolean type1 = isType1(fontUris.getEmbed());
>                  FontLoader loader;
>                  if (type1) {
>                      if (encodingMode == EncodingMode.CID) {
>                          throw new IllegalArgumentException(
>                                  "CID encoding mode not supported for
>         Type 1 fonts");
>                      }
>         -            loader = new Type1FontLoader(fontFileURI,
>         embedded, embeddingMode, useKerning,
>         +            loader = new Type1FontLoader(fontUris, embedded,
>         embeddingMode, useKerning,
>                              resourceResolver);
>                  } else {
>         -            loader = new OFFontLoader(fontFileURI,
>         subFontName, embedded, embeddingMode,
>         +            loader = new OFFontLoader(fontUris.getEmbed(),
>         subFontName, embedded, embeddingMode,
>                              encodingMode, useKerning, useAdvanced,
>         resourceResolver);
>                  }
>                  return loader.getFont();
>
>         Added:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java?rev=1637817&view=auto
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>         (added)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>         Mon Nov 10 11:18:43 2014
>         @@ -0,0 +1,65 @@
>         +/*
>         + * Licensed to the Apache Software Foundation (ASF) under one
>         or more
>         + * contributor license agreements.  See the NOTICE file
>         distributed with
>         + * this work for additional information regarding copyright
>         ownership.
>         + * The ASF licenses this file to You under the Apache
>         License, Version 2.0
>         + * (the "License"); you may not use this file except in
>         compliance with
>         + * the License.  You may obtain a copy of the License at
>         + *
>         + * http://www.apache.org/licenses/LICENSE-2.0
>         + *
>         + * Unless required by applicable law or agreed to in writing,
>         software
>         + * distributed under the License is distributed on an "AS IS"
>         BASIS,
>         + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
>         express or implied.
>         + * See the License for the specific language governing
>         permissions and
>         + * limitations under the License.
>         + */
>         +
>         +/* $Id$ */
>         +
>         +package org.apache.fop.fonts;
>         +
>         +import java.io.Serializable;
>         +import java.net.URI;
>         +
>         +public class FontUris implements Serializable {
>         +
>         +    private static final long serialVersionUID =
>         8571060588775532701L;
>         +
>         +    private final URI embed;
>         +    private final URI metrics;
>         +    private final URI afm;
>         +    private final URI pfm;
>         +
>         +    public FontUris(URI embed, URI metrics, URI afm, URI pfm) {
>         +        this.embed = embed;
>         +        this.metrics = metrics;
>         +        this.afm = afm;
>         +        this.pfm = pfm;
>         +    }
>         +
>         +    public FontUris(URI embed, URI metrics) {
>         +        this.embed = embed;
>         +        this.metrics = metrics;
>         +        this.afm = null;
>         +        this.pfm = null;
>         +    }
>         +
>         +    public URI getEmbed() {
>         +        return embed;
>         +    }
>         +
>         +    public URI getMetrics() {
>         +        return metrics;
>         +    }
>         +
>         +    public URI getAfm() {
>         +        return afm;
>         +    }
>         +
>         +    public URI getPfm() {
>         +        return pfm;
>         +    }
>         +
>         +}
>         +
>
>         Propchange:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>         ------------------------------------------------------------------------------
>             svn:mime-type = text/plain
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>         Mon Nov 10 11:18:43 2014
>         @@ -43,8 +43,8 @@ public class LazyFont extends Typeface i
>
>              private static Log log = LogFactory.getLog(LazyFont.class);
>
>         -    private final URI metricsURI;
>         -    private final URI fontEmbedURI;
>         +    private final FontUris fontUris;
>         +
>              private final boolean useKerning;
>              private final boolean useAdvanced;
>              private final EncodingMode encodingMode;
>         @@ -64,8 +64,8 @@ public class LazyFont extends Typeface i
>               */
>              public LazyFont(EmbedFontInfo fontInfo,
>         InternalResourceResolver resourceResolver,
>                      boolean useComplexScripts) {
>         -        this.metricsURI = fontInfo.getMetricsURI();
>         -        this.fontEmbedURI = fontInfo.getEmbedURI();
>         +
>         +        this.fontUris = fontInfo.getFontUris();
>                  this.useKerning = fontInfo.getKerning();
>                  if (resourceResolver != null) {
>                      this.useAdvanced = useComplexScripts;
>         @@ -85,8 +85,8 @@ public class LazyFont extends Typeface i
>              public String toString() {
>                  StringBuffer sbuf = new StringBuffer(super.toString());
>                  sbuf.append('{');
>         -        sbuf.append("metrics-url=" + metricsURI);
>         -        sbuf.append(",embed-url=" + fontEmbedURI);
>         +        sbuf.append("metrics-url=" + fontUris.getMetrics());
>         +        sbuf.append(",embed-url=" + fontUris.getEmbed());
>                  sbuf.append(",kerning=" + useKerning);
>                  sbuf.append(",advanced=" + useAdvanced);
>                  sbuf.append('}');
>         @@ -96,36 +96,36 @@ public class LazyFont extends Typeface i
>              private void load(boolean fail) {
>                  if (!isMetricsLoaded) {
>                      try {
>         -                if (metricsURI != null) {
>         +                if (fontUris.getMetrics() != null) {
>                              /**@todo Possible thread problem here */
>                              FontReader reader = null;
>         -                    InputStream in =
>         resourceResolver.getResource(metricsURI);
>         +                    InputStream in =
>         resourceResolver.getResource(fontUris.getMetrics());
>                              InputSource src = new InputSource(in);
>         - src.setSystemId(metricsURI.toASCIIString());
>         + src.setSystemId(fontUris.getMetrics().toASCIIString());
>                              reader = new FontReader(src,
>         resourceResolver);
>          reader.setKerningEnabled(useKerning);
>          reader.setAdvancedEnabled(useAdvanced);
>                              if (this.embedded) {
>         - reader.setFontEmbedURI(fontEmbedURI);
>         + reader.setFontEmbedURI(fontUris.getEmbed());
>                              }
>                              realFont = reader.getFont();
>                          } else {
>         -                    if (fontEmbedURI == null) {
>         +                    if (fontUris.getEmbed() == null) {
>                                  throw new RuntimeException("Cannot
>         load font. No font URIs available.");
>                              }
>         -                    realFont =
>         FontLoader.loadFont(fontEmbedURI, subFontName, embedded,
>         +                    realFont = FontLoader.loadFont(fontUris,
>         subFontName, embedded,
>                                      embeddingMode, encodingMode,
>         useKerning, useAdvanced, resourceResolver);
>                          }
>                          if (realFont instanceof FontDescriptor) {
>                              realFontDescriptor = (FontDescriptor)
>         realFont;
>                          }
>                      } catch (FOPException fopex) {
>         -                log.error("Failed to read font metrics file "
>         + metricsURI, fopex);
>         +                log.error("Failed to read font metrics file "
>         + fontUris.getMetrics(), fopex);
>                          if (fail) {
>                              throw new RuntimeException(fopex);
>                          }
>                      } catch (IOException ioex) {
>         -                log.error("Failed to read font metrics file "
>         + metricsURI, ioex);
>         +                log.error("Failed to read font metrics file "
>         + fontUris.getMetrics(), ioex);
>                          if (fail) {
>                              throw new RuntimeException(ioex);
>                          }
>         @@ -498,6 +498,5 @@ public class LazyFont extends Typeface i
>                  }
>                  return realFont.isMultiByte();
>              }
>         -
>          }
>
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>         Mon Nov 10 11:18:43 2014
>         @@ -40,6 +40,7 @@ import org.apache.fop.fonts.FontCache;
>          import org.apache.fop.fonts.FontEventListener;
>          import org.apache.fop.fonts.FontLoader;
>          import org.apache.fop.fonts.FontTriplet;
>         +import org.apache.fop.fonts.FontUris;
>          import org.apache.fop.fonts.FontUtil;
>          import org.apache.fop.fonts.MultiByteFont;
>          import org.apache.fop.fonts.truetype.FontFileReader;
>         @@ -141,14 +142,15 @@ public class FontInfoFinder {
>               */
>              private EmbedFontInfo getFontInfoFromCustomFont(URI
>         fontUri, CustomFont customFont,
>                      FontCache fontCache, InternalResourceResolver
>         resourceResolver) {
>         +        FontUris fontUris = new FontUris(fontUri, null);
>                  List<FontTriplet> fontTripletList = new
>         java.util.ArrayList<FontTriplet>();
>                  generateTripletsFromFont(customFont, fontTripletList);
>                  String subFontName = null;
>                  if (customFont instanceof MultiByteFont) {
>                      subFontName = ((MultiByteFont)
>         customFont).getTTCName();
>                  }
>         -        EmbedFontInfo fontInfo = new EmbedFontInfo(null,
>         customFont.isKerningEnabled(),
>         -                customFont.isAdvancedEnabled(),
>         fontTripletList, fontUri, subFontName,
>         +        EmbedFontInfo fontInfo = new EmbedFontInfo(fontUris,
>         customFont.isKerningEnabled(),
>         +                customFont.isAdvancedEnabled(),
>         fontTripletList, subFontName,
>                          EncodingMode.AUTO, EmbeddingMode.AUTO);
>          fontInfo.setPostScriptName(customFont.getFontName());
>                  if (fontCache != null) {
>         @@ -248,8 +250,9 @@ public class FontInfoFinder {
>                  } else {
>                      // The normal case
>                      try {
>         -                customFont = FontLoader.loadFont(fontURI,
>         null, true, EmbeddingMode.AUTO,
>         -                        EncodingMode.AUTO, useKerning,
>         useAdvanced, resourceResolver);
>         +                FontUris fontUris = new FontUris(fontURI, null);
>         +                customFont = FontLoader.loadFont(fontUris,
>         null, true, EmbeddingMode.AUTO, EncodingMode.AUTO,
>         +                        useKerning, useAdvanced,
>         resourceResolver);
>                          if (this.eventListener != null) {
>          customFont.setEventListener(this.eventListener);
>                          }
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>         Mon Nov 10 11:18:43 2014
>         @@ -22,7 +22,6 @@ package org.apache.fop.fonts.type1;
>          import java.awt.geom.RectangularShape;
>          import java.io.IOException;
>          import java.io.InputStream;
>         -import java.net.URI;
>          import java.net.URISyntaxException;
>          import java.util.HashSet;
>          import java.util.List;
>         @@ -37,6 +36,7 @@ import org.apache.fop.fonts.CodePointMap
>          import org.apache.fop.fonts.EmbeddingMode;
>          import org.apache.fop.fonts.FontLoader;
>          import org.apache.fop.fonts.FontType;
>         +import org.apache.fop.fonts.FontUris;
>          import org.apache.fop.fonts.SingleByteEncoding;
>          import org.apache.fop.fonts.SingleByteFont;
>
>         @@ -51,6 +51,8 @@ public class Type1FontLoader extends Fon
>
>              private EmbeddingMode embeddingMode;
>
>         +    private final FontUris fontUris;
>         +
>              /**
>               * Constructs a new Type 1 font loader.
>               * @param fontFileURI the URI to the PFB file of a Type 1
>         font
>         @@ -59,10 +61,11 @@ public class Type1FontLoader extends Fon
>               * @param resourceResolver the font resolver used to
>         resolve URIs
>               * @throws IOException In case of an I/O error
>               */
>         -    public Type1FontLoader(URI fontFileURI, boolean embedded,
>         EmbeddingMode embeddingMode,
>         +    public Type1FontLoader(FontUris fontUris, boolean
>         embedded, EmbeddingMode embeddingMode,
>                      boolean useKerning, InternalResourceResolver
>         resourceResolver) throws IOException {
>         -        super(fontFileURI, embedded, useKerning, true,
>         resourceResolver);
>         +        super(fontUris.getEmbed(), embedded, useKerning,
>         true, resourceResolver);
>                  this.embeddingMode = embeddingMode;
>         +        this.fontUris = fontUris;
>              }
>
>              private String getPFMURI(String pfbURI) {
>         @@ -83,18 +86,26 @@ public class Type1FontLoader extends Fon
>                  InputStream afmIn = null;
>                  String fontFileStr = fontFileURI.toASCIIString();
>                  String partialAfmUri = fontFileStr.substring(0,
>         fontFileStr.length() - 4);
>         -        String afmUri = null;
>         -        for (String afmExtension : AFM_EXTENSIONS) {
>         +        String afmUri = (fontUris.getAfm() != null) ?
>         fontUris.getAfm().toASCIIString() : null;
>         +        if (afmUri == null) {
>         +            for (String afmExtension : AFM_EXTENSIONS) {
>         +                try {
>         +                    afmUri = partialAfmUri + afmExtension;
>         +                    afmIn = resourceResolver.getResource(afmUri);
>         +                    if (afmIn != null) {
>         +                        break;
>         +                    }
>         +                } catch (IOException ioe) {
>         +                    // Ignore, AFM probably not available
>         under the URI
>         +                } catch (URISyntaxException e) {
>         +                    // Ignore, AFM probably not available
>         under the URI
>         +                }
>         +            }
>         +        } else {
>                      try {
>         -                afmUri = partialAfmUri + afmExtension;
>                          afmIn = resourceResolver.getResource(afmUri);
>         -                if (afmIn != null) {
>         -                    break;
>         -                }
>         -            } catch (IOException ioe) {
>         -                // Ignore, AFM probably not available under
>         the URI
>                      } catch (URISyntaxException e) {
>         -                // Ignore, AFM probably not available under
>         the URI
>         +                throw new IOException(e);
>                      }
>                  }
>                  if (afmIn != null) {
>         @@ -106,7 +117,8 @@ public class Type1FontLoader extends Fon
>                      }
>                  }
>
>         -        String pfmUri = getPFMURI(fontFileStr);
>         +        String pfmUri = (fontUris.getPfm() == null) ?
>         getPFMURI(fontFileStr) : fontUris.getPfm()
>         +                .toASCIIString();
>                  InputStream pfmIn = null;
>                  try {
>                      pfmIn = resourceResolver.getResource(pfmUri);
>
>         Modified:
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>         Mon Nov 10 11:18:43 2014
>         @@ -33,6 +33,7 @@ import org.apache.fop.fonts.FontCollecti
>          import org.apache.fop.fonts.FontInfo;
>          import org.apache.fop.fonts.FontLoader;
>          import org.apache.fop.fonts.FontTriplet;
>         +import org.apache.fop.fonts.FontUris;
>          import org.apache.fop.fonts.LazyFont;
>
>          /**
>         @@ -81,10 +82,10 @@ public class ConfiguredFontCollection im
>                              InputStream fontSource =
>         resourceResolver.getResource(fontURI);
>                              font = new
>         CustomFontMetricsMapper(fontMetrics, fontSource);
>                          } else {
>         -                    CustomFont fontMetrics =
>         FontLoader.loadFont(fontURI, null, true,
>         +                    FontUris fontUris = new FontUris(fontURI,
>         null);
>         +                    CustomFont fontMetrics =
>         FontLoader.loadFont(fontUris, null, true,
>          configFontInfo.getEmbeddingMode(),
>         configFontInfo.getEncodingMode(),
>         - configFontInfo.getKerning(), configFontInfo.getAdvanced(),
>         -                            resourceResolver);
>         + configFontInfo.getKerning(), configFontInfo.getAdvanced(),
>         resourceResolver);
>                              font = new
>         CustomFontMetricsMapper(fontMetrics);
>                          }
>
>
>         Modified:
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>         Mon Nov 10 11:18:43 2014
>         @@ -47,7 +47,8 @@ public class DejaVuLGCSerifTestCase {
>              @Before
>              public void setUp() throws Exception {
>                  File file = new
>         File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
>         -        font = FontLoader.loadFont(file.toURI(), "", true,
>         EmbeddingMode.AUTO, EncodingMode.AUTO,
>         +        FontUris fontUris = new FontUris(file.toURI(), null);
>         +        font = FontLoader.loadFont(fontUris, "", true,
>         EmbeddingMode.AUTO, EncodingMode.AUTO,
>                          false, false, resolver);
>              }
>
>
>         Modified:
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>         URL:
>         http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>         ==============================================================================
>         ---
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>         (original)
>         +++
>         xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>         Mon Nov 10 11:18:43 2014
>         @@ -52,8 +52,8 @@ public class EmbedFontInfoTestCase {
>              public void setUp() {
>                  List<FontTriplet> triplets = new
>         ArrayList<FontTriplet>();
>                  triplets.add(triplet);
>         -        sut = new EmbedFontInfo(metricsURI, kerning,
>         useAdvanced, triplets, embedURI, subFontName,
>         -                encMode, embedMode);
>         +        FontUris fontUris = new FontUris(embedURI, metricsURI);
>         +        sut = new EmbedFontInfo(fontUris, kerning,
>         useAdvanced, triplets, subFontName, encMode, embedMode);
>              }
>
>              @Test
>         @@ -82,8 +82,9 @@ public class EmbedFontInfoTestCase {
>
>              @Test
>              public void testQuirkyBoundaryCasesIsEmbedded() {
>         -        sut = new EmbedFontInfo(metricsURI, kerning,
>         useAdvanced, sut.getFontTriplets(), null,
>         -                subFontName, encMode, embedMode);
>         +        FontUris fontUris = new FontUris(null, metricsURI);
>         +        sut = new EmbedFontInfo(fontUris, kerning,
>         useAdvanced, sut.getFontTriplets(), subFontName, encMode,
>         +                embedMode);
>                  sut.setEmbedded(true);
>                  assertFalse(sut.isEmbedded());
>
>
>
>
>         ---------------------------------------------------------------------
>         To unsubscribe, e-mail:
>         fop-commits-unsubscribe@xmlgraphics.apache.org
>         <ma...@xmlgraphics.apache.org>
>         For additional commands, e-mail:
>         fop-commits-help@xmlgraphics.apache.org
>         <ma...@xmlgraphics.apache.org>
>
>
>


Re: svn commit: r1637817 - in /xmlgraphics/fop/trunk: src/foschema/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/ src/java/org/apache/fop/fonts/type1/ src/java/org/apache/fop/render/java2d/ test/java/org/apache/fop/fonts/

Posted by Glenn Adams <gl...@skynav.com>.
I fixed the problem below, but still getting other NPEs, so it looks pretty
broken. I'm reverting your commit. I guess you didn't run junit before
doing the commit.

On Tue, Nov 11, 2014 at 2:59 PM, Glenn Adams <gl...@skynav.com> wrote:

> Your commit broke the build (junit). Getting an NPE at highlight diff
> below when fontUris is null when running
>
> Testsuite: org.apache.fop.BasicTranscoderTestSuite
> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.131 sec
> Testcase: testGenericPDFTranscoder took 1.578 sec
>         Caused an ERROR
> Error while setting up PDFDocumentGraphics2D
> Enclosed Exception:
> null
> org.apache.batik.transcoder.TranscoderException: Error while setting up
> PDFDocumentGraphics2D
> Enclosed Exception:
> null
>      at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:137)
> at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
> Source)
> at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown
> Source)
> at
> org.apache.fop.AbstractBasicTranscoderTest.testGenericPDFTranscoder(AbstractBasicTranscoderTest.java:71)
>
> @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>       * @return true if the font is embedded, false if it is referenced.
>       */
>      public boolean isEmbedded() {
> -        if (embedURI == null) {
> +        if (fontUris.getEmbed() == null) {
>              return false;
>          } else {
>              return this.embedded;
>
>
> On Mon, Nov 10, 2014 at 6:18 PM, <lb...@apache.org> wrote:
>
>> Author: lbernardo
>> Date: Mon Nov 10 11:18:43 2014
>> New Revision: 1637817
>>
>> URL: http://svn.apache.org/r1637817
>> Log:
>> FOP-2424: Allow for type1 afm/pfm files to be in a different path than
>> the pfb file
>>
>> Added:
>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>  (with props)
>> Modified:
>>     xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>>
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>>
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>>
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>>
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>>
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>>
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>>
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>>
>> Modified: xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd (original)
>> +++ xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd Mon Nov 10
>> 11:18:43 2014
>> @@ -283,6 +283,8 @@
>>      </xsd:sequence>
>>      <xsd:attribute name="metrics-url" type="xsd:anyURI" use="optional"/>
>>      <xsd:attribute name="embed-url" type="xsd:anyURI" use="optional"/>
>> +    <xsd:attribute name="embed-url-afm" type="xsd:anyURI"
>> use="optional"/>
>> +    <xsd:attribute name="embed-url-pfm" type="xsd:anyURI"
>> use="optional"/>
>>      <xsd:attribute name="sub-font" type="xsd:string" use="optional"/>
>>      <xsd:attribute name="embedding-mode" use="optional">
>>        <xsd:simpleType>
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfig.java
>> Mon Nov 10 11:18:43 2014
>> @@ -108,11 +108,13 @@ public final class DefaultFontConfig imp
>>                              strict);
>>                      continue;
>>                  }
>> -                Font font = new Font(fontCfg.getAttribute("metrics-url",
>> null), embed,
>> -                        fontCfg.getAttribute("sub-font", null),
>> fontCfg.getAttributeAsBoolean(
>> -                                "kerning", true),
>> fontCfg.getAttributeAsBoolean("advanced", true),
>> -                        fontCfg.getAttribute("encoding-mode",
>> EncodingMode.AUTO.getName()),
>> -                        fontCfg.getAttribute("embedding-mode",
>> EncodingMode.AUTO.getName()));
>> +                Font font = new Font(fontCfg.getAttribute("metrics-url",
>> null), embed, fontCfg.getAttribute(
>> +                        "embed-url-afm", null),
>> fontCfg.getAttribute("embed-url-pfm", null),
>> +                        fontCfg.getAttribute("sub-font", null),
>> +                        fontCfg.getAttributeAsBoolean("kerning", true),
>> fontCfg.getAttributeAsBoolean(
>> +                                "advanced", true),
>> fontCfg.getAttribute("encoding-mode",
>> +                                EncodingMode.AUTO.getName()),
>> fontCfg.getAttribute("embedding-mode",
>> +                                EncodingMode.AUTO.getName()));
>>                  instance.fonts.add(font);
>>                  boolean hasTriplets = false;
>>                  for (Configuration tripletCfg :
>> fontCfg.getChildren("font-triplet")) {
>> @@ -269,6 +271,10 @@ public final class DefaultFontConfig imp
>>
>>          private final String embedUri;
>>
>> +        private String afm;
>> +
>> +        private String pfm;
>> +
>>          private final String subFont;
>>
>>          private final boolean kerning;
>> @@ -289,10 +295,12 @@ public final class DefaultFontConfig imp
>>              return Collections.unmodifiableList(tripletList);
>>          }
>>
>> -        private Font(String metrics, String embed, String subFont,
>> boolean kerning,
>> +        private Font(String metrics, String embed, String afm, String
>> pfm, String subFont, boolean kerning,
>>                  boolean advanced, String encodingMode, String
>> embeddingMode) {
>>              this.metrics = metrics;
>>              this.embedUri = embed;
>> +            this.afm = afm;
>> +            this.pfm = pfm;
>>              this.subFont = subFont;
>>              this.kerning = kerning;
>>              this.advanced = advanced;
>> @@ -339,5 +347,13 @@ public final class DefaultFontConfig imp
>>          public String getEmbeddingMode() {
>>              return embeddingMode;
>>          }
>> +
>> +        public String getAfm() {
>> +            return afm;
>> +        }
>> +
>> +        public String getPfm() {
>> +            return pfm;
>> +        }
>>      }
>>  }
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java
>> Mon Nov 10 11:18:43 2014
>> @@ -144,10 +144,16 @@ public class DefaultFontConfigurator imp
>>              throws FOPException, URISyntaxException {
>>          String embed = font.getEmbedURI();
>>          String metrics = font.getMetrics();
>> -        String subFont = font.getSubFont();
>> -        URI metricsUri = metrics == null ? null :
>> InternalResourceResolver.cleanURI(metrics);
>> +        String afm = font.getAfm();
>> +        String pfm = font.getPfm();
>>          URI embedUri = InternalResourceResolver.cleanURI(embed);
>> +        URI metricsUri = metrics == null ? null :
>> InternalResourceResolver.cleanURI(metrics);
>> +        URI afmUri = (afm == null) ? null :
>> InternalResourceResolver.cleanURI(afm);
>> +        URI pfmUri = (pfm == null) ? null :
>> InternalResourceResolver.cleanURI(pfm);
>> +        FontUris fontUris = (afmUri != null || pfmUri != null) ? new
>> FontUris(embedUri, metricsUri, afmUri,
>> +                pfmUri) : new FontUris(embedUri, metricsUri);
>>
>> +        String subFont = font.getSubFont();
>>          List<FontTriplet> tripletList = font.getTripletList();
>>
>>          // no font triplet info
>> @@ -160,8 +166,8 @@ public class DefaultFontConfigurator imp
>>          }
>>          EncodingMode encodingMode =
>> EncodingMode.getValue(font.getEncodingMode());
>>          EmbeddingMode embeddingMode =
>> EmbeddingMode.getValue(font.getEmbeddingMode());
>> -        EmbedFontInfo embedFontInfo = new EmbedFontInfo(metricsUri,
>> font.isKerning(),
>> -                font.isAdvanced(), tripletList, embedUri, subFont,
>> encodingMode, embeddingMode);
>> +        EmbedFontInfo embedFontInfo = new EmbedFontInfo(fontUris,
>> font.isKerning(), font.isAdvanced(),
>> +                tripletList, subFont, encodingMode, embeddingMode);
>>          if (fontCache != null) {
>>              if (!fontCache.containsFont(embedFontInfo)) {
>>                  fontCache.addFont(embedFontInfo, resourceResolver);
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java Mon
>> Nov 10 11:18:43 2014
>> @@ -34,8 +34,6 @@ public class EmbedFontInfo implements Se
>>      /** Serialization Version UID */
>>      private static final long serialVersionUID = 8755432068669997369L;
>>
>> -    protected final URI metricsURI;
>> -    protected final URI embedURI;
>>      /** false, to disable kerning */
>>      protected final boolean kerning;
>>      /** false, to disable advanced typographic features */
>> @@ -55,6 +53,8 @@ public class EmbedFontInfo implements Se
>>
>>      private transient boolean embedded = true;
>>
>> +    private FontUris fontUris;
>> +
>>      /**
>>       * Main constructor
>>       * @param metricsURI the URI of the XML resource containing font
>> metrics
>> @@ -65,26 +65,42 @@ public class EmbedFontInfo implements Se
>>       * @param subFontName the sub-fontname used for TrueType Collections
>> (null otherwise)
>>       * @param encodingMode the encoding mode to use for this font
>>       */
>> -    public EmbedFontInfo(URI metricsURI, boolean kerning, boolean
>> advanced,
>> -            List<FontTriplet> fontTriplets, URI embedURI, String
>> subFontName,
>> +    public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean
>> advanced,
>> +            List<FontTriplet> fontTriplets, String subFontName,
>>              EncodingMode encodingMode, EmbeddingMode embeddingMode) {
>> -        this.metricsURI = metricsURI;
>> -        this.embedURI = embedURI;
>>          this.kerning = kerning;
>>          this.advanced = advanced;
>>          this.fontTriplets = fontTriplets;
>>          this.subFontName = subFontName;
>>          this.encodingMode = encodingMode;
>>          this.embeddingMode = embeddingMode;
>> +        this.fontUris = fontUris;
>> +    }
>> +
>> +    /**
>> +<<<<<<< HEAD
>> +=======
>> +     * Main constructor
>> +     * @param metricsURI the URI of the XML resource containing font
>> metrics
>> +     * @param kerning True if kerning should be enabled
>> +     * @param fontTriplets List of font triplets to associate with this
>> font
>> +     * @param embedURI Path to the embeddable font file (may be null)
>> +     * @param subFontName the sub-fontname used for TrueType Collections
>> (null otherwise)
>> +     */
>> +    public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean
>> advanced,
>> +            List<FontTriplet> fontTriplets, String subFontName) {
>> +        this(fontUris, kerning, advanced, fontTriplets, subFontName,
>> EncodingMode.AUTO,
>> +                EmbeddingMode.AUTO);
>>      }
>>
>>      /**
>> +>>>>>>> 9c3c942... added uris for afm and pfm font files
>>       * Returns the URI of the metrics XML resource
>>       *
>>       * @return the metrics file path
>>       */
>>      public URI getMetricsURI() {
>> -        return metricsURI;
>> +        return fontUris.getMetrics();
>>      }
>>
>>      /**
>> @@ -93,7 +109,7 @@ public class EmbedFontInfo implements Se
>>       * @return the font resource URI
>>       */
>>      public URI getEmbedURI() {
>> -        return embedURI;
>> +        return fontUris.getEmbed();
>>      }
>>
>>      /**
>> @@ -150,7 +166,7 @@ public class EmbedFontInfo implements Se
>>       * @return true if the font is embedded, false if it is referenced.
>>       */
>>      public boolean isEmbedded() {
>> -        if (embedURI == null) {
>> +        if (fontUris.getEmbed() == null) {
>>              return false;
>>          } else {
>>              return this.embedded;
>> @@ -189,7 +205,7 @@ public class EmbedFontInfo implements Se
>>
>>      /** {@inheritDoc} */
>>      public String toString() {
>> -        return "metrics-uri=" + metricsURI + ", embed-uri=" + embedURI
>> +        return "metrics-uri=" + fontUris.getMetrics() + ", embed-uri=" +
>> fontUris.getEmbed()
>>              + ", kerning=" + kerning
>>              + ", advanced=" + advanced
>>              + ", enc-mode=" + encodingMode
>> @@ -198,4 +214,7 @@ public class EmbedFontInfo implements Se
>>              + (isEmbedded() ? "" : ", NOT embedded");
>>      }
>>
>> +    public FontUris getFontUris() {
>> +        return fontUris;
>> +    }
>>  }
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>> (original)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
>> Mon Nov 10 11:18:43 2014
>> @@ -89,20 +89,20 @@ public abstract class FontLoader {
>>       * @return the newly loaded font
>>       * @throws IOException In case of an I/O error
>>       */
>> -    public static CustomFont loadFont(URI fontFileURI, String
>> subFontName,
>> +    public static CustomFont loadFont(FontUris fontUris, String
>> subFontName,
>>              boolean embedded, EmbeddingMode embeddingMode, EncodingMode
>> encodingMode,
>>              boolean useKerning, boolean useAdvanced,
>> InternalResourceResolver resourceResolver) throws IOException {
>> -        boolean type1 = isType1(fontFileURI);
>> +        boolean type1 = isType1(fontUris.getEmbed());
>>          FontLoader loader;
>>          if (type1) {
>>              if (encodingMode == EncodingMode.CID) {
>>                  throw new IllegalArgumentException(
>>                          "CID encoding mode not supported for Type 1
>> fonts");
>>              }
>> -            loader = new Type1FontLoader(fontFileURI, embedded,
>> embeddingMode, useKerning,
>> +            loader = new Type1FontLoader(fontUris, embedded,
>> embeddingMode, useKerning,
>>                      resourceResolver);
>>          } else {
>> -            loader = new OFFontLoader(fontFileURI, subFontName,
>> embedded, embeddingMode,
>> +            loader = new OFFontLoader(fontUris.getEmbed(), subFontName,
>> embedded, embeddingMode,
>>                      encodingMode, useKerning, useAdvanced,
>> resourceResolver);
>>          }
>>          return loader.getFont();
>>
>> Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java?rev=1637817&view=auto
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>> (added)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java Mon
>> Nov 10 11:18:43 2014
>> @@ -0,0 +1,65 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.fonts;
>> +
>> +import java.io.Serializable;
>> +import java.net.URI;
>> +
>> +public class FontUris implements Serializable {
>> +
>> +    private static final long serialVersionUID = 8571060588775532701L;
>> +
>> +    private final URI embed;
>> +    private final URI metrics;
>> +    private final URI afm;
>> +    private final URI pfm;
>> +
>> +    public FontUris(URI embed, URI metrics, URI afm, URI pfm) {
>> +        this.embed = embed;
>> +        this.metrics = metrics;
>> +        this.afm = afm;
>> +        this.pfm = pfm;
>> +    }
>> +
>> +    public FontUris(URI embed, URI metrics) {
>> +        this.embed = embed;
>> +        this.metrics = metrics;
>> +        this.afm = null;
>> +        this.pfm = null;
>> +    }
>> +
>> +    public URI getEmbed() {
>> +        return embed;
>> +    }
>> +
>> +    public URI getMetrics() {
>> +        return metrics;
>> +    }
>> +
>> +    public URI getAfm() {
>> +        return afm;
>> +    }
>> +
>> +    public URI getPfm() {
>> +        return pfm;
>> +    }
>> +
>> +}
>> +
>>
>> Propchange:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUris.java
>>
>> ------------------------------------------------------------------------------
>>     svn:mime-type = text/plain
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
>> (original)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java Mon
>> Nov 10 11:18:43 2014
>> @@ -43,8 +43,8 @@ public class LazyFont extends Typeface i
>>
>>      private static Log log = LogFactory.getLog(LazyFont.class);
>>
>> -    private final URI metricsURI;
>> -    private final URI fontEmbedURI;
>> +    private final FontUris fontUris;
>> +
>>      private final boolean useKerning;
>>      private final boolean useAdvanced;
>>      private final EncodingMode encodingMode;
>> @@ -64,8 +64,8 @@ public class LazyFont extends Typeface i
>>       */
>>      public LazyFont(EmbedFontInfo fontInfo, InternalResourceResolver
>> resourceResolver,
>>              boolean useComplexScripts) {
>> -        this.metricsURI = fontInfo.getMetricsURI();
>> -        this.fontEmbedURI = fontInfo.getEmbedURI();
>> +
>> +        this.fontUris = fontInfo.getFontUris();
>>          this.useKerning = fontInfo.getKerning();
>>          if (resourceResolver != null) {
>>              this.useAdvanced = useComplexScripts;
>> @@ -85,8 +85,8 @@ public class LazyFont extends Typeface i
>>      public String toString() {
>>          StringBuffer sbuf = new StringBuffer(super.toString());
>>          sbuf.append('{');
>> -        sbuf.append("metrics-url=" + metricsURI);
>> -        sbuf.append(",embed-url=" + fontEmbedURI);
>> +        sbuf.append("metrics-url=" + fontUris.getMetrics());
>> +        sbuf.append(",embed-url=" + fontUris.getEmbed());
>>          sbuf.append(",kerning=" + useKerning);
>>          sbuf.append(",advanced=" + useAdvanced);
>>          sbuf.append('}');
>> @@ -96,36 +96,36 @@ public class LazyFont extends Typeface i
>>      private void load(boolean fail) {
>>          if (!isMetricsLoaded) {
>>              try {
>> -                if (metricsURI != null) {
>> +                if (fontUris.getMetrics() != null) {
>>                      /**@todo Possible thread problem here */
>>                      FontReader reader = null;
>> -                    InputStream in =
>> resourceResolver.getResource(metricsURI);
>> +                    InputStream in =
>> resourceResolver.getResource(fontUris.getMetrics());
>>                      InputSource src = new InputSource(in);
>> -                    src.setSystemId(metricsURI.toASCIIString());
>> +
>> src.setSystemId(fontUris.getMetrics().toASCIIString());
>>                      reader = new FontReader(src, resourceResolver);
>>                      reader.setKerningEnabled(useKerning);
>>                      reader.setAdvancedEnabled(useAdvanced);
>>                      if (this.embedded) {
>> -                        reader.setFontEmbedURI(fontEmbedURI);
>> +                        reader.setFontEmbedURI(fontUris.getEmbed());
>>                      }
>>                      realFont = reader.getFont();
>>                  } else {
>> -                    if (fontEmbedURI == null) {
>> +                    if (fontUris.getEmbed() == null) {
>>                          throw new RuntimeException("Cannot load font. No
>> font URIs available.");
>>                      }
>> -                    realFont = FontLoader.loadFont(fontEmbedURI,
>> subFontName, embedded,
>> +                    realFont = FontLoader.loadFont(fontUris,
>> subFontName, embedded,
>>                              embeddingMode, encodingMode, useKerning,
>> useAdvanced, resourceResolver);
>>                  }
>>                  if (realFont instanceof FontDescriptor) {
>>                      realFontDescriptor = (FontDescriptor) realFont;
>>                  }
>>              } catch (FOPException fopex) {
>> -                log.error("Failed to read font metrics file " +
>> metricsURI, fopex);
>> +                log.error("Failed to read font metrics file " +
>> fontUris.getMetrics(), fopex);
>>                  if (fail) {
>>                      throw new RuntimeException(fopex);
>>                  }
>>              } catch (IOException ioex) {
>> -                log.error("Failed to read font metrics file " +
>> metricsURI, ioex);
>> +                log.error("Failed to read font metrics file " +
>> fontUris.getMetrics(), ioex);
>>                  if (fail) {
>>                      throw new RuntimeException(ioex);
>>                  }
>> @@ -498,6 +498,5 @@ public class LazyFont extends Typeface i
>>          }
>>          return realFont.isMultiByte();
>>      }
>> -
>>  }
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
>> Mon Nov 10 11:18:43 2014
>> @@ -40,6 +40,7 @@ import org.apache.fop.fonts.FontCache;
>>  import org.apache.fop.fonts.FontEventListener;
>>  import org.apache.fop.fonts.FontLoader;
>>  import org.apache.fop.fonts.FontTriplet;
>> +import org.apache.fop.fonts.FontUris;
>>  import org.apache.fop.fonts.FontUtil;
>>  import org.apache.fop.fonts.MultiByteFont;
>>  import org.apache.fop.fonts.truetype.FontFileReader;
>> @@ -141,14 +142,15 @@ public class FontInfoFinder {
>>       */
>>      private EmbedFontInfo getFontInfoFromCustomFont(URI fontUri,
>> CustomFont customFont,
>>              FontCache fontCache, InternalResourceResolver
>> resourceResolver) {
>> +        FontUris fontUris = new FontUris(fontUri, null);
>>          List<FontTriplet> fontTripletList = new
>> java.util.ArrayList<FontTriplet>();
>>          generateTripletsFromFont(customFont, fontTripletList);
>>          String subFontName = null;
>>          if (customFont instanceof MultiByteFont) {
>>              subFontName = ((MultiByteFont) customFont).getTTCName();
>>          }
>> -        EmbedFontInfo fontInfo = new EmbedFontInfo(null,
>> customFont.isKerningEnabled(),
>> -                customFont.isAdvancedEnabled(), fontTripletList,
>> fontUri, subFontName,
>> +        EmbedFontInfo fontInfo = new EmbedFontInfo(fontUris,
>> customFont.isKerningEnabled(),
>> +                customFont.isAdvancedEnabled(), fontTripletList,
>> subFontName,
>>                  EncodingMode.AUTO, EmbeddingMode.AUTO);
>>          fontInfo.setPostScriptName(customFont.getFontName());
>>          if (fontCache != null) {
>> @@ -248,8 +250,9 @@ public class FontInfoFinder {
>>          } else {
>>              // The normal case
>>              try {
>> -                customFont = FontLoader.loadFont(fontURI, null, true,
>> EmbeddingMode.AUTO,
>> -                        EncodingMode.AUTO, useKerning, useAdvanced,
>> resourceResolver);
>> +                FontUris fontUris = new FontUris(fontURI, null);
>> +                customFont = FontLoader.loadFont(fontUris, null, true,
>> EmbeddingMode.AUTO, EncodingMode.AUTO,
>> +                        useKerning, useAdvanced, resourceResolver);
>>                  if (this.eventListener != null) {
>>                      customFont.setEventListener(this.eventListener);
>>                  }
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
>> Mon Nov 10 11:18:43 2014
>> @@ -22,7 +22,6 @@ package org.apache.fop.fonts.type1;
>>  import java.awt.geom.RectangularShape;
>>  import java.io.IOException;
>>  import java.io.InputStream;
>> -import java.net.URI;
>>  import java.net.URISyntaxException;
>>  import java.util.HashSet;
>>  import java.util.List;
>> @@ -37,6 +36,7 @@ import org.apache.fop.fonts.CodePointMap
>>  import org.apache.fop.fonts.EmbeddingMode;
>>  import org.apache.fop.fonts.FontLoader;
>>  import org.apache.fop.fonts.FontType;
>> +import org.apache.fop.fonts.FontUris;
>>  import org.apache.fop.fonts.SingleByteEncoding;
>>  import org.apache.fop.fonts.SingleByteFont;
>>
>> @@ -51,6 +51,8 @@ public class Type1FontLoader extends Fon
>>
>>      private EmbeddingMode embeddingMode;
>>
>> +    private final FontUris fontUris;
>> +
>>      /**
>>       * Constructs a new Type 1 font loader.
>>       * @param fontFileURI the URI to the PFB file of a Type 1 font
>> @@ -59,10 +61,11 @@ public class Type1FontLoader extends Fon
>>       * @param resourceResolver the font resolver used to resolve URIs
>>       * @throws IOException In case of an I/O error
>>       */
>> -    public Type1FontLoader(URI fontFileURI, boolean embedded,
>> EmbeddingMode embeddingMode,
>> +    public Type1FontLoader(FontUris fontUris, boolean embedded,
>> EmbeddingMode embeddingMode,
>>              boolean useKerning, InternalResourceResolver
>> resourceResolver) throws IOException {
>> -        super(fontFileURI, embedded, useKerning, true, resourceResolver);
>> +        super(fontUris.getEmbed(), embedded, useKerning, true,
>> resourceResolver);
>>          this.embeddingMode = embeddingMode;
>> +        this.fontUris = fontUris;
>>      }
>>
>>      private String getPFMURI(String pfbURI) {
>> @@ -83,18 +86,26 @@ public class Type1FontLoader extends Fon
>>          InputStream afmIn = null;
>>          String fontFileStr = fontFileURI.toASCIIString();
>>          String partialAfmUri = fontFileStr.substring(0,
>> fontFileStr.length() - 4);
>> -        String afmUri = null;
>> -        for (String afmExtension : AFM_EXTENSIONS) {
>> +        String afmUri = (fontUris.getAfm() != null) ?
>> fontUris.getAfm().toASCIIString() : null;
>> +        if (afmUri == null) {
>> +            for (String afmExtension : AFM_EXTENSIONS) {
>> +                try {
>> +                    afmUri = partialAfmUri + afmExtension;
>> +                    afmIn = resourceResolver.getResource(afmUri);
>> +                    if (afmIn != null) {
>> +                        break;
>> +                    }
>> +                } catch (IOException ioe) {
>> +                    // Ignore, AFM probably not available under the URI
>> +                } catch (URISyntaxException e) {
>> +                    // Ignore, AFM probably not available under the URI
>> +                }
>> +            }
>> +        } else {
>>              try {
>> -                afmUri = partialAfmUri + afmExtension;
>>                  afmIn = resourceResolver.getResource(afmUri);
>> -                if (afmIn != null) {
>> -                    break;
>> -                }
>> -            } catch (IOException ioe) {
>> -                // Ignore, AFM probably not available under the URI
>>              } catch (URISyntaxException e) {
>> -                // Ignore, AFM probably not available under the URI
>> +                throw new IOException(e);
>>              }
>>          }
>>          if (afmIn != null) {
>> @@ -106,7 +117,8 @@ public class Type1FontLoader extends Fon
>>              }
>>          }
>>
>> -        String pfmUri = getPFMURI(fontFileStr);
>> +        String pfmUri = (fontUris.getPfm() == null) ?
>> getPFMURI(fontFileStr) : fontUris.getPfm()
>> +                .toASCIIString();
>>          InputStream pfmIn = null;
>>          try {
>>              pfmIn = resourceResolver.getResource(pfmUri);
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
>> Mon Nov 10 11:18:43 2014
>> @@ -33,6 +33,7 @@ import org.apache.fop.fonts.FontCollecti
>>  import org.apache.fop.fonts.FontInfo;
>>  import org.apache.fop.fonts.FontLoader;
>>  import org.apache.fop.fonts.FontTriplet;
>> +import org.apache.fop.fonts.FontUris;
>>  import org.apache.fop.fonts.LazyFont;
>>
>>  /**
>> @@ -81,10 +82,10 @@ public class ConfiguredFontCollection im
>>                      InputStream fontSource =
>> resourceResolver.getResource(fontURI);
>>                      font = new CustomFontMetricsMapper(fontMetrics,
>> fontSource);
>>                  } else {
>> -                    CustomFont fontMetrics =
>> FontLoader.loadFont(fontURI, null, true,
>> +                    FontUris fontUris = new FontUris(fontURI, null);
>> +                    CustomFont fontMetrics =
>> FontLoader.loadFont(fontUris, null, true,
>>                              configFontInfo.getEmbeddingMode(),
>> configFontInfo.getEncodingMode(),
>> -                            configFontInfo.getKerning(),
>> configFontInfo.getAdvanced(),
>> -                            resourceResolver);
>> +                            configFontInfo.getKerning(),
>> configFontInfo.getAdvanced(), resourceResolver);
>>                      font = new CustomFontMetricsMapper(fontMetrics);
>>                  }
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
>> Mon Nov 10 11:18:43 2014
>> @@ -47,7 +47,8 @@ public class DejaVuLGCSerifTestCase {
>>      @Before
>>      public void setUp() throws Exception {
>>          File file = new
>> File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
>> -        font = FontLoader.loadFont(file.toURI(), "", true,
>> EmbeddingMode.AUTO, EncodingMode.AUTO,
>> +        FontUris fontUris = new FontUris(file.toURI(), null);
>> +        font = FontLoader.loadFont(fontUris, "", true,
>> EmbeddingMode.AUTO, EncodingMode.AUTO,
>>                  false, false, resolver);
>>      }
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java?rev=1637817&r1=1637816&r2=1637817&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
>> Mon Nov 10 11:18:43 2014
>> @@ -52,8 +52,8 @@ public class EmbedFontInfoTestCase {
>>      public void setUp() {
>>          List<FontTriplet> triplets = new ArrayList<FontTriplet>();
>>          triplets.add(triplet);
>> -        sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced,
>> triplets, embedURI, subFontName,
>> -                encMode, embedMode);
>> +        FontUris fontUris = new FontUris(embedURI, metricsURI);
>> +        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced,
>> triplets, subFontName, encMode, embedMode);
>>      }
>>
>>      @Test
>> @@ -82,8 +82,9 @@ public class EmbedFontInfoTestCase {
>>
>>      @Test
>>      public void testQuirkyBoundaryCasesIsEmbedded() {
>> -        sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced,
>> sut.getFontTriplets(), null,
>> -                subFontName, encMode, embedMode);
>> +        FontUris fontUris = new FontUris(null, metricsURI);
>> +        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced,
>> sut.getFontTriplets(), subFontName, encMode,
>> +                embedMode);
>>          sut.setEmbedded(true);
>>          assertFalse(sut.isEmbedded());
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
>>
>>
>