Top Description Inners Fields Constructors Methods
org.apache.fontbox.ttf.gsub

public Class GlyphSubstitutionDataExtractor

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .LinkedHashMap, .List, .Map, org.apache.commons.logging.Log, .LogFactory, org.apache.fontbox.ttf.model.GsubData, .Language, .MapBackedGsubData, org.apache.fontbox.ttf.table.common.CoverageTable, .FeatureListTable, .FeatureRecord, .LangSysTable, .LookupListTable, .LookupSubTable, .LookupTable, .ScriptTable, org.apache.fontbox.ttf.table.gsub.AlternateSetTable, .LigatureSetTable, .LigatureTable, .LookupTypeAlternateSubstitutionFormat1, .LookupTypeLigatureSubstitutionSubstFormat1, .LookupTypeMultipleSubstitutionFormat1, .LookupTypeSingleSubstFormat1, .LookupTypeSingleSubstFormat2

This class has utility methods to extract meaningful GsubData from the highly obfuscated GSUB Tables. This GsubData is then used to determine which combination of glyphs or words have to be replaced.
Author
Palash Ray

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private MapBackedGsubData
private void
extractData(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTable lookupTable)

private void
extractDataFromAlternateSubstitutionSubstFormat1Table(Map<List<Integer>, Integer>
the map to store the substitution data
glyphSubstitutionMap
,
LookupTypeAlternateSubstitutionFormat1
the alternate substitution format 1 table
alternateSubstitutionFormat1
)

Extracts data from the AlternateSubstitutionFormat1 (lookuptype) 3 table and puts it in the glyphSubstitutionMap.

private void
private void
extractDataFromLigatureTable(Map<List<Integer>, Integer> glyphSubstitutionMap, LigatureTable ligatureTable)

private void
private void
private void
public GsubData
getGsubData(Map<String, ScriptTable> scriptList, FeatureListTable featureListTable, LookupListTable lookupListTable)

public GsubData

Returns:

GsubData instance built especially for the given scriptName
getGsubData
(String scriptName, ScriptTable scriptTable, FeatureListTable featureListTable, LookupListTable lookupListTable)

Unlike getGsubData(Map, FeatureListTable, LookupListTable), this method doesn't iterate over supported Language's searching for the first match with the scripts of the font.

private GlyphSubstitutionDataExtractor.ScriptTableDetails
private void
populateGsubData(Map<String, Map<List<Integer>, Integer>> gsubData, LangSysTable langSysTable, FeatureListTable featureListTable, LookupListTable lookupListTable)

private void
populateGsubData(Map<String, Map<List<Integer>, Integer>> gsubData, FeatureRecord featureRecord, LookupListTable lookupListTable)

private void
putNewSubstitutionEntry(Map<List<Integer>, Integer> glyphSubstitutionMap, int newGlyph, List<Integer> glyphsToBeSubstituted)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Log LOG

Constructor Detail

GlyphSubstitutionDataExtractorback to summary
public GlyphSubstitutionDataExtractor()

Method Detail

buildMapBackedGsubDataback to summary
private MapBackedGsubData buildMapBackedGsubData(FeatureListTable featureListTable, LookupListTable lookupListTable, GlyphSubstitutionDataExtractor.ScriptTableDetails scriptTableDetails)
extractDataback to summary
private void extractData(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTable lookupTable)
extractDataFromAlternateSubstitutionSubstFormat1Tableback to summary
private void extractDataFromAlternateSubstitutionSubstFormat1Table(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTypeAlternateSubstitutionFormat1 alternateSubstitutionFormat1)

Extracts data from the AlternateSubstitutionFormat1 (lookuptype) 3 table and puts it in the glyphSubstitutionMap.

Parameters
glyphSubstitutionMap:Map<List<Integer>, Integer>

the map to store the substitution data

alternateSubstitutionFormat1:LookupTypeAlternateSubstitutionFormat1

the alternate substitution format 1 table

extractDataFromLigatureSubstitutionSubstFormat1Tableback to summary
private void extractDataFromLigatureSubstitutionSubstFormat1Table(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTypeLigatureSubstitutionSubstFormat1 ligatureSubstitutionTable)
extractDataFromLigatureTableback to summary
private void extractDataFromLigatureTable(Map<List<Integer>, Integer> glyphSubstitutionMap, LigatureTable ligatureTable)
extractDataFromMultipleSubstitutionFormat1Tableback to summary
private void extractDataFromMultipleSubstitutionFormat1Table(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTypeMultipleSubstitutionFormat1 multipleSubstFormat1Subtable)
extractDataFromSingleSubstTableFormat1Tableback to summary
private void extractDataFromSingleSubstTableFormat1Table(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTypeSingleSubstFormat1 singleSubstTableFormat1)
extractDataFromSingleSubstTableFormat2Tableback to summary
private void extractDataFromSingleSubstTableFormat2Table(Map<List<Integer>, Integer> glyphSubstitutionMap, LookupTypeSingleSubstFormat2 singleSubstTableFormat2)
getGsubDataback to summary
public GsubData getGsubData(Map<String, ScriptTable> scriptList, FeatureListTable featureListTable, LookupListTable lookupListTable)
getGsubDataback to summary
public GsubData getGsubData(String scriptName, ScriptTable scriptTable, FeatureListTable featureListTable, LookupListTable lookupListTable)

Unlike getGsubData(Map, FeatureListTable, LookupListTable), this method doesn't iterate over supported Language's searching for the first match with the scripts of the font. Instead, it unconditionally creates ScriptTableDetails instance with language left unspecified.

Returns:GsubData

GsubData instance built especially for the given scriptName

getSupportedLanguageback to summary
private GlyphSubstitutionDataExtractor.ScriptTableDetails getSupportedLanguage(Map<String, ScriptTable> scriptList)
populateGsubDataback to summary
private void populateGsubData(Map<String, Map<List<Integer>, Integer>> gsubData, LangSysTable langSysTable, FeatureListTable featureListTable, LookupListTable lookupListTable)
populateGsubDataback to summary
private void populateGsubData(Map<String, Map<List<Integer>, Integer>> gsubData, FeatureRecord featureRecord, LookupListTable lookupListTable)
putNewSubstitutionEntryback to summary
private void putNewSubstitutionEntry(Map<List<Integer>, Integer> glyphSubstitutionMap, int newGlyph, List<Integer> glyphsToBeSubstituted)
org.apache.fontbox.ttf.gsub back to summary

private Class GlyphSubstitutionDataExtractor.ScriptTableDetails

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.fontbox.ttf.gsub.GlyphSubstitutionDataExtractor.ScriptTableDetails

Field Summary

Modifier and TypeField and Description
private final String
private final Language
private final ScriptTable

Constructor Summary

AccessConstructor and Description
private
ScriptTableDetails(Language language, String featureName, ScriptTable scriptTable)

Method Summary

Modifier and TypeMethod and Description
public String
public Language
public ScriptTable
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

featureNameback to summary
private final String featureName
languageback to summary
private final Language language
scriptTableback to summary
private final ScriptTable scriptTable

Constructor Detail

ScriptTableDetailsback to summary
private ScriptTableDetails(Language language, String featureName, ScriptTable scriptTable)

Method Detail

getFeatureNameback to summary
public String getFeatureName()
getLanguageback to summary
public Language getLanguage()
getScriptTableback to summary
public ScriptTable getScriptTable()