From c83c8689f2f88862eccd2fb4263d1ee459ec1954 Mon Sep 17 00:00:00 2001 From: kiliman Date: Tue, 12 Sep 2017 15:43:26 -0400 Subject: [PATCH] Patch names --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index daf43d8..94cd607 100644 --- a/index.js +++ b/index.js @@ -54,6 +54,18 @@ async function patchNames(dom) { const names = xpath.select('/name/namerecord', configDom); const targetName = xpath.select('/ttFont/name', dom, true); + // get font and family name + const familyName = getTextNode(configDom, '/name/namerecord[@nameID="1" and @platformID="1"]'); + const fullName = getTextNode(configDom, '/name/namerecord[@nameID="4" and @platformID="1"]'); + + // patch CFFFont + const cffFont = xpath.select('/ttFont/CFF/CFFFont', dom, true); + + cffFont.setAttribute('name', ligFontName); + setAttribute(cffFont, 'FullName', 'value', fullName); + setAttribute(cffFont, 'FamilyName', 'value', familyName); + + // update existing names with new names names.forEach(node => { const nameId = node.getAttribute('nameID'); const platformId = node.getAttribute('platformID');