Package org.apache.fop.fonts.apps
Class TTFReader
- java.lang.Object
-
- org.apache.fop.fonts.apps.AbstractFontReader
-
- org.apache.fop.fonts.apps.TTFReader
-
public class TTFReader extends AbstractFontReader
A tool which reads TTF files and generates XML font metrics file for use in FOP.
-
-
Field Summary
Fields Modifier and Type Field Description static int
METRICS_VERSION
Current version number for the metrics filestatic java.lang.String
METRICS_VERSION_ATTR
Used to detect incompatible versions of the generated XML files-
Fields inherited from class org.apache.fop.fonts.apps.AbstractFontReader
log
-
-
Constructor Summary
Constructors Constructor Description TTFReader()
Main constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
checkMetricsVersion(org.xml.sax.Attributes attr)
Bugzilla 40739, check that attr has a metrics-version attribute compatible with ours.org.w3c.dom.Document
constructFontXML(TTFFile ttf, java.lang.String fontName, java.lang.String className, java.lang.String resource, java.lang.String file, boolean isCid, java.lang.String ttcName)
Generates the font metrics file from the TTF/TTC file.private static void
displayUsage()
private void
generateDOM4Kerning(org.w3c.dom.Element parent, TTFFile ttf, boolean isCid)
private void
generateDOM4MultiByteExtras(org.w3c.dom.Element parent, TTFFile ttf, boolean isCid)
private void
generateDOM4SingleByteExtras(org.w3c.dom.Element parent, TTFFile ttf, boolean isCid)
TTFFile
loadTTF(java.lang.String fileName, java.lang.String fontName, boolean useKerning, boolean useAdvanced)
Read a TTF file and returns it as an object.static void
main(java.lang.String[] args)
The main method for the TTFReader tool.-
Methods inherited from class org.apache.fop.fonts.apps.AbstractFontReader
determineLogLevel, parseArguments, setLogLevel, writeFontXML, writeFontXML
-
-
-
-
Field Detail
-
METRICS_VERSION_ATTR
public static final java.lang.String METRICS_VERSION_ATTR
Used to detect incompatible versions of the generated XML files- See Also:
- Constant Field Values
-
METRICS_VERSION
public static final int METRICS_VERSION
Current version number for the metrics file- See Also:
- Constant Field Values
-
-
Method Detail
-
displayUsage
private static void displayUsage()
-
main
public static void main(java.lang.String[] args)
The main method for the TTFReader tool.- Parameters:
args
- Command-line arguments: [options] fontfile.ttf xmlfile.xml where options can be: -fn fontname default is to use the fontname in the .ttf file, but you can override that name to make sure that the embedded font is used instead of installed fonts when viewing documents with Acrobat Reader. -cn classname default is to use the fontname -ef path to the truetype fontfile will add the possibility to embed the font. When running fop, fop will look for this file to embed it -er path to truetype fontfile relative to org/apache/fop/render/pdf/fonts you can also include the fontfile in the fop.jar file when building fop. You can use both -ef and -er. The file specified in -ef will be searched first, then the -er file. -nocs if complex script features are disabled
-
loadTTF
public TTFFile loadTTF(java.lang.String fileName, java.lang.String fontName, boolean useKerning, boolean useAdvanced) throws java.io.IOException
Read a TTF file and returns it as an object.- Parameters:
fileName
- The filename of the TTF file.fontName
- The name of the fontuseKerning
- true if should load kerning datauseAdvanced
- true if should load advanced typographic table data- Returns:
- The TTF as an object, null if the font is incompatible.
- Throws:
java.io.IOException
- In case of an I/O problem
-
constructFontXML
public org.w3c.dom.Document constructFontXML(TTFFile ttf, java.lang.String fontName, java.lang.String className, java.lang.String resource, java.lang.String file, boolean isCid, java.lang.String ttcName)
Generates the font metrics file from the TTF/TTC file.- Parameters:
ttf
- The PFM file to generate the font metrics from.fontName
- Name of the fontclassName
- Class name for the fontresource
- path to the font as embedded resourcefile
- path to the font as fileisCid
- True if the font is CID encodedttcName
- Name of the TrueType Collection- Returns:
- The DOM document representing the font metrics file.
-
generateDOM4MultiByteExtras
private void generateDOM4MultiByteExtras(org.w3c.dom.Element parent, TTFFile ttf, boolean isCid)
-
generateDOM4SingleByteExtras
private void generateDOM4SingleByteExtras(org.w3c.dom.Element parent, TTFFile ttf, boolean isCid)
-
generateDOM4Kerning
private void generateDOM4Kerning(org.w3c.dom.Element parent, TTFFile ttf, boolean isCid)
-
checkMetricsVersion
public static void checkMetricsVersion(org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
Bugzilla 40739, check that attr has a metrics-version attribute compatible with ours.- Parameters:
attr
- attributes read from the root element of a metrics XML file- Throws:
org.xml.sax.SAXException
- if incompatible
-
-