You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ga...@apache.org on 2014/08/17 20:56:01 UTC

svn commit: r1618496 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/afp/fonts/ java/org/apache/fop/fonts/ java/org/apache/fop/fonts/truetype/ java/org/apache/fop/render/java2d/ java/org/apache/fop/render/pcl/ java/org/apache/fop/to...

Author: gadams
Date: Sun Aug 17 18:56:01 2014
New Revision: 1618496

URL: http://svn.apache.org/r1618496
Log:
Add verbose (-v) flag to FontList tool that shows URI of font resource.

Modified:
    xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AFPFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/fontlist/FontListMain.java

Modified: xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl (original)
+++ xmlgraphics/fop/trunk/src/codegen/fonts/font-file.xsl Sun Aug 17 18:56:01 2014
@@ -36,6 +36,7 @@
 package org.apache.fop.fonts.base14;
 
 import java.awt.Rectangle;
+import java.net.URI;
 <xsl:if test="count(kerning) &gt; 0">
 import java.util.Map;
 </xsl:if>
@@ -46,6 +47,7 @@ import org.apache.fop.fonts.CodePointMap
 import org.apache.fop.fonts.Typeface;
 
 public class <xsl:value-of select="class-name"/> extends Base14Font {
+    private final static URI fontFileURI;
     private final static String fontName = "<xsl:value-of select="font-name"/>";
     private final static String fullName = "<xsl:value-of select="full-name"/>";
     private final static Set familyNames;
@@ -69,6 +71,12 @@ public class <xsl:value-of select="class
     private boolean enableKerning = false;
 
     static {
+        URI uri = null;
+        try {
+            uri = new URI("base14:" + fontName.toLowerCase());
+        } catch (java.net.URISyntaxException e) {
+        }
+        fontFileURI = uri;
         width = new int[256];
         boundingBoxes = new Rectangle[256];
         <xsl:apply-templates select="char-metrics"/>
@@ -94,6 +102,10 @@ public class <xsl:value-of select="class
         return encoding;
     }
 
+    public URI getFontURI() {
+        return fontFileURI;
+    }
+
     public String getFontName() {
         return fontName;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AFPFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AFPFont.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AFPFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AFPFont.java Sun Aug 17 18:56:01 2014
@@ -20,6 +20,7 @@
 package org.apache.fop.afp.fonts;
 
 import java.awt.Rectangle;
+import java.net.URI;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -27,7 +28,6 @@ import java.util.Set;
 import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.Typeface;
 
-
 /**
  * All implementations of AFP fonts should extend this base class,
  * the object implements the FontMetrics information.
@@ -53,6 +53,11 @@ public abstract class AFPFont extends Ty
     }
 
     /** {@inheritDoc} */
+    public URI getFontURI() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     public String getFontName() {
         return this.name;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java Sun Aug 17 18:56:01 2014
@@ -42,6 +42,7 @@ public abstract class CustomFont extends
     /** Fallback thickness for underline and strikeout when not provided by the font. */
     private static final int DEFAULT_LINE_THICKNESS = 50;
 
+    private URI fontFileURI;
     private String fontName;
     private String fullName;
     private Set<String> familyNames;
@@ -89,6 +90,11 @@ public abstract class CustomFont extends
 
 
     /** {@inheritDoc} */
+    public URI getFontURI() {
+        return fontFileURI;
+    }
+
+    /** {@inheritDoc} */
     public String getFontName() {
         return fontName;
     }
@@ -326,6 +332,11 @@ public abstract class CustomFont extends
     /* ---- MutableFont interface ---- */
 
     /** {@inheritDoc} */
+    public void setFontURI(URI uri) {
+        this.fontFileURI = uri;
+    }
+
+    /** {@inheritDoc} */
     public void setFontName(String name) {
         this.fontName = name;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java Sun Aug 17 18:56:01 2014
@@ -20,17 +20,22 @@
 package org.apache.fop.fonts;
 
 import java.awt.Rectangle;
+import java.net.URI;
 import java.util.Map;
 import java.util.Set;
 
-
-
 /**
  * Main interface for access to font metrics.
  */
 public interface FontMetrics {
 
     /**
+     * Returns the URI of the font file from which these metrics were loaded.
+     * @return the font file's URI
+     */
+    URI getFontURI();
+
+    /**
      * Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
      * @return the font name
      */

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=1618496&r1=1618495&r2=1618496&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 Sun Aug 17 18:56:01 2014
@@ -189,6 +189,12 @@ public class LazyFont extends Typeface i
 
     // ---- FontMetrics interface ----
     /** {@inheritDoc} */
+    public URI getFontURI() {
+        load(true);
+        return realFont.getFontURI();
+    }
+
+    /** {@inheritDoc} */
     public String getFontName() {
         load(true);
         return realFont.getFontName();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java Sun Aug 17 18:56:01 2014
@@ -31,6 +31,12 @@ import java.util.Set;
 public interface MutableFont {
 
     /**
+     * Sets the URI from which this font is or will be loaded.
+     * @param uri URI from which font is or will be loaded
+     */
+    void setFontURI(URI uri);
+
+    /**
      * Sets the "PostScript" font name (Example: "Helvetica-BoldOblique").
      * @param name font name
      */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java Sun Aug 17 18:56:01 2014
@@ -141,6 +141,7 @@ public class OFFontLoader extends FontLo
             returnFont = singleFont;
         }
 
+        returnFont.setFontURI(fontFileURI);
         returnFont.setFontName(otf.getPostScriptName());
         returnFont.setFullName(otf.getFullName());
         returnFont.setFamilyNames(otf.getFamilyNames());

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java Sun Aug 17 18:56:01 2014
@@ -24,6 +24,7 @@ import java.awt.FontFormatException;
 import java.awt.Rectangle;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -161,6 +162,11 @@ public class CustomFontMetricsMapper ext
     }
 
     /** {@inheritDoc} */
+    public final URI getFontURI() {
+        return typeface.getFontURI();
+    }
+
+    /** {@inheritDoc} */
     public final FontType getFontType() {
         return typeface.getFontType();
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java Sun Aug 17 18:56:01 2014
@@ -21,6 +21,7 @@ package org.apache.fop.render.java2d;
 
 // Java
 import java.awt.Rectangle;
+import java.net.URI;
 import java.util.Map;
 import java.util.Set;
 
@@ -44,6 +45,8 @@ public class SystemFontMetricsMapper ext
      */
     private final Java2DFontMetrics java2DFontMetrics;
 
+    private final URI fontFileURI;
+
     /**
      * The java name of the font.
      * #  Make the family name immutable.
@@ -63,14 +66,24 @@ public class SystemFontMetricsMapper ext
      * @param java2DFontMetrics metric calculations delegated to this
      */
     public SystemFontMetricsMapper(String family, int style, Java2DFontMetrics java2DFontMetrics) {
+        URI uri;
+        try {
+            uri = new URI("system:" + family.toLowerCase());
+        } catch (java.net.URISyntaxException e) {
+            uri = null;
+        }
+        this.fontFileURI = uri;
         this.family = family;
-
         this.style = style;
-
         this.java2DFontMetrics = java2DFontMetrics;
     }
 
     /** {@inheritDoc} */
+    public final URI getFontURI() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     public String getFontName() {
         return family;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java Sun Aug 17 18:56:01 2014
@@ -120,7 +120,7 @@ public class PCLGraphics2D extends Abstr
      * @param msg the error message to be displayed
      */
     protected void handleUnsupportedFeature(String msg) {
-        if (this.FAIL_ON_UNSUPPORTED_FEATURE) {
+        if (FAIL_ON_UNSUPPORTED_FEATURE) {
             throw new UnsupportedOperationException(msg);
         }
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/fontlist/FontListMain.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/fontlist/FontListMain.java?rev=1618496&r1=1618495&r2=1618496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/fontlist/FontListMain.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/fontlist/FontListMain.java Sun Aug 17 18:56:01 2014
@@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
+import java.net.URI;
 import java.net.URL;
 import java.util.Iterator;
 import java.util.List;
@@ -66,6 +67,7 @@ public final class FontListMain {
 
     private FopFactory fopFactory;
 
+    private boolean verbose;
     private File configFile;
     private File outputFile;
     private String configMime = MimeConstants.MIME_PDF;
@@ -168,22 +170,42 @@ public final class FontListMain {
     private void writeToConsole(SortedMap fontFamilies)
             throws TransformerConfigurationException, SAXException, IOException {
         Iterator iter = fontFamilies.entrySet().iterator();
+        StringBuffer sb = new StringBuffer();
         while (iter.hasNext()) {
             Map.Entry entry = (Map.Entry)iter.next();
             String firstFamilyName = (String)entry.getKey();
-            System.out.println(firstFamilyName + ":");
+            sb.append(firstFamilyName);
+            sb.append(':');
+            sb.append('\n');
             List list = (List)entry.getValue();
             Iterator fonts = list.iterator();
             while (fonts.hasNext()) {
                 FontSpec f = (FontSpec)fonts.next();
-                System.out.println("  " + f.getKey() + " " + f.getFamilyNames());
+                sb.append("  ");
+                sb.append(f.getKey());
+                sb.append(' ');
+                sb.append(f.getFamilyNames());
+                if (verbose) {
+                    URI uri = f.getFontMetrics().getFontURI();
+                    if (uri != null) {
+                        sb.append(' ');
+                        sb.append('(');
+                        sb.append(uri.toString());
+                        sb.append(')');
+                    }
+                }
+                sb.append('\n');
                 Iterator triplets = f.getTriplets().iterator();
                 while (triplets.hasNext()) {
                     FontTriplet triplet = (FontTriplet)triplets.next();
-                    System.out.println("    " + triplet.toString());
+                    sb.append("    ");
+                    sb.append(triplet.toString());
+                    sb.append('\n');
                 }
             }
         }
+        System.out.print(sb.toString());
+        System.out.flush();
     }
 
     private void writeOutput(SortedMap fontFamilies)
@@ -231,7 +253,7 @@ public final class FontListMain {
         PrintStream out = System.out;
         out.println("USAGE");
         out.println("  java [vmargs] " + className
-                + " [-c <config-file>] [-f <mime>] [[output-dir|output-file] [font-family]]");
+                + "[-v] [-c <config-file>] [-f <mime>] [[output-dir|output-file] [font-family]]");
         out.println();
         out.println("PARAMETERS");
         out.println("  config-file: an optional FOP configuration file");
@@ -260,6 +282,10 @@ public final class FontListMain {
                 // @SuppressFBWarnings("DM_EXIT")
                 System.exit(0);
             }
+            if ("-v".equals(args[idx])) {
+                verbose = true;
+                idx += 1;
+            }
             if (idx < args.length - 1 && "-c".equals(args[idx])) {
                 String filename = args[idx + 1];
                 this.configFile = new File(filename);



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