Save This Page
Home » iText-src-2.1.3 » com.lowagie » text » pdf » [javadoc | source]
com.lowagie.text.pdf
class: TrueTypeFont [javadoc | source]
java.lang.Object
   com.lowagie.text.pdf.BaseFont
      com.lowagie.text.pdf.TrueTypeFont

Direct Known Subclasses:
    TrueTypeFontUnicode, EnumerateTTC

Reads a Truetype font
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
static final  String[] codePages    The code pages possible for a True Type font. 
protected  boolean justNames     
protected  HashMap tables    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. 
protected  RandomAccessFileOrArray rf    The file in use. 
protected  String fileName    The file name. 
protected  boolean cff     
protected  int cffOffset     
protected  int cffLength     
protected  int directoryOffset    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. 
protected  String ttcIndex    The index for the TTC font. It is an empty String for a TTF file. 
protected  String style    The style modifier 
protected  TrueTypeFont.FontHeader head    The content of table 'head'. 
protected  TrueTypeFont.HorizontalHeader hhea    The content of table 'hhea'. 
protected  TrueTypeFont.WindowsMetrics os_2    The content of table 'OS/2'. 
protected  int[] GlyphWidths    The width of the glyphs. This is essentially the content of table 'hmtx' normalized to 1000 units. 
protected  int[][] bboxes     
protected  HashMap cmap10    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. 
protected  HashMap cmap31    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. 

protected  HashMap cmapExt     
protected  IntHashtable kerning    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. 
protected  String fontName    The font name. This name is usually extracted from the table 'name' with the 'Name ID' 6. 
protected  String[][] fullName    The full name of the font 
protected  String[][] allNameEntries    All the names of the Names-Table 
protected  String[][] familyName    The family name of the font 
protected  double italicAngle    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
 
protected  boolean isFixedPitch    true if all the glyphs have the same width. 
protected  int underlinePosition     
protected  int underlineThickness     
Fields inherited from com.lowagie.text.pdf.BaseFont:
COURIER,  COURIER_BOLD,  COURIER_OBLIQUE,  COURIER_BOLDOBLIQUE,  HELVETICA,  HELVETICA_BOLD,  HELVETICA_OBLIQUE,  HELVETICA_BOLDOBLIQUE,  SYMBOL,  TIMES_ROMAN,  TIMES_BOLD,  TIMES_ITALIC,  TIMES_BOLDITALIC,  ZAPFDINGBATS,  ASCENT,  CAPHEIGHT,  DESCENT,  ITALICANGLE,  BBOXLLX,  BBOXLLY,  BBOXURX,  BBOXURY,  AWT_ASCENT,  AWT_DESCENT,  AWT_LEADING,  AWT_MAXADVANCE,  UNDERLINE_POSITION,  UNDERLINE_THICKNESS,  STRIKETHROUGH_POSITION,  STRIKETHROUGH_THICKNESS,  SUBSCRIPT_SIZE,  SUBSCRIPT_OFFSET,  SUPERSCRIPT_SIZE,  SUPERSCRIPT_OFFSET,  FONT_TYPE_T1,  FONT_TYPE_TT,  FONT_TYPE_CJK,  FONT_TYPE_TTUNI,  FONT_TYPE_DOCUMENT,  FONT_TYPE_T3,  IDENTITY_H,  IDENTITY_V,  CP1250,  CP1252,  CP1257,  WINANSI,  MACROMAN,  CHAR_RANGE_LATIN,  CHAR_RANGE_ARABIC,  CHAR_RANGE_HEBREW,  CHAR_RANGE_CYRILLIC,  EMBEDDED,  NOT_EMBEDDED,  CACHED,  NOT_CACHED,  RESOURCE_PATH,  CID_NEWLINE,  subsetRanges,  fontType,  notdef,  widths,  differences,  unicodeDifferences,  charBBoxes,  encoding,  embedded,  compressionLevel,  fontSpecific,  fontCache,  BuiltinFonts14,  forceWidthsOutput,  directTextToByte,  subset,  fastWinansi,  specialMap
Constructor:
 protected TrueTypeFont() 
 TrueTypeFont(String ttFile,
    String enc,
    boolean emb,
    byte[] ttfAfm) throws IOException, DocumentException 
 TrueTypeFont(String ttFile,
    String enc,
    boolean emb,
    byte[] ttfAfm,
    boolean justNames) throws IOException, DocumentException 
    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
    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
