Package com.lowagie.text.pdf
Class TrueTypeFont
java.lang.Object
com.lowagie.text.pdf.BaseFont
com.lowagie.text.pdf.TrueTypeFont
- Direct Known Subclasses:
EnumerateTTC,TrueTypeFontUnicode
Deprecated.
Reads a Truetype font
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classDeprecated.The components of table 'head'.protected static classDeprecated.The components of table 'hhea'.protected static classDeprecated.The components of table 'OS/2'.Nested classes/interfaces inherited from class com.lowagie.text.pdf.BaseFont
BaseFont.StreamFont -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[][]Deprecated.All the names of the Names-Tableprotected int[][]Deprecated.protected booleanDeprecated.protected intDeprecated.protected intDeprecated.Deprecated.The map containing the code information for the table 'cmap', encoding 1.0.Deprecated.The map containing the code information for the table 'cmap', encoding 3.1 in Unicode.Deprecated.(package private) static final String[]Deprecated.The code pages possible for a True Type font.protected intDeprecated.The offset from the start of the file to the table directory.protected String[][]Deprecated.The family name of the fontprotected StringDeprecated.The file name.protected StringDeprecated.The font name.protected String[][]Deprecated.The full name of the fontprotected int[]Deprecated.The width of the glyphs.protected TrueTypeFont.FontHeaderDeprecated.The content of table 'head'.protected TrueTypeFont.HorizontalHeaderDeprecated.The content of table 'hhea'.protected booleanDeprecated.trueif all the glyphs have the same width.protected doubleDeprecated.The italic angle.protected booleanDeprecated.protected IntHashtableDeprecated.The map containing the kerning information.protected TrueTypeFont.WindowsMetricsDeprecated.The content of table 'OS/2'.protected RandomAccessFileOrArrayDeprecated.The file in use.protected StringDeprecated.The style modifierDeprecated.Contains the location of the several tables.protected StringDeprecated.The index for the TTC font.protected intDeprecated.protected intDeprecated.Fields inherited from class com.lowagie.text.pdf.BaseFont
ASCENT, AWT_ASCENT, AWT_DESCENT, AWT_LEADING, AWT_MAXADVANCE, BBOXLLX, BBOXLLY, BBOXURX, BBOXURY, BuiltinFonts14, CACHED, CAPHEIGHT, CHAR_RANGE_ARABIC, CHAR_RANGE_CYRILLIC, CHAR_RANGE_HEBREW, CHAR_RANGE_LATIN, charBBoxes, CID_NEWLINE, compressionLevel, COURIER, COURIER_BOLD, COURIER_BOLDOBLIQUE, COURIER_OBLIQUE, CP1250, CP1252, CP1257, DESCENT, differences, directTextToByte, embedded, EMBEDDED, encoding, fastWinansi, FONT_TYPE_CJK, FONT_TYPE_DOCUMENT, FONT_TYPE_T1, FONT_TYPE_T3, FONT_TYPE_TT, FONT_TYPE_TTUNI, fontCache, fontSpecific, fontType, forceWidthsOutput, HELVETICA, HELVETICA_BOLD, HELVETICA_BOLDOBLIQUE, HELVETICA_OBLIQUE, IDENTITY_H, IDENTITY_V, includeCidSet, ITALICANGLE, MACROMAN, NOT_CACHED, NOT_EMBEDDED, notdef, RESOURCE_PATH, secureRandom, specialMap, STRIKETHROUGH_POSITION, STRIKETHROUGH_THICKNESS, SUBSCRIPT_OFFSET, SUBSCRIPT_SIZE, subset, subsetRanges, SUPERSCRIPT_OFFSET, SUPERSCRIPT_SIZE, SYMBOL, TIMES_BOLD, TIMES_BOLDITALIC, TIMES_ITALIC, TIMES_ROMAN, UNDERLINE_POSITION, UNDERLINE_THICKNESS, unicodeDifferences, widths, WINANSI, ZAPFDINGBATS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated.This constructor is present to allow extending the class.(package private)TrueTypeFont(String ttFile, String enc, boolean emb, byte[] ttfAfm, boolean justNames, boolean forceRead) Deprecated.Creates a new TrueType font. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddRangeUni(Map<Integer, int[]> longTag, boolean includeMetrics, boolean subsetp) Deprecated.(package private) voidcheckCff()Deprecated.protected static int[]compactRanges(ArrayList ranges) Deprecated.(package private) voidDeprecated.Reads the tables 'head', 'hhea', 'OS/2' and 'post' filling several variables.String[][]Deprecated.Gets all the entries of the Names-Table.(package private) String[][]Deprecated.Extracts all the names of the names-Table(package private) StringDeprecated.Gets the Postscript font name.String[]Deprecated.Gets the code pages supported by the font.String[][]Deprecated.Gets the family name of the font.protected PdfDictionarygetFontBaseType(PdfIndirectReference fontDescriptor, String subsetPrefix, int firstChar, int lastChar, byte[] shortTag) Deprecated.Generates the font dictionary for this font.floatgetFontDescriptor(int key, float fontSize) Deprecated.Gets the font parameter identified bykey.protected PdfDictionarygetFontDescriptor(PdfIndirectReference fontStream, String subsetPrefix, PdfIndirectReference cidset) Deprecated.Generates the font descriptor for this font.protected byte[]Deprecated.String[][]Deprecated.Gets the full name of the font.Deprecated.Returns a PdfStream object with the full font program.protected intgetGlyphWidth(int glyph) Deprecated.Gets a glyph width.intgetKerning(int char1, int char2) Deprecated.Gets the kerning between two Unicode chars.int[]getMetricsTT(int c) Deprecated.Gets the glyph index and metrics for a character.(package private) String[][]getNames(int id) Deprecated.Extracts the names of the font in all the languages available.Deprecated.Gets the postscript font name.protected int[]getRawCharBBox(int c, String name) Deprecated.(package private) intgetRawWidth(int c, String name) Deprecated.Gets the width from the font according to the unicode charc.protected static StringgetTTCName(String name) Deprecated.Gets the name from a composed TTC file name.booleanDeprecated.Checks if the font has any kerning pairs.(package private) voidprocess(byte[] ttfAfm, boolean preload) Deprecated.Reads the font data.private voidreadBbox()Deprecated.protected byte[]Deprecated.If this font file is using the Compact Font File Format, then this method will return the raw bytes needed for the font stream.(package private) voidDeprecated.Reads the several maps from the table 'cmap'.Deprecated.The information in the maps of the table 'cmap' is coded in several formats.Deprecated.Deprecated.The information in the maps of the table 'cmap' is coded in several formats.Deprecated.The information in the maps of the table 'cmap' is coded in several formats.protected voidDeprecated.Reads the glyphs widths.(package private) voidDeprecated.Reads the kerning information from the 'kern' table.protected StringreadStandardString(int length) Deprecated.Reads aStringfrom the font file as bytes using the Cp1252 encoding.protected StringreadUnicodeString(int length) Deprecated.Reads a UnicodeStringfrom the font file.booleansetKerning(int char1, int char2, int kern) Deprecated.Sets the kerning between two Unicode chars.voidsetPostscriptFontName(String name) Deprecated.Sets the font name that will appear in the pdf font dictionary.(package private) voidwriteFont(PdfWriter writer, PdfIndirectReference ref, Object[] params) Deprecated.Outputs to the writer the font dictionaries and streams.Methods inherited from class com.lowagie.text.pdf.BaseFont
addSubsetRange, charExists, convertToBytes, convertToBytes, correctArabicAdvance, createEncoding, createFont, createFont, createFont, createFont, createFont, createFont, createFont, createSubsetPrefix, enumerateTTCNames, enumerateTTCNames, getAllFontNames, getAllNameEntries, getAscent, getAscentPoint, getBaseName, getCharBBox, getCidCode, getCompressionLevel, getDescent, getDescentPoint, getDifferences, getDocumentFonts, getDocumentFonts, getEncoding, getFontType, getFullFontName, getResourceStream, getResourceStream, getSecureRandom, getUnicodeDifferences, getUnicodeDifferences, getUnicodeEquivalent, getWidth, getWidth, getWidthPoint, getWidthPoint, getWidthPointKerned, getWidths, isDirectTextToByte, isEmbedded, isFontSpecific, isForceWidthsOutput, isIncludeCidSet, isSubset, normalizeEncoding, setCharAdvance, setCompressionLevel, setDirectTextToByte, setForceWidthsOutput, setIncludeCidSet, setSecureRandom, setSubset
-
Field Details
-
codePages
Deprecated.The code pages possible for a True Type font. -
justNames
protected boolean justNamesDeprecated. -
tables
Deprecated.Contains the location of the several tables. The key is the name of the table and the value is anint[2]where position 0 is the offset from the start of the file and position 1 is the length of the table. -
rf
Deprecated.The file in use. -
fileName
Deprecated.The file name. -
cff
protected boolean cffDeprecated. -
cffOffset
protected int cffOffsetDeprecated. -
cffLength
protected int cffLengthDeprecated. -
directoryOffset
protected int directoryOffsetDeprecated.The offset from the start of the file to the table directory. It is 0 for TTF and may vary for TTC depending on the chosen font. -
ttcIndex
Deprecated.The index for the TTC font. It is an emptyStringfor a TTF file. -
style
Deprecated.The style modifier -
head
Deprecated.The content of table 'head'. -
hhea
Deprecated.The content of table 'hhea'. -
os_2
Deprecated.The content of table 'OS/2'. -
GlyphWidths
protected int[] GlyphWidthsDeprecated.The width of the glyphs. This is essentially the content of table 'hmtx' normalized to 1000 units. -
bboxes
protected int[][] bboxesDeprecated. -
cmap10
Deprecated.The map containing the code information for the table 'cmap', encoding 1.0. The key is the code and the value is anint[2]where position 0 is the glyph number and position 1 is the glyph width normalized to 1000 units. -
cmap31
Deprecated.The map containing the code information for the table 'cmap', encoding 3.1 in Unicode.The key is the code and the value is an
int[2] where position 0 is the glyph number and position 1 is the glyph width normalized to 1000 units. -
cmapExt
Deprecated. -
kerning
Deprecated.The map containing the kerning information. It represents the content of table 'kern'. The key is anIntegerwhere the top 16 bits are the glyph number for the first character and the lower 16 bits are the glyph number for the second character. The value is the amount of kerning in normalized 1000 units as anInteger. This value is usually negative. -
fontName
Deprecated.The font name. This name is usually extracted from the table 'name' with the 'Name ID' 6. -
fullName
Deprecated.The full name of the font -
allNameEntries
Deprecated.All the names of the Names-Table -
familyName
Deprecated.The family name of the font -
italicAngle
protected double italicAngleDeprecated.The italic angle. It is usually extracted from the 'post' table or in it's absence with the code:-Math.atan2(hhea.caretSlopeRun, hhea.caretSlopeRise) * 180 / Math.PI
-
isFixedPitch
protected boolean isFixedPitchDeprecated.trueif all the glyphs have the same width. -
underlinePosition
protected int underlinePositionDeprecated. -
underlineThickness
protected int underlineThicknessDeprecated.
-
-
Constructor Details
-
TrueTypeFont
protected TrueTypeFont()Deprecated.This constructor is present to allow extending the class. -
TrueTypeFont
TrueTypeFont(String ttFile, String enc, boolean emb, byte[] ttfAfm, boolean justNames, boolean forceRead) throws DocumentException, IOException Deprecated.Creates a new TrueType font.- Parameters:
ttFile- the location of the font on file. The file must end in '.ttf' or '.ttc' but can have modifiers after the nameenc- the encoding to be applied to this fontemb- true if the font is to be embedded in the PDFttfAfm- the font as abytearray- Throws:
DocumentException- the font is invalidIOException- the font file could not be read- Since:
- 2.1.5
-
-
Method Details
-
getTTCName
Deprecated.Gets the name from a composed TTC file name. If I have for input "myfont.ttc,2" the return will be "myfont.ttc".- Parameters:
name- the full name- Returns:
- the simple file name
-
compactRanges
Deprecated. -
fillTables
Deprecated.Reads the tables 'head', 'hhea', 'OS/2' and 'post' filling several variables.- Throws:
DocumentException- the font is invalidIOException- the font file could not be read
-
getBaseFont
Deprecated.Gets the Postscript font name.- Returns:
- the Postscript font name
- Throws:
DocumentException- the font is invalidIOException- the font file could not be read
-
getNames
Deprecated.Extracts the names of the font in all the languages available.- Parameters:
id- the name id to retrieve- Throws:
DocumentException- on errorIOException- on error
-
getAllNames
Deprecated.Extracts all the names of the names-Table- Throws:
DocumentException- on errorIOException- on error
-
checkCff
void checkCff()Deprecated. -
process
Deprecated.Reads the font data.- Parameters:
ttfAfm- the font as abytearray, possiblynull- Throws:
DocumentException- the font is invalidIOException- the font file could not be read- Since:
- 2.1.5
-
readStandardString
Deprecated.Reads aStringfrom the font file as bytes using the Cp1252 encoding.- Parameters:
length- the length of bytes to read- Returns:
- the
Stringread - Throws:
IOException- the font file could not be read
-
readUnicodeString
Deprecated.Reads a UnicodeStringfrom the font file. Each character is represented by two bytes.- Parameters:
length- the length of bytes to read. TheStringwill havelength/2 characters- Returns:
- the
Stringread - Throws:
IOException- the font file could not be read
-
readGlyphWidths
Deprecated.Reads the glyphs widths. The widths are extracted from the table 'hmtx'. The glyphs are normalized to 1000 units.- Throws:
DocumentException- the font is invalidIOException- the font file could not be read
-
getGlyphWidth
protected int getGlyphWidth(int glyph) Deprecated.Gets a glyph width.- Parameters:
glyph- the glyph to get the width of- Returns:
- the width of the glyph in normalized 1000 units
-
readBbox
Deprecated.- Throws:
DocumentExceptionIOException
-
readCMaps
Deprecated.Reads the several maps from the table 'cmap'. The maps of interest are 1.0 for symbolic fonts and 3.1 for all others. A symbolic font is defined as having the map 3.0.- Throws:
DocumentException- the font is invalidIOException- the font file could not be read
-
readFormat12
Deprecated.- Throws:
IOException
-
readFormat0
Deprecated.The information in the maps of the table 'cmap' is coded in several formats. Format 0 is the Apple standard character to glyph index mapping table.- Returns:
- a
HashMaprepresenting this map - Throws:
IOException- the font file could not be read
-
readFormat4
Deprecated.The information in the maps of the table 'cmap' is coded in several formats. Format 4 is the Microsoft standard character to glyph index mapping table.- Returns:
- a
HashMaprepresenting this map - Throws:
IOException- the font file could not be read
-
readFormat6
Deprecated.The information in the maps of the table 'cmap' is coded in several formats. Format 6 is a trimmed table mapping. It is similar to format 0 but can have less than 256 entries.- Returns:
- a
HashMaprepresenting this map - Throws:
IOException- the font file could not be read
-
readKerning
Deprecated.Reads the kerning information from the 'kern' table.- Throws:
IOException- the font file could not be read
-
getKerning
public int getKerning(int char1, int char2) Deprecated.Gets the kerning between two Unicode chars.- Specified by:
getKerningin classBaseFont- Parameters:
char1- the first charchar2- the second char- Returns:
- the kerning to be applied
-
getRawWidth
Deprecated.Gets the width from the font according to the unicode charc. If thenameis null it's a symbolic font.- Specified by:
getRawWidthin classBaseFont- Parameters:
c- the unicode charname- the glyph name- Returns:
- the width of the char
-
getFontDescriptor
protected PdfDictionary getFontDescriptor(PdfIndirectReference fontStream, String subsetPrefix, PdfIndirectReference cidset) Deprecated.Generates the font descriptor for this font.- Parameters:
subsetPrefix- the subset prefixfontStream- the indirect reference to a PdfStream containing the font ornull- Returns:
- the PdfDictionary containing the font descriptor or
null
-
getFontBaseType
protected PdfDictionary getFontBaseType(PdfIndirectReference fontDescriptor, String subsetPrefix, int firstChar, int lastChar, byte[] shortTag) Deprecated.Generates the font dictionary for this font.- Parameters:
subsetPrefix- the subset prefixfirstChar- the first valid characterlastChar- the last valid charactershortTag- a 256 bytes longbytearray where each unused byte is represented by 0fontDescriptor- the indirect reference to a PdfDictionary containing the font descriptor ornull- Returns:
- the PdfDictionary containing the font dictionary
-
getFullFont
Deprecated.- Throws:
IOException
-
addRangeUni
Deprecated. -
writeFont
void writeFont(PdfWriter writer, PdfIndirectReference ref, Object[] params) throws DocumentException, IOException Deprecated.Outputs to the writer the font dictionaries and streams.- Specified by:
writeFontin classBaseFont- Parameters:
writer- the writer for this documentref- the font indirect referenceparams- several parameters that depend on the font type- Throws:
IOException- on errorDocumentException- error in generating the object
-
readCffFont
Deprecated.If this font file is using the Compact Font File Format, then this method will return the raw bytes needed for the font stream. If this method is ever made public: make sure to add a test if (cff == true).- Returns:
- a byte array
- Throws:
IOException- Since:
- 2.1.3
-
getFullFontStream
Deprecated.Returns a PdfStream object with the full font program.- Specified by:
getFullFontStreamin classBaseFont- Returns:
- a PdfStream with the font program
- Throws:
IOException- on errorDocumentException- on error- Since:
- 2.1.3
-
getFontDescriptor
public float getFontDescriptor(int key, float fontSize) Deprecated.Gets the font parameter identified bykey. Valid values forkeyareASCENT,CAPHEIGHT,DESCENTandITALICANGLE.- Specified by:
getFontDescriptorin classBaseFont- Parameters:
key- the parameter to be extractedfontSize- the font size in points- Returns:
- the parameter in points
-
getMetricsTT
public int[] getMetricsTT(int c) Deprecated.Gets the glyph index and metrics for a character.- Parameters:
c- the character- Returns:
- an
intarray with {glyph index, width}
-
getPostscriptFontName
Deprecated.Gets the postscript font name.- Specified by:
getPostscriptFontNamein classBaseFont- Returns:
- the postscript font name
-
setPostscriptFontName
Deprecated.Sets the font name that will appear in the pdf font dictionary. Use with care as it can easily make a font unreadable if not embedded.- Specified by:
setPostscriptFontNamein classBaseFont- Parameters:
name- the new font name
-
getCodePagesSupported
Deprecated.Gets the code pages supported by the font.- Overrides:
getCodePagesSupportedin classBaseFont- Returns:
- the code pages supported by the font
-
getFullFontName
Deprecated.Gets the full name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.- Specified by:
getFullFontNamein classBaseFont- Returns:
- the full name of the font
-
getAllNameEntries
Deprecated.Gets all the entries of the Names-Table. If it is a True Type font each array element will have {Name ID, Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.- Specified by:
getAllNameEntriesin classBaseFont- Returns:
- the full name of the font
-
getFamilyFontName
Deprecated.Gets the family name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.- Specified by:
getFamilyFontNamein classBaseFont- Returns:
- the family name of the font
-
hasKernPairs
public boolean hasKernPairs()Deprecated.Checks if the font has any kerning pairs.- Specified by:
hasKernPairsin classBaseFont- Returns:
trueif the font has any kerning pairs
-
setKerning
public boolean setKerning(int char1, int char2, int kern) Deprecated.Sets the kerning between two Unicode chars.- Specified by:
setKerningin classBaseFont- Parameters:
char1- the first charchar2- the second charkern- the kerning to apply in normalized 1000 units- Returns:
trueif the kerning was applied,falseotherwise
-
getRawCharBBox
Deprecated.- Specified by:
getRawCharBBoxin classBaseFont
-