Package org.apache.fontbox.ttf
Class NamingTable
- java.lang.Object
-
- org.apache.fontbox.ttf.TTFTable
-
- org.apache.fontbox.ttf.NamingTable
-
public class NamingTable extends TTFTable
This 'name'-table is a required table in a TrueType font.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringfontFamilyprivate java.lang.StringfontSubFamilyprivate java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.String>>>>lookupTableprivate java.util.List<NameRecord>nameRecordsprivate java.lang.StringpsNamestatic java.lang.StringTAGA tag that identifies this table type.-
Fields inherited from class org.apache.fontbox.ttf.TTFTable
initialized
-
-
Constructor Summary
Constructors Constructor Description NamingTable()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidfillLookupTable()private java.nio.charset.CharsetgetCharset(NameRecord nr)private java.lang.StringgetEnglishName(int nameId)Helper to get English names by best effort.java.lang.StringgetFontFamily()Returns the font family name, in English.java.lang.StringgetFontSubFamily()Returns the font sub family name, in English.java.lang.StringgetName(int nameId, int platformId, int encodingId, int languageId)Returns a name from the table, or null it it does not exist.java.util.List<NameRecord>getNameRecords()This will get the name records for this naming table.java.lang.StringgetPostScriptName()Returns the PostScript name.private static booleanisUsefulForOnlyHeaders(NameRecord nr)(package private) voidread(TrueTypeFont ttf, TTFDataStream data)This will read the required data from the stream.private voidread(TrueTypeFont ttf, TTFDataStream data, boolean onlyHeaders)(package private) voidreadHeaders(TrueTypeFont ttf, TTFDataStream data, FontHeaders outHeaders)This will read required headers from the stream into outHeaders.private voidreadInterestingStrings()-
Methods inherited from class org.apache.fontbox.ttf.TTFTable
getCheckSum, getInitialized, getLength, getOffset, getTag, setCheckSum, setLength, setOffset, setTag
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
A tag that identifies this table type.- See Also:
- Constant Field Values
-
nameRecords
private java.util.List<NameRecord> nameRecords
-
lookupTable
private java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.String>>>> lookupTable
-
fontFamily
private java.lang.String fontFamily
-
fontSubFamily
private java.lang.String fontSubFamily
-
psName
private java.lang.String psName
-
-
Method Detail
-
read
void read(TrueTypeFont ttf, TTFDataStream data) throws java.io.IOException
This will read the required data from the stream.
-
readHeaders
void readHeaders(TrueTypeFont ttf, TTFDataStream data, FontHeaders outHeaders) throws java.io.IOException
This will read required headers from the stream into outHeaders.- Overrides:
readHeadersin classTTFTable- Parameters:
ttf- The font that is being read.data- The stream to read the data from.outHeaders- The class to write the data to.- Throws:
java.io.IOException- If there is an error reading the data.
-
read
private void read(TrueTypeFont ttf, TTFDataStream data, boolean onlyHeaders) throws java.io.IOException
- Throws:
java.io.IOException
-
getCharset
private java.nio.charset.Charset getCharset(NameRecord nr)
-
fillLookupTable
private void fillLookupTable()
-
readInterestingStrings
private void readInterestingStrings()
-
isUsefulForOnlyHeaders
private static boolean isUsefulForOnlyHeaders(NameRecord nr)
-
getEnglishName
private java.lang.String getEnglishName(int nameId)
Helper to get English names by best effort.
-
getName
public java.lang.String getName(int nameId, int platformId, int encodingId, int languageId)Returns a name from the table, or null it it does not exist.- Parameters:
nameId- Name ID from NameRecord constants.platformId- Platform ID from NameRecord constants.encodingId- Platform Encoding ID from NameRecord constants.languageId- Language ID from NameRecord constants.- Returns:
- name, or null
-
getNameRecords
public java.util.List<NameRecord> getNameRecords()
This will get the name records for this naming table.- Returns:
- A list of NameRecord objects.
-
getFontFamily
public java.lang.String getFontFamily()
Returns the font family name, in English.- Returns:
- the font family name, in English
-
getFontSubFamily
public java.lang.String getFontSubFamily()
Returns the font sub family name, in English.- Returns:
- the font sub family name, in English
-
getPostScriptName
public java.lang.String getPostScriptName()
Returns the PostScript name.- Returns:
- the PostScript name
-
-