String scriptTag = selectScriptTag(scriptTags); Collection<LangSysTable> langSysTables = getLangSysTables(scriptTag); List<FeatureRecord> featureRecords = getFeatureRecords(langSysTables, enabledFeatures); int sgid = gid; for (FeatureRecord featureRecord : featureRecords) sgid = applyFeature(featureRecord, sgid);
if (containsFeature(result, "vrt2")) removeFeature(result, "vert");
public GsubData getGsubData() throws IOException { GlyphSubstitutionTable table = getGsub(); if (table == null) { return GsubData.NO_DATA_FOUND; } return table.getGsubData(); }
CoverageTable coverageTable = readCoverageTable(data, offset + coverage); ligatureSetTables[i] = readLigatureSetTable(data, offset + ligatureOffsets[i], coverageGlyphId);
@Override public int getGlyphId(int characterCode) { int gid = cmap.getGlyphId(characterCode); String[] scriptTags = OpenTypeScript.getScriptTags(characterCode); return gsub.getSubstitution(gid, scriptTags, enabledFeatures); }
@Override public List<Integer> getCharCodes(int gid) { return cmap.getCharCodes(gsub.getUnsubstitution(gid)); } }
private int applyFeature(FeatureRecord featureRecord, int gid) { int lookupResult = gid; for (int lookupListIndex : featureRecord.getFeatureTable().getLookupListIndices()) { LookupTable lookupTable = lookupListTable.getLookups()[lookupListIndex]; if (lookupTable.getLookupType() != 1) { LOG.debug("Skipping GSUB feature '" + featureRecord.getFeatureTag() + "' because it requires unsupported lookup table type " + lookupTable.getLookupType()); continue; } lookupResult = doLookup(lookupTable, lookupResult); } return lookupResult; }
private LookupSubTable readLookupSubTable(TTFDataStream data, long offset) throws IOException { data.seek(offset); int substFormat = data.readUnsignedShort(); switch (substFormat) { case 1: { int coverageOffset = data.readUnsignedShort(); short deltaGlyphID = data.readSignedShort(); CoverageTable coverageTable = readCoverageTable(data, offset + coverageOffset); return new LookupTypeSingleSubstFormat1(substFormat, coverageTable, deltaGlyphID); } case 2: { int coverageOffset = data.readUnsignedShort(); int glyphCount = data.readUnsignedShort(); int[] substituteGlyphIDs = new int[glyphCount]; for (int i = 0; i < glyphCount; i++) { substituteGlyphIDs[i] = data.readUnsignedShort(); } CoverageTable coverageTable = readCoverageTable(data, offset + coverageOffset); return new LookupTypeSingleSubstFormat2(substFormat, coverageTable, substituteGlyphIDs); } default: throw new IllegalArgumentException("Unknown substFormat: " + substFormat); } }
break; case GlyphSubstitutionTable.TAG: table = new GlyphSubstitutionTable(font); break; default:
@Override public int getGlyphId(int characterCode) { int gid = cmap.getGlyphId(characterCode); String[] scriptTags = OpenTypeScript.getScriptTags(characterCode); return gsub.getSubstitution(gid, scriptTags, enabledFeatures); }
@Override public List<Integer> getCharCodes(int gid) { return cmap.getCharCodes(gsub.getUnsubstitution(gid)); } }
private int applyFeature(FeatureRecord featureRecord, int gid) { for (int lookupListIndex : featureRecord.featureTable.lookupListIndices) { LookupTable lookupTable = lookupList[lookupListIndex]; if (lookupTable.lookupType != 1) { LOG.debug("Skipping GSUB feature '" + featureRecord.featureTag + "' because it requires unsupported lookup table type " + lookupTable.lookupType); continue; } gid = doLookup(lookupTable, gid); } return gid; }
int coverageOffset = data.readUnsignedShort(); lookupSubTable.deltaGlyphID = data.readSignedShort(); lookupSubTable.coverageTable = readCoverageTable(data, offset + coverageOffset); return lookupSubTable; lookupSubTable.coverageTable = readCoverageTable(data, offset + coverageOffset); return lookupSubTable;
table = new GlyphSubstitutionTable(font);
String scriptTag = selectScriptTag(scriptTags); Collection<LangSysTable> langSysTables = getLangSysTables(scriptTag); List<FeatureRecord> featureRecords = getFeatureRecords(langSysTables, enabledFeatures); int sgid = gid; for (FeatureRecord featureRecord : featureRecords) sgid = applyFeature(featureRecord, sgid);
if (containsFeature(result, "vrt2")) removeFeature(result, "vert");