Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.lowagie.text.pdf
Class TrueTypeFontUnicode

    java.lang.Object
      com.lowagie.text.pdf.BaseFont
          com.lowagie.text.pdf.TrueTypeFont
              com.lowagie.text.pdf.TrueTypeFontUnicode

All Implemented Interfaces:
  Comparator

     class TrueTypeFontUnicode

extends TrueTypeFont
implements Comparator

Represents a True Type font with Unicode encoding. All the character in the font can be used directly by using the encoding Identity-H or Identity-V. This is the only way to represent some character sets such as Thai.

Author:
  Paulo Soares (psoares@consiste.pt)

Nested Class Summary

Nested classes/interfaces inherited from class com.lowagie.text.pdf.TrueTypeFont
`TrueTypeFont.FontHeader, TrueTypeFont.HorizontalHeader, TrueTypeFont.WindowsMetrics`

Nested classes/interfaces inherited from class com.lowagie.text.pdf.BaseFont
`BaseFont.StreamFont`

Field Summary
`private static byte[]` | `rotbits`
`(package private) boolean` | `vertical` `true` if the encoding is vertical.

Fields inherited from class com.lowagie.text.pdf.TrueTypeFont
`bboxes, cff, cffLength, cffOffset, cmap10, cmap31, codePages, directoryOffset, familyName, fileName, fontName, fullName, GlyphWidths, head, hhea, isFixedPitch, italicAngle, justNames, kerning, os_2, rf, style, tables, ttcIndex, underlinePosition, underlineThickness`

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, 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, ITALICANGLE, MACROMAN, NOT_CACHED, NOT_EMBEDDED, notdef, RESOURCE_PATH, 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
`TrueTypeFontUnicode(String ttFile, String enc, boolean emb, byte[] ttfAfm)` Creates a new TrueType font addressed by Unicode characters.

Method Summary
`boolean` | `charExists(char c)` Checks if a character exists in this font.
`int` | `compare(Object o1, Object o2)` The method used to sort the metrics array.
`(package private) byte[]` | `convertToBytes(char char1)` Converts a `char` to a byte array according to the font's encoding.
`(package private) byte[]` | `convertToBytes(String text)` A forbidden operation.
`int[]` | `getCharBBox(char c)` Gets the smallest box enclosing the character contours.
`private PdfDictionary` | `getCIDFontType2(PdfIndirectReference fontDescriptor, String subsetPrefix, Object[] metrics)` Generates the CIDFontTyte2 dictionary.
`private PdfDictionary` | `getFontBaseType(PdfIndirectReference descendant, String subsetPrefix, PdfIndirectReference toUnicode)` Generates the font dictionary.
`private PdfStream` | `getToUnicode(Object[] metrics)` Creates a ToUnicode CMap to allow copy and paste from Acrobat.
`int` | `getWidth(char char1)` Gets the width of a `char` in normalized 1000 units.
`int` | `getWidth(String text)` Gets the width of a `String` in normalized 1000 units.
`boolean` | `setCharAdvance(char c, int advance)` Sets the character advance.
`(package private) static String` | `toHex(int n)` Gets an hex string in the format "<HHHH>".
`(package private) void` | `writeFont(PdfWriter writer, PdfIndirectReference ref, Object[] params)` Outputs to the writer the font dictionaries and streams.

Methods inherited from class com.lowagie.text.pdf.TrueTypeFont
`addRangeUni, checkCff, compactRanges, fillTables, getBaseFont, getCodePagesSupported, getFamilyFontName, getFontBaseType, getFontDescriptor, getFontDescriptor, getFullFont, getFullFontName, getGlyphWidth, getKerning, getMetricsTT, getNames, getPostscriptFontName, getRawCharBBox, getRawWidth, getTTCName, hasKernPairs, process, readCMaps, readFormat0, readFormat4, readFormat6, readGlyphWidths, readKerning, readStandardString, readUnicodeString, setKerning, setPostscriptFontName`

Methods inherited from class com.lowagie.text.pdf.BaseFont
`addSubsetRange, correctArabicAdvance, createEncoding, createFont, createFont, createFont, createFont, createSubsetPrefix, enumerateTTCNames, enumerateTTCNames, getAllFontNames, getAscent, getAscentPoint, getBaseName, getCidCode, getDescent, getDescentPoint, getDifferences, getDocumentFonts, getDocumentFonts, getEncoding, getFontType, getFullFontName, getResourceStream, getResourceStream, getUnicodeDifferences, getUnicodeDifferences, getUnicodeEquivalent, getWidthPoint, getWidthPoint, getWidthPointKerned, getWidths, isDirectTextToByte, isEmbedded, isFontSpecific, isForceWidthsOutput, isSubset, normalizeEncoding, setDirectTextToByte, setForceWidthsOutput, setSubset`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Comparator
`equals`

