Package uk.ac.starlink.ttools.plot
Class ExternalFontMapper
java.lang.Object
com.lowagie.text.pdf.DefaultFontMapper
uk.ac.starlink.ttools.plot.ExternalFontMapper
- All Implemented Interfaces:
com.lowagie.text.pdf.FontMapper
public class ExternalFontMapper
extends com.lowagie.text.pdf.DefaultFontMapper
IText FontMapper implementation that works with externally supplied
TTF files. It is suitable for use with JLatexMath.
The paths of externally stored TTF files are supplied to the
mapper at construction time.
There are utility methods for extracting lists of the locations
of such paths from supplied zip (or jar) files.
- Since:
- 4 May 2012
- Author:
- Mark Taylor
-
Nested Class Summary
Nested classes/interfaces inherited from class com.lowagie.text.pdf.DefaultFontMapper
com.lowagie.text.pdf.DefaultFontMapper.BaseFontParameters
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.lowagie.text.pdf.BaseFont
static ExternalFontMapper
Creates a font mapper given a stream of strings giving resource paths, for resources available on the classpath.static ExternalFontMapper
createMapperFromResourcePaths
(String[] paths) Creates a font mapper given a list of font resource paths, for resources available on the classpath.static void
When given the names of one or more zip/jar files as arguments, this writes to standard output the absolute paths of any entries that appear to be a TTF file.static String[]
readLines
(InputStream in) Reads lines of text from a stream.static void
writeLines
(String[] lines, OutputStream out) Writes lines of text to a stream.Methods inherited from class com.lowagie.text.pdf.DefaultFontMapper
getAliases, getBaseFontParameters, getMapper, insertDirectory, insertNames, pdfToAwt, putAlias, putName
-
Constructor Details
-
ExternalFontMapper
Constructor.- Parameters:
fontLocations
- locations for font TTF files as supplied to the FontFactory.register method; URLs work (probably files too)
-
-
Method Details
-
awtToPdf
- Specified by:
awtToPdf
in interfacecom.lowagie.text.pdf.FontMapper
- Overrides:
awtToPdf
in classcom.lowagie.text.pdf.DefaultFontMapper
-
createMapperFromResourcePaths
Creates a font mapper given a list of font resource paths, for resources available on the classpath. These are mapped to URLs and passed to the constructor.- Parameters:
paths
- absolute resource path strings for TTF files- Returns:
- new font mapper
-
createMapperFromResourceList
Creates a font mapper given a stream of strings giving resource paths, for resources available on the classpath. The stream is read and closed, andcreateMapperFromResourcePaths(java.lang.String[])
is called. Each resource is on a separate line, encoding is UTF-8.- Parameters:
in
- input stream- Returns:
- new font mapper
- Throws:
IOException
-
readLines
Reads lines of text from a stream.- Parameters:
in
- input stream- Returns:
- lines
- Throws:
IOException
-
writeLines
Writes lines of text to a stream.- Parameters:
lines
- lines to writeout
- output stream- Throws:
IOException
-
main
When given the names of one or more zip/jar files as arguments, this writes to standard output the absolute paths of any entries that appear to be a TTF file. The output of this is suitable for use with thecreateMapperFromResourceList(java.io.InputStream)
method.- Parameters:
args
- list of zip file names- Throws:
IOException
-