public class GlyphSubstitutionTable extends TTFTable
Modifier and Type | Field and Description |
---|---|
private GlyphSubstitutionTable.FeatureRecord[] |
featureList |
private java.lang.String |
lastUsedSupportedScript |
private static org.apache.commons.logging.Log |
LOG |
private java.util.Map<java.lang.Integer,java.lang.Integer> |
lookupCache |
private GlyphSubstitutionTable.LookupTable[] |
lookupList |
private java.util.Map<java.lang.Integer,java.lang.Integer> |
reverseLookup |
private java.util.LinkedHashMap<java.lang.String,GlyphSubstitutionTable.ScriptTable> |
scriptList |
static java.lang.String |
TAG |
font, initialized
Constructor and Description |
---|
GlyphSubstitutionTable(TrueTypeFont font) |
Modifier and Type | Method and Description |
---|---|
private int |
applyFeature(GlyphSubstitutionTable.FeatureRecord featureRecord,
int gid) |
private boolean |
containsFeature(java.util.List<GlyphSubstitutionTable.FeatureRecord> featureRecords,
java.lang.String featureTag) |
private int |
doLookup(GlyphSubstitutionTable.LookupTable lookupTable,
int gid) |
private java.util.List<GlyphSubstitutionTable.FeatureRecord> |
getFeatureRecords(java.util.Collection<GlyphSubstitutionTable.LangSysTable> langSysTables,
java.util.List<java.lang.String> enabledFeatures)
Get a list of
FeatureRecord s from a collection of LangSysTable s. |
private java.util.Collection<GlyphSubstitutionTable.LangSysTable> |
getLangSysTables(java.lang.String scriptTag) |
int |
getSubstitution(int gid,
java.lang.String[] scriptTags,
java.util.List<java.lang.String> enabledFeatures)
Apply glyph substitutions to the supplied gid.
|
int |
getUnsubstitution(int sgid)
For a substitute-gid (obtained from
getSubstitution(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) java.util.LinkedHashMap<java.lang.String,GlyphSubstitutionTable.ScriptTable> |
readScriptList(TTFDataStream data,
long offset) |
(package private) GlyphSubstitutionTable.ScriptTable |
readScriptTable(TTFDataStream data,
long offset) |
private void |
removeFeature(java.util.List<GlyphSubstitutionTable.FeatureRecord> featureRecords,
java.lang.String featureTag) |
private java.lang.String |
selectScriptTag(java.lang.String[] tags)
Choose from one of the supplied OpenType script tags, depending on what the font supports and
potentially on context.
|
getCheckSum, getInitialized, getLength, getOffset, getTag, setCheckSum, setLength, setOffset, setTag
private static final org.apache.commons.logging.Log LOG
public static final java.lang.String TAG
private java.util.LinkedHashMap<java.lang.String,GlyphSubstitutionTable.ScriptTable> scriptList
private GlyphSubstitutionTable.FeatureRecord[] featureList
private GlyphSubstitutionTable.LookupTable[] lookupList
private final java.util.Map<java.lang.Integer,java.lang.Integer> lookupCache
private final java.util.Map<java.lang.Integer,java.lang.Integer> reverseLookup
private java.lang.String lastUsedSupportedScript
GlyphSubstitutionTable(TrueTypeFont font)
void read(TrueTypeFont ttf, TTFDataStream data) throws java.io.IOException
TTFTable
java.util.LinkedHashMap<java.lang.String,GlyphSubstitutionTable.ScriptTable> readScriptList(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.ScriptTable readScriptTable(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.LangSysTable readLangSysTable(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.FeatureRecord[] readFeatureList(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.FeatureTable readFeatureTable(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.LookupTable[] readLookupList(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.LookupTable readLookupTable(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.LookupSubTable readLookupSubTable(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
GlyphSubstitutionTable.CoverageTable readCoverageTable(TTFDataStream data, long offset) throws java.io.IOException
java.io.IOException
private java.lang.String selectScriptTag(java.lang.String[] tags)
tags
- private java.util.Collection<GlyphSubstitutionTable.LangSysTable> getLangSysTables(java.lang.String scriptTag)
private java.util.List<GlyphSubstitutionTable.FeatureRecord> getFeatureRecords(java.util.Collection<GlyphSubstitutionTable.LangSysTable> langSysTables, java.util.List<java.lang.String> enabledFeatures)
FeatureRecord
s from a collection of LangSysTable
s. Optionally
filter the returned features by supplying a list of allowed feature tags in
enabledFeatures
.
Note that features listed as required (LangSysTable#requiredFeatureIndex
) will be
included even if not explicitly enabled.langSysTables
- The LangSysTable
s indicating FeatureRecord
s to search
forenabledFeatures
- An optional whitelist of feature tags (null
to allow all)FeatureRecord
sprivate boolean containsFeature(java.util.List<GlyphSubstitutionTable.FeatureRecord> featureRecords, java.lang.String featureTag)
private void removeFeature(java.util.List<GlyphSubstitutionTable.FeatureRecord> featureRecords, java.lang.String featureTag)
private int applyFeature(GlyphSubstitutionTable.FeatureRecord featureRecord, int gid)
private int doLookup(GlyphSubstitutionTable.LookupTable lookupTable, int gid)
public int getSubstitution(int gid, java.lang.String[] scriptTags, java.util.List<java.lang.String> enabledFeatures)
scriptTags
which indicate the language of the gid, and by the
enabledFeatures
which acts as a whitelist.
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.gid
- GIDscriptTags
- Script tags applicable to the gid (see OpenTypeScript
)enabledFeatures
- Whitelist of features to applypublic int getUnsubstitution(int sgid)
getSubstitution(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.sgid
- Substitute GIDGlyphSubstitutionTable.RangeRecord readRangeRecord(TTFDataStream data) throws java.io.IOException
java.io.IOException