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 java.util.Map<OFTableName,OFDirTabEntry> |
dirTabs
Table directory
|
protected java.lang.String |
embedFontName |
protected java.util.Set<java.lang.String> |
familyNames |
protected FontFileReader |
fontFile
The FontFileReader used to read this TrueType font.
|
protected java.lang.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 java.lang.String |
notice |
protected int |
numberOfGlyphs |
protected java.lang.String |
postScriptName |
protected java.lang.String |
subFamilyName |
static boolean |
TRACE_ENABLED
Set to true to get even more debug output than with level DEBUG
|
protected java.util.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(java.lang.String tag,
java.lang.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.
|
java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.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
|
java.awt.Rectangle[] |
getBoundingBoxes() |
int |
getCapHeight()
Returns the CapHeight attribute of the font.
|
java.lang.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
|
java.util.List<CMapSegment> |
getCMaps()
Returns this font's character to glyph mapping.
|
java.lang.String |
getCopyrightNotice() |
OFDirTabEntry |
getDirectoryEntry(OFTableName name)
Obtain directory table entry.
|
java.lang.String |
getEmbedFontName() |
java.util.Set<java.lang.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() |
java.lang.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.
|
java.lang.String |
getItalicAngle()
Returns the ItalicAngle attribute of the font.
|
java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.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.
|
java.util.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.
|
java.lang.String |
getPostScriptName()
Returns the PostScript name of the font.
|
java.lang.String |
getStemV()
Returns the StemV attribute of the font.
|
int |
getStrikeoutPosition() |
int |
getStrikeoutThickness() |
java.lang.String |
getSubFamilyName()
Returns the font sub family name of the font.
|
java.util.List<java.lang.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(java.lang.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,
java.lang.String header)
Reads the font using a FontFileReader.
|
void |
readFont(FontFileReader in,
java.lang.String header,
MultiByteFont mbfont)
Reads a font.
|
boolean |
readFont(FontFileReader in,
java.lang.String header,
java.lang.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 java.util.Map<OFTableName,OFDirTabEntry> dirTabs
protected java.util.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 java.lang.String postScriptName
protected java.lang.String fullName
protected java.lang.String embedFontName
protected java.lang.String notice
protected final java.util.Set<java.lang.String> familyNames
protected java.lang.String subFamilyName
protected boolean cid
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 java.io.IOException
in
- font file readertableName
- (tag) of tableoffset
- from start of tablejava.io.IOException
- if I/O exception occurs during seekpublic int convertTTFUnit2PDFUnit(int n)
n
- truetype unitprotected boolean readCMAP() throws java.io.IOException
java.io.IOException
public java.util.List<OFMtxEntry> getMtx()
public void readFont(FontFileReader in, java.lang.String header) throws java.io.IOException
in
- The FontFileReader to usejava.io.IOException
- In case of an I/O problemprotected void initAnsiWidths()
public boolean readFont(FontFileReader in, java.lang.String header, java.lang.String name) throws java.io.IOException
in
- The FontFileReader to usename
- The name of the fontjava.io.IOException
- In case of an I/O problempublic void readFont(FontFileReader in, java.lang.String header, MultiByteFont mbfont) throws java.io.IOException
in
- FontFileReader to read fromname
- Name to be checked for in the font fileglyphs
- Map of glyphs (glyphs has old index as (Integer) key and
new index as (Integer) value)java.io.IOException
- in case of an I/O problemprotected abstract void updateBBoxAndOffset() throws java.io.IOException
java.io.IOException
protected abstract void readName() throws java.io.IOException
java.io.IOException
protected abstract void initializeFont(FontFileReader in) throws java.io.IOException
java.io.IOException
protected void handleCharacterSpacing(FontFileReader in) throws java.io.IOException
java.io.IOException
protected void createCMaps()
public java.lang.String getPostScriptName()
public java.util.Set<java.lang.String> getFamilyNames()
public java.lang.String getSubFamilyName()
public java.lang.String getFullName()
public java.lang.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 java.lang.String getStemV()
public java.lang.String getItalicAngle()
public int[] getFontBBox()
public int[] getBBoxRaw()
public int getLowerCaseAscent()
public int getLowerCaseDescent()
public short getLastChar()
public short getFirstChar()
public int[] getWidths()
public java.awt.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 java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.Integer>> getKerning()
public java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.Integer>> getAnsiKerning()
public int getUnderlinePosition()
public int getUnderlineThickness()
public int getStrikeoutPosition()
public int getStrikeoutThickness()
public boolean isEmbeddable()
public boolean isCFF()
protected void readDirTabs() throws java.io.IOException
java.io.IOException
- in case of an I/O problemprotected void readFontHeader() throws java.io.IOException
java.io.IOException
- in case of an I/O problemprotected void getNumGlyphs() throws java.io.IOException
java.io.IOException
- in case of an I/O problemprotected void readHorizontalHeader() throws java.io.IOException
java.io.IOException
- in case of an I/O problemprotected void readHorizontalMetrics() throws java.io.IOException
java.io.IOException
- in case of an I/O problemprotected void readPostScript() throws java.io.IOException
java.io.IOException
protected void readOS2() throws java.io.IOException
java.io.IOException
protected boolean readPCLT() throws java.io.IOException
java.io.IOException
- In case of a I/O problemprotected void determineAscDesc()
protected void guessVerticalMetricsFromGlyphBBox()
protected void readKerning() throws java.io.IOException
java.io.IOException
- In case of a I/O problempublic void stream(TTFOutputStream ttfOut) throws java.io.IOException
ttfOut
- The interface for streaming TrueType tables.java.io.IOException
- file write errorpublic java.util.List<CMapSegment> getCMaps()
protected final boolean checkTTC(java.lang.String tag, java.lang.String name) throws java.io.IOException
name
- The name to checkjava.io.IOException
- In case of an I/O problempublic final java.util.List<java.lang.String> getTTCnames(FontFileReader in) throws java.io.IOException
in
- FontFileReader to read fromjava.io.IOException
- 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(java.lang.String[] args)
args
- The command line argumentspublic java.lang.String getEmbedFontName()
public java.lang.String getCopyrightNotice()
Copyright 1999-2017 The Apache Software Foundation. All Rights Reserved.