Package org.apache.fontbox.ttf
Class GlyphSubstitutionTable
- java.lang.Object
-
- org.apache.fontbox.ttf.TTFTable
-
- org.apache.fontbox.ttf.GlyphSubstitutionTable
-
public class GlyphSubstitutionTable extends TTFTable
A glyph substitution 'GSUB' table in a TrueType or OpenType font.- Author:
- Aaron Madlon-Kay
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTAG-
Fields inherited from class org.apache.fontbox.ttf.TTFTable
initialized
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GsubDatagetGsubData()Returns a GsubData instance containing all scripts of the table.GsubDatagetGsubData(java.lang.String scriptTag)Builds a newGsubDatainstance for given script tag.intgetSubstitution(int gid, java.lang.String[] scriptTags, java.util.List<java.lang.String> enabledFeatures)Apply glyph substitutions to the supplied gid.java.util.Set<java.lang.String>getSupportedScriptTags()intgetUnsubstitution(int sgid)For a substitute-gid (obtained fromgetSubstitution(int, String[], List)), retrieve the original gid.-
Methods inherited from class org.apache.fontbox.ttf.TTFTable
getCheckSum, getInitialized, getLength, getOffset, getTag
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSubstitution
public int getSubstitution(int gid, java.lang.String[] scriptTags, java.util.List<java.lang.String> enabledFeatures)Apply glyph substitutions to the supplied gid. The applicable substitutions are determined by thescriptTagswhich indicate the language of the gid, and by the list ofenabledFeatures. To ensure that a single gid isn't mapped to multiple substitutions, subsequent invocations with the same gid will return the same result as the first, regardless of script or enabled features.- Parameters:
gid- GIDscriptTags- Script tags applicable to the gid (seeOpenTypeScript)enabledFeatures- list of features to apply- Returns:
- the id of the glyph substitution
-
getUnsubstitution
public int getUnsubstitution(int sgid)
For a substitute-gid (obtained fromgetSubstitution(int, String[], List)), retrieve the original gid.Only gids previously substituted by this instance can be un-substituted. If you are trying to unsubstitute before you substitute, something is wrong.
- Parameters:
sgid- Substitute GID- Returns:
- the original gid of a substitute-gid
-
getGsubData
public GsubData getGsubData()
Returns a GsubData instance containing all scripts of the table.- Returns:
- the GsubData instance representing the table
-
getGsubData
public GsubData getGsubData(java.lang.String scriptTag)
Builds a newGsubDatainstance for given script tag. In contrast to neighbourgetGsubData()method, this one does not try to find the first supported language and load GSUB data for it. Instead, it fetches the data for the givenscriptTag(if it's supported by the font) leaving the language unspecified. It means that even after successful reading of GSUB data, the actual glyph substitution may not work if there is no correspondingGsubWorkerimplementation for it. Note: This method performs searching on every invocation (no results are cached)- Parameters:
scriptTag- a script tag for which the data is needed- Returns:
- GSUB data for the given script or
nullif no such script in the font
-
getSupportedScriptTags
public java.util.Set<java.lang.String> getSupportedScriptTags()
- Returns:
- a read-only view of the script tags for which this GSUB table has records
-
-