com.lowagie.text.pdf
class TrueTypeFont extends BaseFont
Nested Class Summary | |
---|---|
protected static class | TrueTypeFont.FontHeader The components of table 'head'. |
protected static class | TrueTypeFont.HorizontalHeader The components of table 'hhea'. |
protected static class | TrueTypeFont.WindowsMetrics The components of table 'OS/2'. |
Field Summary | |
---|---|
protected String[][] | allNameEntries All the names of the Names-Table |
protected int[][] | bboxes |
protected boolean | cff |
protected int | cffLength |
protected int | cffOffset |
protected HashMap | cmap10 The map containing the code information for the table 'cmap', encoding 1.0.
|
protected HashMap | cmap31 The map containing the code information for the table 'cmap', encoding 3.1
in Unicode.
|
protected HashMap | cmapExt |
static String[] | codePages The code pages possible for a True Type font. |
protected int | directoryOffset The offset from the start of the file to the table directory.
|
protected String[][] | familyName The family name of the font |
protected String | fileName The file name. |
protected String | fontName
The font name.
|
protected String[][] | fullName The full name of the font |
protected int[] | GlyphWidths The width of the glyphs. |
protected TrueTypeFont.FontHeader | head The content of table 'head'. |
protected TrueTypeFont.HorizontalHeader | hhea The content of table 'hhea'. |
protected boolean | isFixedPitchtrue if all the glyphs have the same width. |
protected double | italicAngle The italic angle. |
protected boolean | justNames |
protected IntHashtable | kerning The map containing the kerning information. |
protected TrueTypeFont.WindowsMetrics | os_2 The content of table 'OS/2'. |
protected RandomAccessFileOrArray | rf The file in use. |
protected String | style The style modifier |
protected HashMap | tables Contains the location of the several tables. |
protected String | ttcIndex The index for the TTC font. |
protected int | underlinePosition |
protected int | underlineThickness |
Constructor Summary | |
---|---|
protected | TrueTypeFont() This constructor is present to allow extending the class. |
TrueTypeFont(String ttFile, String enc, boolean emb, byte[] ttfAfm) | |
TrueTypeFont(String ttFile, String enc, boolean emb, byte[] ttfAfm, boolean justNames) Creates a new TrueType font. |
Method Summary | |
---|---|
protected void | addRangeUni(HashMap longTag, boolean includeMetrics, boolean subsetp) |
void | checkCff() |
protected static int[] | compactRanges(ArrayList ranges) |
void | fillTables()
Reads the tables 'head', 'hhea', 'OS/2' and 'post' filling several variables. |
String[][] | getAllNameEntries() Gets all the entries of the Names-Table. |
String[][] | getAllNames() Extracts all the names of the names-Table |
String | getBaseFont()
Gets the Postscript font name. |
String[] | getCodePagesSupported() Gets the code pages supported by the font. |
String[][] | getFamilyFontName() Gets the family name of the font. |
protected PdfDictionary | getFontBaseType(PdfIndirectReference fontDescriptor, String subsetPrefix, int firstChar, int lastChar, byte[] shortTag) Generates the font dictionary for this font. |
protected PdfDictionary | getFontDescriptor(PdfIndirectReference fontStream, String subsetPrefix, PdfIndirectReference cidset) Generates the font descriptor for this font. |
float | getFontDescriptor(int key, float fontSize) Gets the font parameter identified by key . |
protected byte[] | getFullFont() |
String[][] | getFullFontName() Gets the full name of the font. |
PdfStream | getFullFontStream()
Returns a PdfStream object with the full font program. |
protected int | getGlyphWidth(int glyph) Gets a glyph width. |
int | getKerning(int char1, int char2) Gets the kerning between two Unicode chars. |
int[] | getMetricsTT(int c) Gets the glyph index and metrics for a character. |
String[][] | getNames(int id) Extracts the names of the font in all the languages available. |
String | getPostscriptFontName() Gets the postscript font name. |
protected int[] | getRawCharBBox(int c, String name) |
int | getRawWidth(int c, String name) Gets the width from the font according to the unicode char c .
|
protected static String | getTTCName(String name) Gets the name from a composed TTC file name.
|
boolean | hasKernPairs() Checks if the font has any kerning pairs. |
void | process(byte[] ttfAfm) Reads the font data. |
void | readBbox() |
protected byte[] | readCffFont()
If this font file is using the Compact Font File Format, then this method
will return the raw bytes needed for the font stream. |
void | readCMaps() Reads the several maps from the table 'cmap'. |
HashMap | readFormat0() The information in the maps of the table 'cmap' is coded in several formats.
|
HashMap | readFormat12() |
HashMap | readFormat4() The information in the maps of the table 'cmap' is coded in several formats.
|
HashMap | readFormat6() The information in the maps of the table 'cmap' is coded in several formats.
|
protected void | readGlyphWidths() Reads the glyphs widths. |
void | readKerning() Reads the kerning information from the 'kern' table. |
protected String | readStandardString(int length) Reads a String from the font file as bytes using the Cp1252
encoding. |
protected String | readUnicodeString(int length) Reads a Unicode String from the font file. |
boolean | setKerning(int char1, int char2, int kern)
Sets the kerning between two Unicode chars. |
void | setPostscriptFontName(String name)
Sets the font name that will appear in the pdf font dictionary.
|
void | writeFont(PdfWriter writer, PdfIndirectReference ref, Object[] params) Outputs to the writer the font dictionaries and streams. |
int[2]
where position 0
is the glyph number and position 1 is the glyph width normalized to 1000
units.
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.
true
if all the glyphs have the same width.
-Math.atan2(hhea.caretSlopeRun, hhea.caretSlopeRise) * 180 / Math.PI
Integer
where 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 an Integer
. This value is usually negative.int[2]
where position 0
is the offset from the start of the file and position 1 is the length
of the table.String
for a
TTF file.Parameters: ttFile the location of the font on file. The file must end in '.ttf' or
'.ttc' but can have modifiers after the name enc the encoding to be applied to this font emb true if the font is to be embedded in the PDF ttfAfm the font as a byte
array
Throws: DocumentException the font is invalid IOException the font file could not be read
Throws: DocumentException the font is invalid IOException the font file could not be read
Returns: the full name of the font
Throws: DocumentException on error IOException on error
Returns: the Postscript font name
Throws: DocumentException the font is invalid IOException the font file could not be read
Returns: the code pages supported by the font
Returns: the family name of the font
Parameters: subsetPrefix the subset prefx firstChar the first valid character lastChar the last valid character shortTag a 256 bytes long byte
array where each unused byte is represented by 0 fontDescriptor the indirect reference to a PdfDictionary containing the font descriptor or null
Returns: the PdfDictionary containing the font dictionary
Throws: DocumentException if there is an error
Parameters: subsetPrefix the subset prefix fontStream the indirect reference to a PdfStream containing the font or null
Returns: the PdfDictionary containing the font descriptor or null
Throws: DocumentException if there is an error
key
. Valid values
for key
are ASCENT
, CAPHEIGHT
, DESCENT
and ITALICANGLE
.Parameters: key the parameter to be extracted fontSize the font size in points
Returns: the parameter in points
Returns: the full name of the font
Returns: a PdfStream with the font program
Since: 2.1.3
Parameters: glyph the glyph to get the width of
Returns: the width of the glyph in normalized 1000 units
Parameters: char1 the first char char2 the second char
Returns: the kerning to be applied
Parameters: c the character
Returns: an int
array with {glyph index, width}
Parameters: id the name id to retrieve
Throws: DocumentException on error IOException on error
Returns: the postscript font name
c
.
If the name
is null it's a symbolic font.Parameters: c the unicode char name the glyph name
Returns: the width of the char
Parameters: name the full name
Returns: the simple file name
Returns: true
if the font has any kerning pairs
Parameters: ttfAfm the font as a byte
array, possibly null
Throws: DocumentException the font is invalid IOException the font file could not be read
Returns: a byte array
Since: 2.1.3
Throws: DocumentException the font is invalid IOException the font file could not be read
Returns: a HashMap
representing this map
Throws: IOException the font file could not be read
Returns: a HashMap
representing this map
Throws: IOException the font file could not be read
Returns: a HashMap
representing this map
Throws: IOException the font file could not be read
Throws: DocumentException the font is invalid IOException the font file could not be read
Throws: IOException the font file could not be read
String
from the font file as bytes using the Cp1252
encoding.Parameters: length the length of bytes to read
Returns: the String
read
Throws: IOException the font file could not be read
String
from the font file. Each character is
represented by two bytes.Parameters: length the length of bytes to read. The String
will have length
/2
characters
Returns: the String
read
Throws: IOException the font file could not be read
Parameters: char1 the first char char2 the second char kern the kerning to apply in normalized 1000 units
Returns: true
if the kerning was applied, false
otherwise
Parameters: name the new font name
Parameters: writer the writer for this document ref the font indirect reference params several parameters that depend on the font type
Throws: IOException on error DocumentException error in generating the object