public class TrueTypeFont extends Object implements FontBoxFont, Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
disableGsubFeature(String featureTag)
Disable a particular glyph substitution feature.
|
void |
enableGsubFeature(String featureTag)
Enable a particular glyph substitution feature.
|
void |
enableVerticalSubstitutions()
Enable glyph substitutions for vertical writing.
|
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.
|
List<Number> |
getFontMatrix()
Returns the FontMatrix in PostScript units.
|
GlyphTable |
getGlyph()
Get the glyf table for this TTF.
|
GlyphSubstitutionTable |
getGsub()
Get the "gsub" table for this TTF.
|
GsubData |
getGsubData()
Returns the GSubData of the GlyphSubstitutionTable if present.
|
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.
|
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).
|
InputStream |
getOriginalData()
Get the data of the TrueType Font
program representing the stream used to build this
object (normally from the TTFParser object).
|
long |
getOriginalDataSize()
Get the data size of the TrueType 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.
|
GeneralPath |
getPath(String name)
Returns the path for the character with the given name.
|
PostScriptTable |
getPostScript()
Get the postscript table for this TTF.
|
protected TTFTable |
getTable(String tag)
This will get the table for the given tag.
|
byte[] |
getTableBytes(TTFTable table)
Returns the raw bytes of the given table.
|
Map<String,TTFTable> |
getTableMap()
Get all of the tables.
|
byte[] |
getTableNBytes(TTFTable table,
int limit)
Returns the raw bytes of the given table, no more than
limit bytes. |
Collection<TTFTable> |
getTables()
Get all of the tables.
|
CmapLookup |
getUnicodeCmapLookup()
Returns the best Unicode from the font (the most general).
|
CmapLookup |
getUnicodeCmapLookup(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(String name)
Returns the advance width for the character with the given name.
|
boolean |
hasGlyph(String name)
Returns true if the font contains the given glyph.
|
boolean |
isEnableGsub() |
int |
nameToGID(String name)
Returns the GID for the given PostScript name, if the "post" table is present.
|
void |
setEnableGsub(boolean enableGsub)
Enable or disable the GSUB table for this font.
|
String |
toString() |
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic float getVersion()
public boolean isEnableGsub()
public void setEnableGsub(boolean enableGsub)
public Collection<TTFTable> getTables()
public Map<String,TTFTable> getTableMap()
public byte[] getTableBytes(TTFTable table) throws IOException
table - the table to read.IOException - if there was an error accessing the table.protected TTFTable getTable(String tag) throws IOException
tag - the name of the table to be returnedIOException - if there was an error reading the table.public byte[] getTableNBytes(TTFTable table, int limit) throws IOException
limit bytes.table - the table to read.limit - maximum length of array to returnIOException - if there was an error accessing the table.public NamingTable getNaming() throws IOException
IOException - if there was an error reading the table.public PostScriptTable getPostScript() throws IOException
IOException - if there was an error reading the table.public OS2WindowsMetricsTable getOS2Windows() throws IOException
IOException - if there was an error reading the table.public MaximumProfileTable getMaximumProfile() throws IOException
IOException - if there was an error reading the table.public HeaderTable getHeader() throws IOException
IOException - if there was an error reading the table.public HorizontalHeaderTable getHorizontalHeader() throws IOException
IOException - if there was an error reading the table.public HorizontalMetricsTable getHorizontalMetrics() throws IOException
IOException - if there was an error reading the table.public IndexToLocationTable getIndexToLocation() throws IOException
IOException - if there was an error reading the table.public GlyphTable getGlyph() throws IOException
IOException - if there was an error reading the table.public CmapTable getCmap() throws IOException
IOException - if there was an error reading the table.public VerticalHeaderTable getVerticalHeader() throws IOException
IOException - if there was an error reading the table.public VerticalMetricsTable getVerticalMetrics() throws IOException
IOException - if there was an error reading the table.public VerticalOriginTable getVerticalOrigin() throws IOException
IOException - if there was an error reading the table.public KerningTable getKerning() throws IOException
IOException - if there was an error reading the table.public GlyphSubstitutionTable getGsub() throws IOException
IOException - if there was an error reading the table.public InputStream getOriginalData() throws IOException
IOException - If there is an error getting the font data.public long getOriginalDataSize()
public int getNumberOfGlyphs()
throws IOException
IOException - if there was an error reading the table.public int getUnitsPerEm()
throws IOException
IOException - if there was an error reading the table.public int getAdvanceWidth(int gid)
throws IOException
gid - the GIDIOException - if there was an error reading the metrics table.public int getAdvanceHeight(int gid)
throws IOException
gid - the GIDIOException - if there was an error reading the metrics table.public String getName() throws IOException
FontBoxFontgetName in interface FontBoxFontIOException - if something went wrong when accessing the font datapublic CmapLookup getUnicodeCmapLookup() throws IOException
IOException - if the font could not be readpublic CmapLookup getUnicodeCmapLookup(boolean isStrict) throws IOException
isStrict - False if we allow falling back to any cmap, even if it's not Unicode.IOException - if the font could not be read, or there is no Unicode cmappublic int nameToGID(String name) throws IOException
name - the PostScript name.IOException - if the font data could not be readpublic GsubData getGsubData() throws IOException
GsubData.NO_DATA_FOUND if no GSUB data is
available, its scripts are not supported or it was disabled for that fontIOException - if the font data could not be readpublic GeneralPath getPath(String name) throws IOException
FontBoxFontgetPath in interface FontBoxFontname - PostScript glyph nameIOException - if the path could not be readpublic float getWidth(String name) throws IOException
FontBoxFontgetWidth in interface FontBoxFontname - PostScript glyph nameIOException - if the path could not be readpublic boolean hasGlyph(String name) throws IOException
FontBoxFonthasGlyph in interface FontBoxFontname - PostScript glyph nameIOException - if something went wrong when accessing the font datapublic BoundingBox getFontBBox() throws IOException
FontBoxFontgetFontBBox in interface FontBoxFontIOException - if something went wrong when accessing the font datapublic List<Number> getFontMatrix() throws IOException
FontBoxFontgetFontMatrix in interface FontBoxFontIOException - if something went wrong when accessing the font datapublic void enableGsubFeature(String featureTag)
featureTag - The GSUB feature to enablepublic void disableGsubFeature(String featureTag)
featureTag - The GSUB feature to disablepublic void enableVerticalSubstitutions()
Copyright © 2008–2025 The Apache Software Foundation. All rights reserved.