Package org.apache.fontbox.ttf
Class GlyphSubstitutionTable
java.lang.Object
org.apache.fontbox.ttf.TTFTable
org.apache.fontbox.ttf.GlyphSubstitutionTable
A glyph substitution 'GSUB' table in a TrueType or OpenType font.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate GlyphSubstitutionTable.FeatureRecord[]private Stringprivate static final org.apache.commons.logging.Logprivate GlyphSubstitutionTable.LookupTable[]static final StringFields inherited from class org.apache.fontbox.ttf.TTFTable
font, initialized -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intapplyFeature(GlyphSubstitutionTable.FeatureRecord featureRecord, int gid) private booleancontainsFeature(List<GlyphSubstitutionTable.FeatureRecord> featureRecords, String featureTag) private intdoLookup(GlyphSubstitutionTable.LookupTable lookupTable, int gid) private List<GlyphSubstitutionTable.FeatureRecord>getFeatureRecords(Collection<GlyphSubstitutionTable.LangSysTable> langSysTables, List<String> enabledFeatures) Get a list ofFeatureRecords from a collection ofLangSysTables.getLangSysTables(String scriptTag) intgetSubstitution(int gid, String[] scriptTags, List<String> enabledFeatures) Apply glyph substitutions to the supplied gid.intgetUnsubstitution(int sgid) For a substitute-gid (obtained fromgetSubstitution(int, String[], List)), retrieve the original gid.(package private) voidread(TrueTypeFont ttf, TTFDataStream data) This will read the required data from the stream.(package private) GlyphSubstitutionTable.CoverageTablereadCoverageTable(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.FeatureRecord[]readFeatureList(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.FeatureTablereadFeatureTable(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LangSysTablereadLangSysTable(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LookupTable[]readLookupList(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LookupSubTablereadLookupSubTable(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LookupTablereadLookupTable(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.RangeRecordreadRangeRecord(TTFDataStream data) (package private) LinkedHashMap<String,GlyphSubstitutionTable.ScriptTable> readScriptList(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.ScriptTablereadScriptTable(TTFDataStream data, long offset) private voidremoveFeature(List<GlyphSubstitutionTable.FeatureRecord> featureRecords, String featureTag) private StringselectScriptTag(String[] tags) Choose from one of the supplied OpenType script tags, depending on what the font supports and potentially on context.Methods inherited from class org.apache.fontbox.ttf.TTFTable
getCheckSum, getInitialized, getLength, getOffset, getTag, setCheckSum, setLength, setOffset, setTag
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
TAG
- See Also:
-
scriptList
-
featureList
-
lookupList
-
lookupCache
-
reverseLookup
-
lastUsedSupportedScript
-
-
Constructor Details
-
GlyphSubstitutionTable
GlyphSubstitutionTable(TrueTypeFont font)
-
-
Method Details
-
read
Description copied from class:TTFTableThis will read the required data from the stream.- Overrides:
readin classTTFTable- Parameters:
ttf- The font that is being read.data- The stream to read the data from.- Throws:
IOException- If there is an error reading the data.
-
readScriptList
LinkedHashMap<String,GlyphSubstitutionTable.ScriptTable> readScriptList(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readScriptTable
GlyphSubstitutionTable.ScriptTable readScriptTable(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readLangSysTable
GlyphSubstitutionTable.LangSysTable readLangSysTable(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readFeatureList
GlyphSubstitutionTable.FeatureRecord[] readFeatureList(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readFeatureTable
GlyphSubstitutionTable.FeatureTable readFeatureTable(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readLookupList
GlyphSubstitutionTable.LookupTable[] readLookupList(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readLookupTable
GlyphSubstitutionTable.LookupTable readLookupTable(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readLookupSubTable
GlyphSubstitutionTable.LookupSubTable readLookupSubTable(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
readCoverageTable
GlyphSubstitutionTable.CoverageTable readCoverageTable(TTFDataStream data, long offset) throws IOException - Throws:
IOException
-
selectScriptTag
Choose from one of the supplied OpenType script tags, depending on what the font supports and potentially on context.- Parameters:
tags-- Returns:
- The best OpenType script tag
-
getLangSysTables
-
getFeatureRecords
private List<GlyphSubstitutionTable.FeatureRecord> getFeatureRecords(Collection<GlyphSubstitutionTable.LangSysTable> langSysTables, List<String> enabledFeatures) Get a list ofFeatureRecords from a collection ofLangSysTables. Optionally filter the returned features by supplying a list of allowed feature tags inenabledFeatures. Note that features listed as required (LangSysTable#requiredFeatureIndex) will be included even if not explicitly enabled.- Parameters:
langSysTables- TheLangSysTables indicatingFeatureRecords to search forenabledFeatures- An optional list of feature tags (nullto allow all)- Returns:
- The indicated
FeatureRecords
-
containsFeature
private boolean containsFeature(List<GlyphSubstitutionTable.FeatureRecord> featureRecords, String featureTag) -
removeFeature
private void removeFeature(List<GlyphSubstitutionTable.FeatureRecord> featureRecords, String featureTag) -
applyFeature
-
doLookup
-
getSubstitution
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
-
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
-
readRangeRecord
- Throws:
IOException
-