Modifier and Type | Class and Description |
---|---|
static class |
OpenFont.PostScriptVersion
Version of the PostScript table (post) contained in this font.
|
Modifier and Type | Field and Description |
---|---|
protected OTFAdvancedTypographicTableReader |
advancedTableReader |
protected boolean |
cid |
protected Map<OFTableName,OFDirTabEntry> |
dirTabs
Table directory
|
protected String |
embedFontName |
protected Set<String> |
familyNames |
protected FontFileReader |
fontFile
The FontFileReader used to read this TrueType font.
|
protected String |
fullName |
protected long |
lastLoca
Offset to last loca
|
protected int |
locaFormat |
protected org.apache.commons.logging.Log |
log
logging instance
|
protected OFMtxEntry[] |
mtxTab
Contains glyph data
|
protected int |
nhmtx |
protected String |
notice |
protected int |
numberOfGlyphs |
protected String |
postScriptName |
protected String |
subFamilyName |
protected Map<Integer,SVGGlyphData> |
svgs |
static boolean |
TRACE_ENABLED
Set to true to get even more debug output than with level DEBUG
|
protected List<org.apache.fop.fonts.truetype.OpenFont.UnicodeMapping> |
unicodeMappings |
protected boolean |
useAdvanced |
protected boolean |
useKerning |
Constructor and Description |
---|
OpenFont() |
OpenFont(boolean useKerning,
boolean useAdvanced)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkTTC(String tag,
String name)
Check if this is a TrueType collection and that the given
name exists in the collection.
|
int |
convertTTFUnit2PDFUnit(int n)
Convert from truetype unit to pdf unit based on the
unitsPerEm field in the "head" table
|
protected void |
createCMaps() |
protected void |
determineAscDesc()
Determines the right source for the ascender and descender values.
|
Map<Integer,Map<Integer,Integer>> |
getAnsiKerning()
Returns the ANSI kerning table.
|
int[] |
getBBox(int glyphIndex)
Returns an array (xMin, yMin, xMax, yMax) for a glyph.
|
int[] |
getBBoxRaw()
Returns the original bounding box values from the HEAD table
|
Rectangle[] |
getBoundingBoxes() |
int |
getCapHeight()
Returns the CapHeight attribute of the font.
|
String |
getCharSetName()
Returns the name of the character set used.
|
int |
getCharWidth(int idx)
Returns the width of a given character.
|
int |
getCharWidthRaw(int idx)
Returns the width of a given character in raw units
|
List<CMapSegment> |
getCMaps()
Returns this font's character to glyph mapping.
|
String |
getCopyrightNotice() |
OFDirTabEntry |
getDirectoryEntry(OFTableName name)
Obtain directory table entry.
|
String |
getEmbedFontName() |
Set<String> |
getFamilyNames()
Returns the font family names of the font.
|
short |
getFirstChar()
Returns the index of the first character.
|
int |
getFlags()
Returns the Flags attribute of the font.
|
int[] |
getFontBBox() |
String |
getFullName()
Returns the full name of the font.
|
GlyphDefinitionTable |
getGDEF()
Returns the GDEF table or null if none present.
|
GlyphPositioningTable |
getGPOS()
Returns the GPOS table or null if none present.
|
GlyphSubstitutionTable |
getGSUB()
Returns the GSUB table or null if none present.
|
String |
getItalicAngle()
Returns the ItalicAngle attribute of the font.
|
Map<Integer,Map<Integer,Integer>> |
getKerning()
Returns the kerning table.
|
short |
getLastChar()
Returns the index of the last character, but this is for WinAnsiEncoding
only, so the last char is < 256.
|
int |
getLowerCaseAscent()
Returns the LowerCaseAscent attribute of the font.
|
int |
getLowerCaseDescent()
Returns the LowerCaseDescent attribute of the font.
|
List<OFMtxEntry> |
getMtx() |
protected void |
getNumGlyphs()
Read the number of glyphs from the "maxp" table
|
protected int |
getPadSize(int currentPosition)
Returns the number of bytes necessary to pad the currentPosition so that a table begins
on a 4-byte boundary.
|
String |
getPostScriptName()
Returns the PostScript name of the font.
|
String |
getStemV()
Returns the StemV attribute of the font.
|
int |
getStrikeoutPosition() |
int |
getStrikeoutThickness() |
String |
getSubFamilyName()
Returns the font sub family name of the font.
|
List<String> |
getTTCnames(FontFileReader in)
Return TTC font names
|
int |
getUnderlinePosition() |
int |
getUnderlineThickness() |
int |
getWeightClass()
Returns the weight class of this font.
|
int[] |
getWidths()
Returns an array of character widths.
|
int |
getXHeight()
Returns the XHeight attribute of the font.
|
protected void |
guessVerticalMetricsFromGlyphBBox() |
protected void |
handleCharacterSpacing(FontFileReader in) |
boolean |
hasAdvancedTable()
Determine if advanced (typographic) table is present.
|
protected void |
initAnsiWidths()
initialize the ansiWidths array (for winAnsiEncoding)
and fill with the missingwidth
|
protected abstract void |
initializeFont(FontFileReader in) |
boolean |
isCFF()
Indicates whether or not the font is an OpenType
CFF font (rather than a TrueType font).
|
boolean |
isEmbeddable()
Indicates if the font may be embedded.
|
static void |
main(String[] args)
Static main method to get info about a TrueType font.
|
void |
printStuff()
Dumps a few informational values to System.out.
|
protected boolean |
readCMAP()
Read the cmap table,
return false if the table is not present or only unsupported
tables are present.
|
protected void |
readDirTabs()
Read Table Directory from the current position in the
FontFileReader and fill the global HashMap dirTabs
with the table name (String) as key and a TTFDirTabEntry
as value.
|
void |
readFont(FontFileReader in,
String header)
Reads the font using a FontFileReader.
|
void |
readFont(FontFileReader in,
String header,
MultiByteFont mbfont)
Reads a font.
|
boolean |
readFont(FontFileReader in,
String header,
String name)
Read the font data.
|
protected void |
readFontHeader()
Read the "head" table, this reads the bounding box and
sets the upem (unitsPerEM) variable
|
protected void |
readHorizontalHeader()
Read the "hhea" table to find the ascender and descender and
size of "hmtx" table, as a fixed size font might have only
one width.
|
protected void |
readHorizontalMetrics()
Read "hmtx" table and put the horizontal metrics
in the mtxTab array.
|
protected void |
readKerning()
Read the kerning table, create a table for both CIDs and
winAnsiEncoding.
|
protected abstract void |
readName() |
protected void |
readOS2()
Read the "OS/2" table
|
protected boolean |
readPCLT()
Read the "PCLT" table to find xHeight and capHeight.
|
protected void |
readPostScript()
Read the "post" table
containing the PostScript names of the glyphs.
|
boolean |
seekTab(FontFileReader in,
OFTableName tableName,
long offset)
Position inputstream to position indicated
in the dirtab offset + offset
|
void |
stream(TTFOutputStream ttfOut)
Streams a font.
|
protected abstract void |
updateBBoxAndOffset() |
protected FontFileReader fontFile
public static final boolean TRACE_ENABLED
protected boolean useKerning
protected Map<OFTableName,OFDirTabEntry> dirTabs
protected List<org.apache.fop.fonts.truetype.OpenFont.UnicodeMapping> unicodeMappings
protected int nhmtx
protected int locaFormat
protected long lastLoca
protected int numberOfGlyphs
protected OFMtxEntry[] mtxTab
protected String postScriptName
protected String fullName
protected String embedFontName
protected String notice
protected String subFamilyName
protected boolean cid
protected Map<Integer,SVGGlyphData> svgs
protected boolean useAdvanced
protected OTFAdvancedTypographicTableReader advancedTableReader
protected org.apache.commons.logging.Log log
public OpenFont()
public OpenFont(boolean useKerning, boolean useAdvanced)
useKerning
- true if kerning data should be loadeduseAdvanced
- true if advanced typographic tables should be loadedpublic OFDirTabEntry getDirectoryEntry(OFTableName name)
name
- (tag) of entrypublic boolean seekTab(FontFileReader in, OFTableName tableName, long offset) throws IOException
in
- font file readertableName
- (tag) of tableoffset
- from start of tableIOException
- if I/O exception occurs during seekpublic int convertTTFUnit2PDFUnit(int n)
n
- truetype unitprotected boolean readCMAP() throws IOException
IOException
public List<OFMtxEntry> getMtx()
public void readFont(FontFileReader in, String header) throws IOException
in
- The FontFileReader to useIOException
- In case of an I/O problemprotected void initAnsiWidths()
public boolean readFont(FontFileReader in, String header, String name) throws IOException
in
- The FontFileReader to usename
- The name of the fontIOException
- In case of an I/O problempublic void readFont(FontFileReader in, String header, MultiByteFont mbfont) throws IOException
in
- FontFileReader to read fromIOException
- in case of an I/O problemprotected abstract void updateBBoxAndOffset() throws IOException
IOException
protected abstract void readName() throws IOException
IOException
protected abstract void initializeFont(FontFileReader in) throws IOException
IOException
protected void handleCharacterSpacing(FontFileReader in) throws IOException
IOException
protected void createCMaps()
public String getPostScriptName()
public Set<String> getFamilyNames()
public String getSubFamilyName()
public String getFullName()
public String getCharSetName()
public int getCapHeight()
public int getXHeight()
protected int getPadSize(int currentPosition)
currentPosition
- the position to pad.public int getFlags()
public int getWeightClass()
public String getStemV()
public String getItalicAngle()
public int[] getFontBBox()
public int[] getBBoxRaw()
public int getLowerCaseAscent()
public int getLowerCaseDescent()
public short getLastChar()
public short getFirstChar()
public int[] getWidths()
public Rectangle[] getBoundingBoxes()
public int[] getBBox(int glyphIndex)
glyphIndex
- the index of the glyphpublic int getCharWidth(int idx)
idx
- Index of the characterpublic int getCharWidthRaw(int idx)
idx
- Index of the characterpublic Map<Integer,Map<Integer,Integer>> getKerning()
public Map<Integer,Map<Integer,Integer>> getAnsiKerning()
public int getUnderlinePosition()
public int getUnderlineThickness()
public int getStrikeoutPosition()
public int getStrikeoutThickness()
public boolean isEmbeddable()
public boolean isCFF()
protected void readDirTabs() throws IOException
IOException
- in case of an I/O problemprotected void readFontHeader() throws IOException
IOException
- in case of an I/O problemprotected void getNumGlyphs() throws IOException
IOException
- in case of an I/O problemprotected void readHorizontalHeader() throws IOException
IOException
- in case of an I/O problemprotected void readHorizontalMetrics() throws IOException
IOException
- in case of an I/O problemprotected void readPostScript() throws IOException
IOException
protected void readOS2() throws IOException
IOException
protected boolean readPCLT() throws IOException
IOException
- In case of a I/O problemprotected void determineAscDesc()
protected void guessVerticalMetricsFromGlyphBBox()
protected void readKerning() throws IOException
IOException
- In case of a I/O problempublic void stream(TTFOutputStream ttfOut) throws IOException
ttfOut
- The interface for streaming TrueType tables.IOException
- file write errorpublic List<CMapSegment> getCMaps()
protected final boolean checkTTC(String tag, String name) throws IOException
name
- The name to checkIOException
- In case of an I/O problempublic final List<String> getTTCnames(FontFileReader in) throws IOException
in
- FontFileReader to read fromIOException
- In case of an I/O problempublic void printStuff()
public boolean hasAdvancedTable()
public GlyphDefinitionTable getGDEF()
public GlyphSubstitutionTable getGSUB()
public GlyphPositioningTable getGPOS()
public static void main(String[] args)
args
- The command line argumentspublic String getEmbedFontName()
public String getCopyrightNotice()
Copyright © 2025 Apache Software Foundation. All rights reserved.