From 660c719779f5df16dbe2387463566b61126757fb Mon Sep 17 00:00:00 2001 From: Emanuele Ballarin Date: Sun, 17 Jun 2018 04:27:58 +0200 Subject: [PATCH] Fix font family names in PS and TTF metadata Fix font family names in PS and TTF metadata, as already defined in original font and master branch --- index.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 78d3a9f..8abfda1 100644 --- a/index.js +++ b/index.js @@ -184,16 +184,26 @@ const patchNames = (dom, ligatures, profile) => { ); const [name, style] = names.fontName.split('-'); + var [familyStyle, fullNameStyleTry] = names.fontStyle.split(' '); + + let fullNameStyle + if (fullNameStyleTry) { + fullNameStyle = fullNameStyleTry; + } else { + fullNameStyle = ""; + } + const fontName = `${name}${profile.suffixWithLeadingHyphen}-${style}`; - const familyName = `${names.familyName}${profile.suffixWithLeadingSpace}`; - const fullName = `${familyName} ${names.fontStyle}`; + const familyNamePlat = `${ names.familyName }${ profile.suffixWithLeadingSpace }`; + const familyName = `${ familyNamePlat } ${ familyStyle }`; + const fullName = `${ familyName } ${ fullNameStyle }`; const uniqueId = `${names.foundry}: ${fullName}: ${names.version}`; // 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); + setAttribute(cffFont, 'FamilyName', 'value', familyNamePlat); // update existing names with new names updateName(PlatformId.mac, NameId.familyName, familyName); @@ -201,7 +211,7 @@ const patchNames = (dom, ligatures, profile) => { updateName(PlatformId.mac, NameId.uniqueId, uniqueId); updateName(PlatformId.mac, NameId.fullName, fullName); updateName(PlatformId.mac, NameId.postscriptName, fontName); - updateName(PlatformId.mac, NameId.windowsFamilyName, familyName); + updateName(PlatformId.mac, NameId.windowsFamilyName, familyNamePlat); updateName(PlatformId.mac, NameId.fontStyleName, names.fontStyle); updateName(PlatformId.win, NameId.familyName, familyName); @@ -209,7 +219,7 @@ const patchNames = (dom, ligatures, profile) => { updateName(PlatformId.win, NameId.uniqueId, uniqueId); updateName(PlatformId.win, NameId.fullName, fullName); updateName(PlatformId.win, NameId.postscriptName, fontName); - updateName(PlatformId.win, NameId.windowsFamilyName, familyName); + updateName(PlatformId.win, NameId.windowsFamilyName, familyNamePlat); updateName(PlatformId.win, NameId.fontStyleName, names.fontStyle); };