Method from com.lowagie.text.pdf.TrueTypeFont Summary:
addRangeUni,   checkCff,   compactRanges,   fillTables,   getAllNameEntries,   getAllNames,   getBaseFont,   getCodePagesSupported,   getFamilyFontName,   getFontBaseType,   getFontDescriptor,   getFontDescriptor,   getFullFont,   getFullFontName,   getFullFontStream,   getGlyphWidth,   getKerning,   getMetricsTT,   getNames,   getPostscriptFontName,   getRawCharBBox,   getRawWidth,   getTTCName,   hasKernPairs,   process,   readCMaps,   readCffFont,   readFormat0,   readFormat12,   readFormat4,   readFormat6,   readGlyphWidths,   readKerning,   readStandardString,   readUnicodeString,   setKerning,   setPostscriptFontName,   writeFont
Methods from com.lowagie.text.pdf.BaseFont:
addSubsetRange,   charExists,   convertToBytes,   convertToBytes,   correctArabicAdvance,   createEncoding,   createFont,   createFont,   createFont,   createFont,   createFont,   createSubsetPrefix,   enumerateTTCNames,   enumerateTTCNames,   getAllFontNames,   getAllNameEntries,   getAllNameEntries,   getAscent,   getAscentPoint,   getBaseName,   getCharBBox,   getCidCode,   getCodePagesSupported,   getCompressionLevel,   getDescent,   getDescentPoint,   getDifferences,   getDocumentFonts,   getDocumentFonts,   getEncoding,   getFamilyFontName,   getFontDescriptor,   getFontType,   getFullFontName,   getFullFontName,   getFullFontStream,   getKerning,   getPostscriptFontName,   getRawCharBBox,   getRawWidth,   getResourceStream,   getResourceStream,   getUnicodeDifferences,   getUnicodeDifferences,   getUnicodeEquivalent,   getWidth,   getWidth,   getWidthPoint,   getWidthPoint,   getWidthPointKerned,   getWidths,   hasKernPairs,   isDirectTextToByte,   isEmbedded,   isFontSpecific,   isForceWidthsOutput,   isSubset,   normalizeEncoding,   setCharAdvance,   setCompressionLevel,   setDirectTextToByte,   setForceWidthsOutput,   setKerning,   setPostscriptFontName,   setSubset,   writeFont
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.pdf.TrueTypeFont Detail:
 protected  void addRangeUni(HashMap longTag,
    boolean includeMetrics,
    boolean subsetp) 
  void checkCff() 
 protected static int[] compactRanges(ArrayList ranges) 
  void fillTables() throws IOException, DocumentException 
    Reads the tables 'head', 'hhea', 'OS/2' and 'post' filling several variables.
 public String[][] getAllNameEntries() 
    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}.
 String[][] getAllNames() throws IOException, DocumentException 
    Extracts all the names of the names-Table
 String getBaseFont() throws IOException, DocumentException 
    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. 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}.
 protected PdfDictionary getFontBaseType(PdfIndirectReference fontDescriptor,
    String subsetPrefix,
    int firstChar,
    int lastChar,
    byte[] shortTag) 
    Generates the font dictionary for this font.
 public float getFontDescriptor(int key,
    float fontSize) 
    Gets the font parameter identified by key. Valid values for key are ASCENT, CAPHEIGHT, DESCENT and ITALICANGLE.
 protected PdfDictionary getFontDescriptor(PdfIndirectReference fontStream,
    String subsetPrefix,
    PdfIndirectReference cidset) 
    Generates the font descriptor for this font.
 protected byte[] getFullFont() throws IOException 
 public String[][] getFullFontName() 
    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}.
 public PdfStream getFullFontStream() throws IOException, DocumentException 
    Returns a PdfStream object with the full font program.
 protected int getGlyphWidth(int glyph) 
    Gets a glyph width.
 public int getKerning(int char1,
    int 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) throws IOException, DocumentException 
    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. If the name is null it's a symbolic font.
 protected static String getTTCName(String name) 
    Gets the name from a composed TTC file name. If I have for input "myfont.ttc,2" the return will be "myfont.ttc".
 public boolean hasKernPairs() 
    Checks if the font has any kerning pairs.
  void process(byte[] ttfAfm) throws IOException, DocumentException 
    Reads the font data.
  void readCMaps() throws IOException, DocumentException 
    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.
 protected byte[] readCffFont() throws IOException 
    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).
 HashMap readFormat0() throws IOException 
    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.
 HashMap readFormat12() throws IOException 
 HashMap readFormat4() throws IOException 
    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.
 HashMap readFormat6() throws IOException 
    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.
 protected  void readGlyphWidths() throws IOException, DocumentException 
    Reads the glyphs widths. The widths are extracted from the table 'hmtx'. The glyphs are normalized to 1000 units.
  void readKerning() throws IOException 
    Reads the kerning information from the 'kern' table.
 protected String readStandardString(int length) throws IOException 
    Reads a String from the font file as bytes using the Cp1252 encoding.
 protected String readUnicodeString(int length) throws IOException 
    Reads a Unicode String from the font file. Each character is represented by two bytes.
 public boolean setKerning(int char1,
    int 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. Use with care as it can easily make a font unreadable if not embedded.
  void writeFont(PdfWriter writer,
    PdfIndirectReference ref,
    Object[] params) throws IOException, DocumentException 
    Outputs to the writer the font dictionaries and streams.