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 String
private static final org.apache.commons.logging.Log
private GlyphSubstitutionTable.LookupTable[]
static final String
Fields inherited from class org.apache.fontbox.ttf.TTFTable
font, initialized
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
applyFeature
(GlyphSubstitutionTable.FeatureRecord featureRecord, int gid) private boolean
containsFeature
(List<GlyphSubstitutionTable.FeatureRecord> featureRecords, String featureTag) private int
doLookup
(GlyphSubstitutionTable.LookupTable lookupTable, int gid) private List<GlyphSubstitutionTable.FeatureRecord>
getFeatureRecords
(Collection<GlyphSubstitutionTable.LangSysTable> langSysTables, List<String> enabledFeatures) Get a list ofFeatureRecord
s from a collection ofLangSysTable
s.getLangSysTables
(String scriptTag) int
getSubstitution
(int gid, String[] scriptTags, List<String> enabledFeatures) Apply glyph substitutions to the supplied gid.int
getUnsubstitution
(int sgid) For a substitute-gid (obtained fromgetSubstitution(int, String[], List)
), retrieve the original gid.(package private) void
read
(TrueTypeFont ttf, TTFDataStream data) This will read the required data from the stream.(package private) GlyphSubstitutionTable.CoverageTable
readCoverageTable
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.FeatureRecord[]
readFeatureList
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.FeatureTable
readFeatureTable
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LangSysTable
readLangSysTable
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LookupTable[]
readLookupList
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LookupSubTable
readLookupSubTable
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.LookupTable
readLookupTable
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.RangeRecord
readRangeRecord
(TTFDataStream data) (package private) LinkedHashMap<String,
GlyphSubstitutionTable.ScriptTable> readScriptList
(TTFDataStream data, long offset) (package private) GlyphSubstitutionTable.ScriptTable
readScriptTable
(TTFDataStream data, long offset) private void
removeFeature
(List<GlyphSubstitutionTable.FeatureRecord> featureRecords, String featureTag) private String
selectScriptTag
(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:TTFTable
This will read the required data from the stream.- Overrides:
read
in 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 ofFeatureRecord
s from a collection ofLangSysTable
s. 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
- TheLangSysTable
s indicatingFeatureRecord
s to search forenabledFeatures
- An optional list of feature tags (null
to allow all)- Returns:
- The indicated
FeatureRecord
s
-
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 thescriptTags
which 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
-