Field Detail

### vertical

    boolean vertical

  `true` if the encoding is vertical.

### rotbits

    private static final byte[] rotbits

Constructor Detail

### TrueTypeFontUnicode

    TrueTypeFontUnicode(String ttFile,
                        String enc,
                        boolean emb,
                        byte[] ttfAfm)
                  throws DocumentException,
                         IOException

  Creates a new TrueType font addressed by Unicode characters. The font will always be embedded.

  Parameters:
    `ttFile` - the location of the font on file. The file must end in '.ttf'. The modifiers after the name are ignored.
    `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 Detail

### getWidth

    public int getWidth(char char1)

  Gets the width of a `char` in normalized 1000 units.

  Overrides:
    `getWidth` in class `BaseFont`
  Parameters:
    `char1` - the unicode `char` to get the width of
  Returns:
    the width in normalized 1000 units

### getWidth

    public int getWidth(String text)

  Gets the width of a `String` in normalized 1000 units.

  Overrides:
    `getWidth` in class `BaseFont`
  Parameters:
    `text` - the `String` to get the witdth of
  Returns:
    the width in normalized 1000 units

### getToUnicode

    private PdfStream getToUnicode(Object[] metrics)

  Creates a ToUnicode CMap to allow copy and paste from Acrobat.

  Parameters:
    `metrics` - metrics[0] contains the glyph index and metrics[2] contains the Unicode code
  Returns:
    the stream representing this CMap or `null`
  Throws:
    `DocumentException` - on error

### toHex

    static String toHex(int n)

  Gets an hex string in the format "<HHHH>".

  Parameters:
    `n` - the number
  Returns:
    the hex string

### getCIDFontType2

    private PdfDictionary getCIDFontType2(PdfIndirectReference fontDescriptor,
                                          String subsetPrefix,
                                          Object[] metrics)

  Generates the CIDFontTyte2 dictionary.

  Parameters:
    `fontDescriptor` - the indirect reference to the font descriptor
    `subsetPrefix` - the subset prefix
    `metrics` - the horizontal width metrics
  Returns:
    a stream

### getFontBaseType

    private PdfDictionary getFontBaseType(PdfIndirectReference descendant,
                                          String subsetPrefix,
                                          PdfIndirectReference toUnicode)

  Generates the font dictionary.

  Parameters:
    `descendant` - the descendant dictionary
    `subsetPrefix` - the subset prefix
    `toUnicode` - the ToUnicode stream
  Returns:
    the stream

### compare

    public int compare(Object o1,
                       Object o2)

  The method used to sort the metrics array.

  Specified by:
    `compare` in interface `Comparator`
  Parameters:
    `o1` - the first element
    `o2` - the second element
  Returns:
    the comparisation

### writeFont

    void writeFont(PdfWriter writer,
                   PdfIndirectReference ref,
                   Object[] params)
             throws DocumentException,
                    IOException

  Outputs to the writer the font dictionaries and streams.

  Overrides:
    `writeFont` in class `TrueTypeFont`
  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

### convertToBytes

    byte[] convertToBytes(String text)

  A forbidden operation. Will throw a null pointer exception.

  Overrides:
    `convertToBytes` in class `BaseFont`
  Parameters:
    `text` - the text
  Returns:
    always `null`

### convertToBytes

    byte[] convertToBytes(char char1)

  Description copied from class: `BaseFont`
  Converts a `char` to a byte array according to the font's encoding.

  Overrides:
    `convertToBytes` in class `BaseFont`
  Parameters:
    `char1` - the `char` to be converted
  Returns:
    an array of `byte` representing the conversion according to the font's encoding

### charExists

    public boolean charExists(char c)

  Checks if a character exists in this font.

  Overrides:
    `charExists` in class `BaseFont`
  Parameters:
    `c` - the character to check
  Returns:
    `true` if the character has a glyph, `false` otherwise

### setCharAdvance

    public boolean setCharAdvance(char c,
                                  int advance)

  Sets the character advance.

  Overrides:
    `setCharAdvance` in class `BaseFont`
  Parameters:
    `c` - the character
    `advance` - the character advance normalized to 1000 units
  Returns:
    `true` if the advance was set, `false` otherwise

### getCharBBox

    public int[] getCharBBox(char c)

  Description copied from class: `BaseFont`
  Gets the smallest box enclosing the character contours. It will return `null` if the font has not the information or the character has no contours, as in the case of the space, for example. Characters with no contours may also return [0,0,0,0].

  Overrides:
    `getCharBBox` in class `BaseFont`
  Parameters:
    `c` - the character to get the contour bounding box from
  Returns:
    an array of four floats with the bounding box in the format [llx,lly,urx,ury] or `null`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD