TrueTypeFont
Date: 2017-05-25

org.apache.fontbox.ttf

## Class TrueTypeFont

- java.lang.Object
- - org.apache.fontbox.ttf.TrueTypeFont

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, FontBoxFont
  Direct Known Subclasses:
    OpenTypeFont

      public class TrueTypeFont
      extends java.lang.Object
      implements FontBoxFont, java.io.Closeable

  A TrueType font file.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<java.lang.String,TTFTable>` | `tables`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `int` | `getAdvanceHeight(int gid)` Returns the height for the given GID.
    `int` | `getAdvanceWidth(int gid)` Returns the width for the given GID.
    `CmapTable` | `getCmap()` Get the "cmap" table for this TTF.
    `BoundingBox` | `getFontBBox()` Returns the font's bounding box in PostScript units.
    `java.util.List<java.lang.Number>` | `getFontMatrix()` Returns the FontMatrix in PostScript units.
    `GlyphTable` | `getGlyph()` Get the glyf table for this TTF.
    `HeaderTable` | `getHeader()` Get the head table for this TTF.
    `HorizontalHeaderTable` | `getHorizontalHeader()` Get the hhea table for this TTF.
    `HorizontalMetricsTable` | `getHorizontalMetrics()` Get the hmtx table for this TTF.
    `IndexToLocationTable` | `getIndexToLocation()` Get the loca table for this TTF.
    `KerningTable` | `getKerning()` Get the "kern" table for this TTF.
    `MaximumProfileTable` | `getMaximumProfile()` Get the maxp table for this TTF.
    `java.lang.String` | `getName()` The PostScript name of the font.
    `NamingTable` | `getNaming()` This will get the naming table for the true type font.
    `int` | `getNumberOfGlyphs()` Returns the number of glyphs (MaximumProfile.numGlyphs).
    `java.io.InputStream` | `getOriginalData()` This permit to get the data of the True Type Font program representing the stream used to build this object (normally from the TTFParser object).
    `OS2WindowsMetricsTable` | `getOS2Windows()` Get the OS/2 table for this TTF.
    `java.awt.geom.GeneralPath` | `getPath(java.lang.String name)` Returns the path for the character with the given name.
    `PostScriptTable` | `getPostScript()` Get the postscript table for this TTF.
    `protected TTFTable` | `getTable(java.lang.String tag)` This will get the table for the given tag.
    `byte[]` | `getTableBytes(TTFTable table)` Returns the raw bytes of the given table.
    `java.util.Map<java.lang.String,TTFTable>` | `getTableMap()` Get all of the tables.
    `java.util.Collection<TTFTable>` | `getTables()` Get all of the tables.
    `CmapSubtable` | `getUnicodeCmap()` Returns the best Unicode from the font (the most general).
    `CmapSubtable` | `getUnicodeCmap(boolean isStrict)` Returns the best Unicode from the font (the most general).
    `int` | `getUnitsPerEm()` Returns the units per EM (Header.unitsPerEm).
    `float` | `getVersion()`
    `VerticalHeaderTable` | `getVerticalHeader()` Get the vhea table for this TTF.
    `VerticalMetricsTable` | `getVerticalMetrics()` Get the vmtx table for this TTF.
    `VerticalOriginTable` | `getVerticalOrigin()` Get the VORG table for this TTF.
    `float` | `getWidth(java.lang.String name)` Returns the advance width for the character with the given name.
    `boolean` | `hasGlyph(java.lang.String name)` Returns true if the font contains the given glyph.
    `int` | `nameToGID(java.lang.String name)` Returns the GID for the given PostScript name, if the "post" table is present.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### tables

          protected java.util.Map<java.lang.String,TTFTable> tables

  - ### Method Detail

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Throws:
        `java.io.IOException`

    - #### getVersion

          public float getVersion()

      Returns:
        Returns the version.

    - #### getTables

          public java.util.Collection<TTFTable> getTables()

      Get all of the tables.
      Returns:
        All of the tables.

    - #### getTableMap

          public java.util.Map<java.lang.String,TTFTable> getTableMap()

      Get all of the tables.
      Returns:
        All of the tables.

    - #### getTableBytes

          public byte[] getTableBytes(TTFTable table)
                               throws java.io.IOException

      Returns the raw bytes of the given table.
      Parameters:
        `table` - the table to read.
      Throws:
        `java.io.IOException` - if there was an error accessing the table.

    - #### getTable

          protected TTFTable getTable(java.lang.String tag)
                               throws java.io.IOException

      This will get the table for the given tag.
      Parameters:
        `tag` - the name of the table to be returned
      Returns:
        The table with the given tag.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getNaming

          public NamingTable getNaming()
                                throws java.io.IOException

      This will get the naming table for the true type font.
      Returns:
        The naming table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getPostScript

          public PostScriptTable getPostScript()
                                        throws java.io.IOException

      Get the postscript table for this TTF.
      Returns:
        The postscript table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getOS2Windows

          public OS2WindowsMetricsTable getOS2Windows()
                                               throws java.io.IOException

      Get the OS/2 table for this TTF.
      Returns:
        The OS/2 table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getMaximumProfile

          public MaximumProfileTable getMaximumProfile()
                                                throws java.io.IOException

      Get the maxp table for this TTF.
      Returns:
        The maxp table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getHeader

          public HeaderTable getHeader()
                                throws java.io.IOException

      Get the head table for this TTF.
      Returns:
        The head table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getHorizontalHeader

          public HorizontalHeaderTable getHorizontalHeader()
                                                    throws java.io.IOException

      Get the hhea table for this TTF.
      Returns:
        The hhea table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getHorizontalMetrics

          public HorizontalMetricsTable getHorizontalMetrics()
                                                      throws java.io.IOException

      Get the hmtx table for this TTF.
      Returns:
        The hmtx table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getIndexToLocation

          public IndexToLocationTable getIndexToLocation()
                                                  throws java.io.IOException

      Get the loca table for this TTF.
      Returns:
        The loca table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getGlyph

          public GlyphTable getGlyph()
                              throws java.io.IOException

      Get the glyf table for this TTF.
      Returns:
        The glyf table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getCmap

          public CmapTable getCmap()
                            throws java.io.IOException

      Get the "cmap" table for this TTF.
      Returns:
        The "cmap" table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getVerticalHeader

          public VerticalHeaderTable getVerticalHeader()
                                                throws java.io.IOException

      Get the vhea table for this TTF.
      Returns:
        The vhea table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getVerticalMetrics

          public VerticalMetricsTable getVerticalMetrics()
                                                  throws java.io.IOException

      Get the vmtx table for this TTF.
      Returns:
        The vmtx table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getVerticalOrigin

          public VerticalOriginTable getVerticalOrigin()
                                                throws java.io.IOException

      Get the VORG table for this TTF.
      Returns:
        The VORG table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getKerning

          public KerningTable getKerning()
                                  throws java.io.IOException

      Get the "kern" table for this TTF.
      Returns:
        The "kern" table.
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getOriginalData

          public java.io.InputStream getOriginalData()
                                              throws java.io.IOException

      This permit to get the data of the True Type Font program representing the stream used to build this object (normally from the TTFParser object).
      Returns:
        COSStream True type font program stream
      Throws:
        `java.io.IOException` - If there is an error getting the font data.

    - #### getNumberOfGlyphs

          public int getNumberOfGlyphs()
                                throws java.io.IOException

      Returns the number of glyphs (MaximumProfile.numGlyphs).
      Returns:
        the number of glyphs
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getUnitsPerEm

          public int getUnitsPerEm()
                            throws java.io.IOException

      Returns the units per EM (Header.unitsPerEm).
      Returns:
        units per EM
      Throws:
        `java.io.IOException` - if there was an error reading the table.

    - #### getAdvanceWidth

          public int getAdvanceWidth(int gid)
                              throws java.io.IOException

      Returns the width for the given GID.
      Parameters:
        `gid` - the GID
      Returns:
        the width
      Throws:
        `java.io.IOException` - if there was an error reading the metrics table.

    - #### getAdvanceHeight

          public int getAdvanceHeight(int gid)
                               throws java.io.IOException

      Returns the height for the given GID.
      Parameters:
        `gid` - the GID
      Returns:
        the height
      Throws:
        `java.io.IOException` - if there was an error reading the metrics table.

    - #### getName

          public java.lang.String getName()
                                   throws java.io.IOException

      Description copied from interface: `FontBoxFont`
      The PostScript name of the font.
      Specified by:
        `getName` in interface `FontBoxFont`
      Throws:
        `java.io.IOException`

    - #### getUnicodeCmap

          public CmapSubtable getUnicodeCmap()
                                      throws java.io.IOException

      Returns the best Unicode from the font (the most general). The PDF spec says that "The means by which this is accomplished are implementation-dependent."
      Throws:
        `java.io.IOException` - if the font could not be read

    - #### getUnicodeCmap

          public CmapSubtable getUnicodeCmap(boolean isStrict)
                                      throws java.io.IOException

      Returns the best Unicode from the font (the most general). The PDF spec says that "The means by which this is accomplished are implementation-dependent."
      Parameters:
        `isStrict` - False if we allow falling back to any cmap, even if it's not Unicode.
      Throws:
        `java.io.IOException` - if the font could not be read, or there is no Unicode cmap

    - #### nameToGID

          public int nameToGID(java.lang.String name)
                        throws java.io.IOException

      Returns the GID for the given PostScript name, if the "post" table is present.
      Parameters:
        `name` - the PostScript name.
      Throws:
        `java.io.IOException`

    - #### getPath

          public java.awt.geom.GeneralPath getPath(java.lang.String name)
                                            throws java.io.IOException

      Description copied from interface: `FontBoxFont`
      Returns the path for the character with the given name.
      Specified by:
        `getPath` in interface `FontBoxFont`
      Returns:
        glyph path
      Throws:
        `java.io.IOException` - if the path could not be read

    - #### getWidth

          public float getWidth(java.lang.String name)
                         throws java.io.IOException

      Description copied from interface: `FontBoxFont`
      Returns the advance width for the character with the given name.
      Specified by:
        `getWidth` in interface `FontBoxFont`
      Returns:
        glyph advance width
      Throws:
        `java.io.IOException` - if the path could not be read

    - #### hasGlyph

          public boolean hasGlyph(java.lang.String name)
                           throws java.io.IOException

      Description copied from interface: `FontBoxFont`
      Returns true if the font contains the given glyph.
      Specified by:
        `hasGlyph` in interface `FontBoxFont`
      Parameters:
        `name` - PostScript glyph name
      Throws:
        `java.io.IOException`

    - #### getFontBBox

          public BoundingBox getFontBBox()
                                  throws java.io.IOException

      Description copied from interface: `FontBoxFont`
      Returns the font's bounding box in PostScript units.
      Specified by:
        `getFontBBox` in interface `FontBoxFont`
      Throws:
        `java.io.IOException`

    - #### getFontMatrix

          public java.util.List<java.lang.Number> getFontMatrix()
                                                         throws java.io.IOException

      Description copied from interface: `FontBoxFont`
      Returns the FontMatrix in PostScript units.
      Specified by:
        `getFontMatrix` in interface `FontBoxFont`
      Throws:
        `java.io.IOException`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`