package org.apache.fop.fonts.base14;
import java.awt.Rectangle;
+import java.net.URI;
<xsl:if test="count(kerning) > 0">
import java.util.Map;
</xsl:if>
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;
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"/>
return encoding;
}
+ public URI getFontURI() {
+ return fontFileURI;
+ }
+
public String getFontName() {
return fontName;
}
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;
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.
this.embeddable = embeddable;
}
+ /** {@inheritDoc} */
+ public URI getFontURI() {
+ return null;
+ }
+
/** {@inheritDoc} */
public String getFontName() {
return this.name;
/** 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;
}
+ /** {@inheritDoc} */
+ public URI getFontURI() {
+ return fontFileURI;
+ }
+
/** {@inheritDoc} */
public String getFontName() {
return fontName;
/* ---- MutableFont interface ---- */
+ /** {@inheritDoc} */
+ public void setFontURI(URI uri) {
+ this.fontFileURI = uri;
+ }
+
/** {@inheritDoc} */
public void setFontName(String name) {
this.fontName = name;
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
}
// ---- FontMetrics interface ----
+ /** {@inheritDoc} */
+ public URI getFontURI() {
+ load(true);
+ return realFont.getFontURI();
+ }
+
/** {@inheritDoc} */
public String getFontName() {
load(true);
*/
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
returnFont = singleFont;
}
+ returnFont.setFontURI(fontFileURI);
returnFont.setFontName(otf.getPostScriptName());
returnFont.setFullName(otf.getFullName());
returnFont.setFamilyNames(otf.getFamilyNames());
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;
return typeface.getFontName();
}
+ /** {@inheritDoc} */
+ public final URI getFontURI() {
+ return typeface.getFontURI();
+ }
+
/** {@inheritDoc} */
public final FontType getFontType() {
return typeface.getFontType();
// Java
import java.awt.Rectangle;
+import java.net.URI;
import java.util.Map;
import java.util.Set;
*/
private final Java2DFontMetrics java2DFontMetrics;
+ private final URI fontFileURI;
+
/**
* The java name of the font.
* # Make the family name immutable.
* @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;
* @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);
}
}
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;
private FopFactory fopFactory;
+ private boolean verbose;
private File configFile;
private File outputFile;
private String configMime = MimeConstants.MIME_PDF;
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)
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");
// @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);