diff --git a/font-src/gen/otd-conv/glyph-name.js b/font-src/gen/otd-conv/glyph-name.js index 91f9c1154..793581431 100644 --- a/font-src/gen/otd-conv/glyph-name.js +++ b/font-src/gen/otd-conv/glyph-name.js @@ -1,4 +1,4 @@ -const { Joining } = require("../../support/gr"); +const { Joining, AnyCv, TieMark } = require("../../support/gr"); const ApplePostNames = new Map([ /* spell-checker: disable */ @@ -261,7 +261,7 @@ const ApplePostNames = new Map([ /* spell-checker: enable */ ]); -function nameSingleGlyph(gid, gSrc, primaryUnicode, conflictSet) { +function nameSingleGlyph1(gid, gSrc, primaryUnicode, conflictSet) { if (gid === 0) return ".notdef"; if (gid === 1) return ".null"; @@ -272,11 +272,7 @@ function nameSingleGlyph(gid, gSrc, primaryUnicode, conflictSet) { } if (preferredName && !conflictSet.has(preferredName)) { conflictSet.add(preferredName); - } else { - preferredName = `.gid${gid}`; } - - preferredName = Joining.amendOtName(preferredName, Joining.get(gSrc)); return preferredName; } @@ -284,4 +280,31 @@ function formatCodePointHex(u) { return u.toString(16).padStart(4, "0").toUpperCase(); } -exports.nameSingleGlyph = nameSingleGlyph; +function nameSingleGlyph2(gSrcBase, baseName, internalNameMap, conflictSet) { + if (!baseName) return; + for (const cv of AnyCv.query(gSrcBase)) { + nameByGr(cv, gSrcBase, baseName, internalNameMap, conflictSet); + } + if (TieMark.get(gSrcBase)) { + nameByGr(TieMark, gSrcBase, baseName, internalNameMap, conflictSet); + } +} +function nameByGr(gr, gSrcBase, baseName, internalNameMap, conflictSet) { + const gnDst = gr.get(gSrcBase); + const gOtDst = internalNameMap.get(gnDst); + const nameT = gr.amendOtName(baseName); + if (gOtDst && !gOtDst.name && !conflictSet.has(nameT)) { + conflictSet.add(nameT); + gOtDst.name = nameT; + } +} + +function nameSingleGlyph3(gid, gSrc, gnOrig) { + if (!gnOrig) gnOrig = `.gid${gid}`; + gnOrig = Joining.amendOtName(gnOrig, Joining.get(gSrc)); + return gnOrig; +} + +exports.nameSingleGlyph1 = nameSingleGlyph1; +exports.nameSingleGlyph2 = nameSingleGlyph2; +exports.nameSingleGlyph3 = nameSingleGlyph3; diff --git a/font-src/gen/otd-conv/glyphs.js b/font-src/gen/otd-conv/glyphs.js index 104ddea0f..6909aa7f0 100644 --- a/font-src/gen/otd-conv/glyphs.js +++ b/font-src/gen/otd-conv/glyphs.js @@ -1,6 +1,6 @@ const { Ot } = require("ot-builder"); const Point = require("../../support/point"); -const { nameSingleGlyph } = require("./glyph-name"); +const { nameSingleGlyph1, nameSingleGlyph2, nameSingleGlyph3 } = require("./glyph-name"); class MappedGlyphStore { constructor() { @@ -48,8 +48,22 @@ class MappedGlyphStore { let conflictSet = new Set(); let rev = new Map(); for (const [u, g] of this.m_primaryUnicodeMapping) rev.set(g, u); + for (const [gSrc, gOt] of this.m_mapping) gOt.name = undefined; + + // Name by Unicode + gid = 0; for (const [gSrc, gOt] of this.m_mapping) { - gOt.name = nameSingleGlyph(gid, gSrc, rev.get(gSrc), conflictSet); + gOt.name = nameSingleGlyph1(gid, gSrc, rev.get(gSrc), conflictSet); + gid++; + } + // Name by CV + for (const [gSrcBase, gOtBase] of this.m_mapping) { + nameSingleGlyph2(gSrcBase, gOtBase.name, this.m_nameMapping, conflictSet); + } + // Name rest + gid = 0; + for (const [gSrc, gOt] of this.m_mapping) { + gOt.name = nameSingleGlyph3(gid, gSrc, gOt.name); gid++; } } diff --git a/font-src/glyphs/letter/latin/z.ptl b/font-src/glyphs/letter/latin/z.ptl index 1881269e4..28faaa34e 100644 --- a/font-src/glyphs/letter/latin/z.ptl +++ b/font-src/glyphs/letter/latin/z.ptl @@ -331,4 +331,4 @@ glyph-block Letter-Latin-Z : begin CreateAccentedComposition 'zBar' 0x1B6 'z/reduced' 'barOver' CreateAccentedComposition 'ZCaron' 0x17D 'Z' 'caronAbove' CreateAccentedComposition 'zCaron' 0x17E 'z' 'caronAbove' - CreateAccentedComposition 'zRTailBR' 0x290 'z/rtailBase' 'rtailBR' + derive-composites 'zRTailBR' 0x290 'z/rtailBase' 'rtailBR' diff --git a/font-src/support/gr.js b/font-src/support/gr.js index 2ea2bf8d3..38759babc 100644 --- a/font-src/support/gr.js +++ b/font-src/support/gr.js @@ -72,6 +72,9 @@ const TieMark = { }, amendName(name) { return `TieMark{${name}}`; + }, + amendOtName(name) { + return name + ".tieMark"; } }; @@ -167,6 +170,9 @@ function Cv(tag, rank) { }, amendName(name) { return name + "." + key; + }, + amendOtName(name) { + return name + "." + tag + "-" + rank; } }; CvTagCache.set(key, rel);