public class TTFFile
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
TTFFile.PostScriptVersion
Version of the PostScript table (
post) contained in this font. |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<TTFTableName,TTFDirTabEntry> |
dirTabs
Table directory
|
protected FontFileReader |
fontFile
The FontFileReader used to read this TrueType font.
|
protected long |
lastLoca
Offset to last loca
|
protected org.apache.commons.logging.Log |
log
logging instance
|
protected org.apache.fop.fonts.truetype.TTFMtxEntry[] |
mtxTab
Contains glyph data
|
static boolean |
TRACE_ENABLED
Set to true to get even more debug output than with level DEBUG
|
Constructor and Description |
---|
TTFFile() |
TTFFile(boolean useKerning,
boolean useAdvanced)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkTTC(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
|
java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.Integer>> |
getAnsiKerning()
Returns the ANSI kerning table.
|
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.
|
java.util.List<CMapSegment> |
getCMaps()
Returns this font's character to glyph mapping.
|
TTFDirTabEntry |
getDirectoryEntry(TTFTableName name)
Obtain directory table entry.
|
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.
|
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.
|
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 |
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.
|
boolean |
hasAdvancedTable()
Determine if advanced (typographic) table is present.
|
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 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)
Reads the font using a FontFileReader.
|
boolean |
readFont(FontFileReader in,
java.lang.String name)
Read the font data.
|
void |
readFont(FontFileReader in,
java.lang.String name,
java.util.Map<java.lang.Integer,java.lang.Integer> glyphs)
Reads a font.
|
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 |
readIndexToLocation()
Read the "loca" table.
|
boolean |
seekTab(FontFileReader in,
TTFTableName tableName,
long offset)
Position inputstream to position indicated
in the dirtab offset + offset
|
void |
stream(TTFOutputStream ttfOut)
Streams a font.
|
protected FontFileReader fontFile
public static final boolean TRACE_ENABLED
protected java.util.Map<TTFTableName,TTFDirTabEntry> dirTabs
protected long lastLoca
protected org.apache.fop.fonts.truetype.TTFMtxEntry[] mtxTab
protected org.apache.commons.logging.Log log
public TTFFile()
public TTFFile(boolean useKerning, boolean useAdvanced)
useKerning
- true if kerning data should be loadeduseAdvanced
- true if advanced typographic tables should be loadedpublic TTFDirTabEntry getDirectoryEntry(TTFTableName name)
name
- (tag) of entrypublic boolean seekTab(FontFileReader in, TTFTableName 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 unitpublic void readFont(FontFileReader in) throws java.io.IOException
in
- The FontFileReader to usejava.io.IOException
- In case of an I/O problempublic boolean readFont(FontFileReader in, 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 name, java.util.Map<java.lang.Integer,java.lang.Integer> glyphs) 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 problempublic 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 getLowerCaseAscent()
public int getLowerCaseDescent()
public short getLastChar()
public short getFirstChar()
public int[] getWidths()
public int getCharWidth(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 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 final void readIndexToLocation() 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 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 argumentsCopyright 1999-2012 The Apache Software Foundation. All Rights Reserved.