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

Treat nameID 2 and 17 both as name record and font-feature record #324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 20 additions & 9 deletions src/tables/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const NAMES = [
];

NameTable.process = function(stream) {
var records = {};
let records = {};

for (let record of this.records) {
// find out what language this is for
let language = LANGUAGES[record.platformID][record.languageID];
Expand All @@ -77,17 +78,27 @@ NameTable.process = function(stream) {

// if the nameID is >= 256, it is a font feature record (AAT)
let key = record.nameID >= 256 ? 'fontFeatures' : (NAMES[record.nameID] || record.nameID);
if (records[key] == null) {
records[key] = {};
}

let obj = records[key];
if (record.nameID >= 256) {
obj = obj[record.nameID] || (obj[record.nameID] = {});
let addRecord = (key, record) => {
if (records[key] == null) {
records[key] = {};
}

let obj = records[key];
if (key === 'fontFeatures') {
obj = obj[record.nameID] || (obj[record.nameID] = {});
}

if (typeof record.string === 'string' || typeof obj[language] !== 'string') {
obj[language] = record.string;
}
}

if (typeof record.string === 'string' || typeof obj[language] !== 'string') {
obj[language] = record.string;
addRecord(key, record);

// if the nameID is 2 or 17, it may also be a font feature record (AAT).
if (record.nameID == 2 || record.nameID == 17) {
addRecord('fontFeatures', record);
}
}

Expand Down