| java.lang.Object com.lowagie.text.pdf.BaseFont com.lowagie.text.pdf.TrueTypeFont
All known Subclasses: com.lowagie.text.pdf.EnumerateTTC, com.lowagie.text.pdf.TrueTypeFontUnicode,
TrueTypeFont | class TrueTypeFont extends BaseFont (Code) | | Reads a Truetype font
author: Paulo Soares (psoares@consiste.pt) |
Inner Class :protected static class FontHeader | |
Inner Class :protected static class HorizontalHeader | |
Inner Class :protected static class WindowsMetrics | |
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.
Parameters: ttFile - the location of the font on file. |
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 | getBaseFont() Gets the Postscript font name. | public String[] | getCodePagesSupported() Gets the code pages supported by the font. | public 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) Generates the font descriptor for this font. | public float | getFontDescriptor(int key, float fontSize) Gets the font parameter identified by key . | protected byte[] | getFullFont() | public String[][] | getFullFontName() Gets the full name of the font. | protected int | getGlyphWidth(int glyph) Gets a glyph width. | public int | getKerning(char char1, char char2) Gets the kerning between two Unicode chars. | public 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. | public 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. | public boolean | hasKernPairs() Checks if the font has any kerning pairs. | void | process(byte ttfAfm) Reads the font data. | 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 | 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.
Format 6 is a trimmed table mapping. | 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. | public boolean | setKerning(char char1, char char2, int kern) Sets the kerning between two Unicode chars. | public 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. |
GlyphWidths | protected int GlyphWidths(Code) | | The width of the glyphs. This is essentially the content of table
'hmtx' normalized to 1000 units.
|
bboxes | protected int bboxes(Code) | | |
cff | protected boolean cff(Code) | | |
cffLength | protected int cffLength(Code) | | |
cffOffset | protected int cffOffset(Code) | | |
cmap10 | protected HashMap cmap10(Code) | | The map containing the code information for the table 'cmap', encoding 1.0.
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.
|
cmap31 | protected HashMap cmap31(Code) | | 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.
|
codePages | final static String codePages(Code) | | The code pages possible for a True Type font.
|
directoryOffset | protected int directoryOffset(Code) | | 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.
|
familyName | protected String familyName(Code) | | The family name of the font
|
fontName | protected String fontName(Code) | | The font name.
This name is usually extracted from the table 'name' with
the 'Name ID' 6.
|
fullName | protected String fullName(Code) | | The full name of the font
|
head | protected FontHeader head(Code) | | The content of table 'head'.
|
hhea | protected HorizontalHeader hhea(Code) | | The content of table 'hhea'.
|
isFixedPitch | protected boolean isFixedPitch(Code) | | true if all the glyphs have the same width.
|
italicAngle | protected double italicAngle(Code) | | 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
|
justNames | protected boolean justNames(Code) | | |
kerning | protected IntHashtable kerning(Code) | | The map containing the kerning information. It represents the content of
table 'kern'. The key is an 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.
|
os_2 | protected WindowsMetrics os_2(Code) | | The content of table 'OS/2'.
|
tables | protected HashMap tables(Code) | | Contains the location of the several tables. The key is the name of
the table and the value is an int[2] where position 0
is the offset from the start of the file and position 1 is the length
of the table.
|
ttcIndex | protected String ttcIndex(Code) | | The index for the TTC font. It is an empty String for a
TTF file.
|
TrueTypeFont | protected TrueTypeFont()(Code) | | This constructor is present to allow extending the class.
|
TrueTypeFont | TrueTypeFont(String ttFile, String enc, boolean emb, byte ttfAfm, boolean justNames) throws DocumentException, IOException(Code) | | 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 name Parameters: enc - the encoding to be applied to this font Parameters: emb - true if the font is to be embedded in the PDF Parameters: ttfAfm - the font as a byte array throws: DocumentException - the font is invalid throws: IOException - the font file could not be read |
addRangeUni | protected void addRangeUni(HashMap longTag, boolean includeMetrics, boolean subsetp)(Code) | | |
checkCff | void checkCff()(Code) | | |
getCodePagesSupported | public String[] getCodePagesSupported()(Code) | | Gets the code pages supported by the font.
the code pages supported by the font |
getFamilyFontName | public String[][] getFamilyFontName()(Code) | | 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}.
the family name of the font |
getFontBaseType | protected PdfDictionary getFontBaseType(PdfIndirectReference fontDescriptor, String subsetPrefix, int firstChar, int lastChar, byte shortTag)(Code) | | Generates the font dictionary for this font.
the PdfDictionary containing the font dictionary Parameters: subsetPrefix - the subset prefx Parameters: firstChar - the first valid character Parameters: lastChar - the last valid character Parameters: shortTag - a 256 bytes long byte array where each unused byte is represented by 0 Parameters: fontDescriptor - the indirect reference to a PdfDictionary containing the font descriptor or null throws: DocumentException - if there is an error |
getFontDescriptor | protected PdfDictionary getFontDescriptor(PdfIndirectReference fontStream, String subsetPrefix)(Code) | | Generates the font descriptor for this font.
the PdfDictionary containing the font descriptor or null Parameters: subsetPrefix - the subset prefix Parameters: fontStream - the indirect reference to a PdfStream containing the font or null throws: DocumentException - if there is an error |
getFontDescriptor | public float getFontDescriptor(int key, float fontSize)(Code) | | Gets the font parameter identified by key . Valid values
for key are ASCENT , CAPHEIGHT , DESCENT
and ITALICANGLE .
Parameters: key - the parameter to be extracted Parameters: fontSize - the font size in points the parameter in points |
getFullFontName | public String[][] getFullFontName()(Code) | | 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}.
the full name of the font |
getGlyphWidth | protected int getGlyphWidth(int glyph)(Code) | | Gets a glyph width.
Parameters: glyph - the glyph to get the width of the width of the glyph in normalized 1000 units |
getKerning | public int getKerning(char char1, char char2)(Code) | | Gets the kerning between two Unicode chars.
Parameters: char1 - the first char Parameters: char2 - the second char the kerning to be applied |
getMetricsTT | public int[] getMetricsTT(int c)(Code) | | Gets the glyph index and metrics for a character.
Parameters: c - the character an int array with {glyph index, width} |
getPostscriptFontName | public String getPostscriptFontName()(Code) | | Gets the postscript font name.
the postscript font name |
getRawCharBBox | protected int[] getRawCharBBox(int c, String name)(Code) | | |
getRawWidth | int getRawWidth(int c, String name)(Code) | | Gets the width from the font according to the unicode char c .
If the name is null it's a symbolic font.
Parameters: c - the unicode char Parameters: name - the glyph name the width of the char |
getTTCName | protected static String getTTCName(String name)(Code) | | 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 the simple file name |
hasKernPairs | public boolean hasKernPairs()(Code) | | Checks if the font has any kerning pairs.
true if the font has any kerning pairs |
readCMaps | void readCMaps() throws DocumentException, IOException(Code) | | 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 invalid throws: IOException - the font file could not be read |
readFormat0 | HashMap readFormat0() throws IOException(Code) | | 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.
a HashMap representing this map throws: IOException - the font file could not be read |
readFormat4 | HashMap readFormat4() throws IOException(Code) | | 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.
a HashMap representing this map throws: IOException - the font file could not be read |
readFormat6 | HashMap readFormat6() throws IOException(Code) | | 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.
a HashMap representing this map throws: IOException - the font file could not be read |
readKerning | void readKerning() throws IOException(Code) | | Reads the kerning information from the 'kern' table.
throws: IOException - the font file could not be read |
readStandardString | protected String readStandardString(int length) throws IOException(Code) | | Reads a String from the font file as bytes using the Cp1252
encoding.
Parameters: length - the length of bytes to read the String read throws: IOException - the font file could not be read |
readUnicodeString | protected String readUnicodeString(int length) throws IOException(Code) | | Reads a Unicode 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 /2characters the String read throws: IOException - the font file could not be read |
setKerning | public boolean setKerning(char char1, char char2, int kern)(Code) | | Sets the kerning between two Unicode chars.
Parameters: char1 - the first char Parameters: char2 - the second char Parameters: kern - the kerning to apply in normalized 1000 units true if the kerning was applied, false otherwise |
setPostscriptFontName | public void setPostscriptFontName(String name)(Code) | | 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.
Parameters: name - the new font name |
Methods inherited from com.lowagie.text.pdf.BaseFont | public void addSubsetRange(int[] range)(Code)(Java Doc) public boolean charExists(char c)(Code)(Java Doc) byte[] convertToBytes(String text)(Code)(Java Doc) byte[] convertToBytes(char char1)(Code)(Java Doc) public void correctArabicAdvance()(Code)(Java Doc) protected void createEncoding()(Code)(Java Doc) public static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException(Code)(Java Doc) public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm, byte pfb) throws DocumentException, IOException(Code)(Java Doc) public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm, byte pfb, boolean noThrow) throws DocumentException, IOException(Code)(Java Doc) public static BaseFont createFont(PRIndirectReference fontRef)(Code)(Java Doc) public static String createSubsetPrefix()(Code)(Java Doc) public static String[] enumerateTTCNames(String ttcFile) throws DocumentException, IOException(Code)(Java Doc) public static String[] enumerateTTCNames(byte ttcArray) throws DocumentException, IOException(Code)(Java Doc) public static Object[] getAllFontNames(String name, String encoding, byte ttfAfm) throws DocumentException, IOException(Code)(Java Doc) public int getAscent(String text)(Code)(Java Doc) public float getAscentPoint(String text, float fontSize)(Code)(Java Doc) protected static String getBaseName(String name)(Code)(Java Doc) public int[] getCharBBox(char c)(Code)(Java Doc) public char getCidCode(char c)(Code)(Java Doc) public String[] getCodePagesSupported()(Code)(Java Doc) public int getDescent(String text)(Code)(Java Doc) public float getDescentPoint(String text, float fontSize)(Code)(Java Doc) public String[] getDifferences()(Code)(Java Doc) public static ArrayList getDocumentFonts(PdfReader reader)(Code)(Java Doc) public static ArrayList getDocumentFonts(PdfReader reader, int page)(Code)(Java Doc) public String getEncoding()(Code)(Java Doc) abstract public String[][] getFamilyFontName()(Code)(Java Doc) abstract public float getFontDescriptor(int key, float fontSize)(Code)(Java Doc) public int getFontType()(Code)(Java Doc) abstract public String[][] getFullFontName()(Code)(Java Doc) public static String[][] getFullFontName(String name, String encoding, byte ttfAfm) throws DocumentException, IOException(Code)(Java Doc) abstract public int getKerning(char char1, char char2)(Code)(Java Doc) abstract public String getPostscriptFontName()(Code)(Java Doc) abstract protected int[] getRawCharBBox(int c, String name)(Code)(Java Doc) abstract int getRawWidth(int c, String name)(Code)(Java Doc) public static InputStream getResourceStream(String key)(Code)(Java Doc) public static InputStream getResourceStream(String key, ClassLoader loader)(Code)(Java Doc) char getUnicodeDifferences(int index)(Code)(Java Doc) public char[] getUnicodeDifferences()(Code)(Java Doc) public char getUnicodeEquivalent(char c)(Code)(Java Doc) public int getWidth(char char1)(Code)(Java Doc) public int getWidth(String text)(Code)(Java Doc) public float getWidthPoint(String text, float fontSize)(Code)(Java Doc) public float getWidthPoint(char char1, float fontSize)(Code)(Java Doc) public float getWidthPointKerned(String text, float fontSize)(Code)(Java Doc) public int[] getWidths()(Code)(Java Doc) abstract public boolean hasKernPairs()(Code)(Java Doc) public boolean isDirectTextToByte()(Code)(Java Doc) public boolean isEmbedded()(Code)(Java Doc) public boolean isFontSpecific()(Code)(Java Doc) public boolean isForceWidthsOutput()(Code)(Java Doc) public boolean isSubset()(Code)(Java Doc) protected static String normalizeEncoding(String enc)(Code)(Java Doc) public boolean setCharAdvance(char c, int advance)(Code)(Java Doc) public void setDirectTextToByte(boolean directTextToByte)(Code)(Java Doc) public void setForceWidthsOutput(boolean forceWidthsOutput)(Code)(Java Doc) abstract public boolean setKerning(char char1, char char2, int kern)(Code)(Java Doc) abstract public void setPostscriptFontName(String name)(Code)(Java Doc) public void setSubset(boolean subset)(Code)(Java Doc) abstract void writeFont(PdfWriter writer, PdfIndirectReference ref, Object params) throws DocumentException, IOException(Code)(Java Doc)
|
|
|