Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSUB lookup table type 7 subtable format 1 #486

Merged
merged 3 commits into from
Feb 26, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/features/featureQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,27 @@ function chainingSubstitutionFormat3(contextParams, subtable) {
const lookupListIndex = lookupRecord.lookupListIndex;
const lookupTable = this.getLookupByIndex(lookupListIndex);
for (let s = 0; s < lookupTable.subtables.length; s++) {
const subtable = lookupTable.subtables[s];
const lookup = this.getLookupMethod(lookupTable, subtable);
const substitutionType = this.getSubstitutionType(lookupTable, subtable);
let subtable = lookupTable.subtables[s];
let lookup;
let substitutionType = this.getSubstitutionType(lookupTable, subtable);

if (substitutionType === '71') {
// This is an extension subtable, so lookup the target subtable
substitutionType = this.getSubstitutionType(subtable, subtable.extension);
lookup = this.getLookupMethod(subtable, subtable.extension);
subtable = subtable.extension;
} else {
lookup = this.getLookupMethod(lookupTable, subtable);
}

if (substitutionType === '12') {
for (let n = 0; n < inputLookups.length; n++) {
const glyphIndex = contextParams.get(n);
const substitution = lookup(glyphIndex);
if (substitution) substitutions.push(substitution);
}
} else {
throw new Error(`Substitution type ${substitutionType} is not supported in chaining substitution`);
}
}
}
Expand Down Expand Up @@ -367,9 +379,19 @@ FeatureQuery.prototype.lookupFeature = function (query) {
const lookupTable = lookups[l];
const subtables = this.getLookupSubtables(lookupTable);
for (let s = 0; s < subtables.length; s++) {
const subtable = subtables[s];
const substType = this.getSubstitutionType(lookupTable, subtable);
const lookup = this.getLookupMethod(lookupTable, subtable);
let subtable = subtables[s];
let substType = this.getSubstitutionType(lookupTable, subtable);
let lookup;

if (substType === '71') {
// This is an extension subtable, so lookup the target subtable
substType = this.getSubstitutionType(subtable, subtable.extension);
lookup = this.getLookupMethod(subtable, subtable.extension);
subtable = subtable.extension;
} else {
lookup = this.getLookupMethod(lookupTable, subtable);
}

let substitution;
switch (substType) {
case '11':
Expand Down