Skip to content
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