diff options
Diffstat (limited to 'src/java/org/apache')
10 files changed, 89 insertions, 10 deletions
diff --git a/src/java/org/apache/fop/afp/fonts/AFPFont.java b/src/java/org/apache/fop/afp/fonts/AFPFont.java index 99e15a46b..3c84e4aa9 100644 --- a/src/java/org/apache/fop/afp/fonts/AFPFont.java +++ b/src/java/org/apache/fop/afp/fonts/AFPFont.java @@ -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 Typeface { } /** {@inheritDoc} */ + public URI getFontURI() { + return null; + } + + /** {@inheritDoc} */ public String getFontName() { return this.name; } diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java index 5c0673b04..fffb429ed 100644 --- a/src/java/org/apache/fop/fonts/CustomFont.java +++ b/src/java/org/apache/fop/fonts/CustomFont.java @@ -42,6 +42,7 @@ public abstract class CustomFont extends Typeface /** 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 Typeface /** {@inheritDoc} */ + public URI getFontURI() { + return fontFileURI; + } + + /** {@inheritDoc} */ public String getFontName() { return fontName; } @@ -326,6 +332,11 @@ public abstract class CustomFont extends Typeface /* ---- MutableFont interface ---- */ /** {@inheritDoc} */ + public void setFontURI(URI uri) { + this.fontFileURI = uri; + } + + /** {@inheritDoc} */ public void setFontName(String name) { this.fontName = name; } diff --git a/src/java/org/apache/fop/fonts/FontMetrics.java b/src/java/org/apache/fop/fonts/FontMetrics.java index 159d321f7..ed59cf5af 100644 --- a/src/java/org/apache/fop/fonts/FontMetrics.java +++ b/src/java/org/apache/fop/fonts/FontMetrics.java @@ -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 */ diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index a392ae6f4..acce1e0f9 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.java @@ -189,6 +189,12 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, // ---- FontMetrics interface ---- /** {@inheritDoc} */ + public URI getFontURI() { + load(true); + return realFont.getFontURI(); + } + + /** {@inheritDoc} */ public String getFontName() { load(true); return realFont.getFontName(); diff --git a/src/java/org/apache/fop/fonts/MutableFont.java b/src/java/org/apache/fop/fonts/MutableFont.java index 9ea323ebf..f02eb2b49 100644 --- a/src/java/org/apache/fop/fonts/MutableFont.java +++ b/src/java/org/apache/fop/fonts/MutableFont.java @@ -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 */ diff --git a/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java index 4216cf290..7c8774933 100644 --- a/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java @@ -141,6 +141,7 @@ public class OFFontLoader extends FontLoader { returnFont = singleFont; } + returnFont.setFontURI(fontFileURI); returnFont.setFontName(otf.getPostScriptName()); returnFont.setFullName(otf.getFullName()); returnFont.setFamilyNames(otf.getFamilyNames()); diff --git a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java index 8a5f4b117..fcb913d53 100644 --- a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java @@ -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 extends Typeface implements FontMetricsMapp } /** {@inheritDoc} */ + public final URI getFontURI() { + return typeface.getFontURI(); + } + + /** {@inheritDoc} */ public final FontType getFontType() { return typeface.getFontType(); } diff --git a/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java index f922e3f05..9ed323ac4 100644 --- a/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java @@ -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 extends Typeface implements FontMetricsMapp */ 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 extends Typeface implements FontMetricsMapp * @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; } diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java index 93648e975..d349394c5 100644 --- a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java +++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java @@ -120,7 +120,7 @@ public class PCLGraphics2D extends AbstractGraphics2D { * @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); } } diff --git a/src/java/org/apache/fop/tools/fontlist/FontListMain.java b/src/java/org/apache/fop/tools/fontlist/FontListMain.java index 794f9306f..af9921c4d 100644 --- a/src/java/org/apache/fop/tools/fontlist/FontListMain.java +++ b/src/java/org/apache/fop/tools/fontlist/FontListMain.java @@ -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); |