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
-
-
Constructor Summary
Constructors Constructor Description ExternalFontMapper(java.lang.String[] fontLocations)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.lowagie.text.pdf.BaseFont
awtToPdf(java.awt.Font font)
static ExternalFontMapper
createMapperFromResourceList(java.io.InputStream in)
Creates a font mapper given a stream of strings giving resource paths, for resources available on the classpath.static ExternalFontMapper
createMapperFromResourcePaths(java.lang.String[] paths)
Creates a font mapper given a list of font resource paths, for resources available on the classpath.static void
main(java.lang.String[] args)
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 java.lang.String[]
readLines(java.io.InputStream in)
Reads lines of text from a stream.static void
writeLines(java.lang.String[] lines, java.io.OutputStream out)
Writes lines of text to a stream.
-
-
-
Method Detail
-
awtToPdf
public com.lowagie.text.pdf.BaseFont awtToPdf(java.awt.Font font)
- Specified by:
awtToPdf
in interfacecom.lowagie.text.pdf.FontMapper
- Overrides:
awtToPdf
in classcom.lowagie.text.pdf.DefaultFontMapper
-
createMapperFromResourcePaths
public static ExternalFontMapper createMapperFromResourcePaths(java.lang.String[] paths)
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
public static ExternalFontMapper createMapperFromResourceList(java.io.InputStream in) throws java.io.IOException
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:
java.io.IOException
-
readLines
public static java.lang.String[] readLines(java.io.InputStream in) throws java.io.IOException
Reads lines of text from a stream.- Parameters:
in
- input stream- Returns:
- lines
- Throws:
java.io.IOException
-
writeLines
public static void writeLines(java.lang.String[] lines, java.io.OutputStream out) throws java.io.IOException
Writes lines of text to a stream.- Parameters:
lines
- lines to writeout
- output stream- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
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:
java.io.IOException
-
-