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

Fix: Handle Undefined Axis Property Error #317

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
21 changes: 12 additions & 9 deletions src/TTFFont.js
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ export default class TTFFont {
}

_decodeDirectory() {
return this.directory = Directory.decode(this.stream, {_startOffset: 0});
return this.directory = Directory.decode(this.stream, { _startOffset: 0 });
}

_decodeTable(table) {
@@ -101,12 +101,12 @@ export default class TTFFont {
if (record) {
// Attempt to retrieve the entry, depending on which translation is available:
return (
record[lang]
|| record[this.defaultLanguage]
|| record[fontkit.defaultLanguage]
|| record['en']
|| record[Object.keys(record)[0]] // Seriously, ANY language would be fine
|| null
record[lang]
|| record[this.defaultLanguage]
|| record[fontkit.defaultLanguage]
|| record['en']
|| record[Object.keys(record)[0]] // Seriously, ANY language would be fine
|| null
);
}

@@ -449,8 +449,9 @@ export default class TTFFont {
}

for (let axis of this.fvar.axis) {
const name = axis.name && axis.name.en ? axis.name.en : axis.axisTag.trim();
res[axis.axisTag.trim()] = {
name: axis.name.en,
name,
min: axis.minValue,
default: axis.defaultValue,
max: axis.maxValue
@@ -481,7 +482,9 @@ export default class TTFFont {
settings[axis.axisTag.trim()] = instance.coord[i];
}

res[instance.name.en] = settings;
// use instance.postscriptNameID as fallback name for namedVariations when the name is not available
const name = instance.name && instance.name.en ? instance.name.en : `PS${instance.postscriptNameID}`;
res[name] = settings;
}

return res;