From 5362d447fec3ebb137af26890b05ca5236ffff36 Mon Sep 17 00:00:00 2001 From: Nicolas Lebrun Date: Tue, 7 May 2024 20:51:13 +0200 Subject: [PATCH] fix some grapheme --- demo/src/index.ts | 16 +++++---- demo/style.css | 9 +++++ src/glyphs/diacritics.ts | 24 +++++++++---- src/glyphs/lowercase/base.ts | 42 ++++++++++++++++------ src/glyphs/lowercase/diaBaseAssociation.ts | 22 ++++++------ src/glyphs/lowercase/index.ts | 17 ++++----- 6 files changed, 86 insertions(+), 44 deletions(-) diff --git a/demo/src/index.ts b/demo/src/index.ts index 6112dd5..ed41925 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -35,15 +35,16 @@ const upscaleGlyph = (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0] * 1.1 - 0.05, p[1] * 1.1 - 0.05])); const scaleGlyph = (g: Glyph) => - g.map((l: Line) => l.map((p: Vec) => [0.166 + p[0] * 0.66, 0.166 + p[1] * 0.66])); + g.map((l: Line) => + l.map((p: Vec) => [0.166 + p[0] * 0.66, 0.166 + p[1] * 0.66]), + ); const mirrorYGlyph = (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], 1 - p[1]])); const mirrorXGlyph = (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [1 - p[0], p[1]])); // font["ɜ"] = mirrorYGlyph(font["ɛ"]) -// alert(`ʁ: ${JSON.stringify(scaleGlyph(rotateGlyph(font["R"])))},`); - +//alert(`ʁ: ${JSON.stringify(scaleGlyph(mirrorXGlyph(rotateGlyph(font["R"]))))},`); for (let l = 0; l < lowercase.length; l++) { if (font[lowercase[l]] === undefined) { @@ -98,9 +99,12 @@ const update = () => { rect.setAttribute("width", `${textSize[0]}`); rect.setAttribute("height", `${textSize[1]}`); rect.setAttribute("title", char); - const title = document.createElementNS(namespace, "title"); - title.textContent = char; - rect.appendChild(title); + const label = document.createElementNS(namespace, "text"); + label.setAttribute("x", `${margin[0] + x * textSize[0] + 10}`); + label.setAttribute("y", `${margin[1] + y * textSize[1] + 20}`); + label.setAttribute("font-size", `${fontScale*20}em`) + label.textContent = char; + group.appendChild(label); lines.map((d: string) => { const path = document.createElementNS(namespace, "path"); diff --git a/demo/style.css b/demo/style.css index 8648d10..0e87ce6 100644 --- a/demo/style.css +++ b/demo/style.css @@ -65,6 +65,15 @@ footer p { stroke-width: 0.5px; } + +#app svg g text { + fill: #000; + stroke: rgba(0, 0, 0, 0); + stroke-width: 0; +} + + + @media screen and (min-width: 900px) { #app form input { display: block; diff --git a/src/glyphs/diacritics.ts b/src/glyphs/diacritics.ts index 6ad96a7..08df11f 100644 --- a/src/glyphs/diacritics.ts +++ b/src/glyphs/diacritics.ts @@ -117,11 +117,11 @@ const diacritics = { // angstorm or circle or ring (top) gs: [ [ - [0.45, 0.2], [0.45, 0.15], + [0.45, 0.1], + [0.55, 0.1], [0.55, 0.15], - [0.55, 0.2], - [0.45, 0.2], + [0.45, 0.15], ], ], // cedilla @@ -183,6 +183,7 @@ const diacritics = { [ [0.85, 0.7], [0.85, 0.85], + [0.83, 0.88], [0.75, 0.9] ] ], @@ -196,17 +197,18 @@ const diacritics = { // horn hr: [ [ - [0.85, 0.3], - [0.9, 0.25], + [0.85, 0.4], + [0.9, 0.35], [0.9, 0.2], ], ], // cross (right) crs: [ [ - [0.85, 0.3], - [0.85, 0.25], [0.90, 0.2], + [0.87, 0.22], + [0.85, 0.25], + [0.85, 0.3], ] , ], // barred (kind of /) @@ -232,6 +234,14 @@ const diacritics = { [0.5, 0.79], [0.55, 0.8] ] + ], + // coma + cm: [ + [ + [0.5, 0.75], + [0.49, 0.79], + [0.45, 0.8], + ], ] } as Font; diff --git a/src/glyphs/lowercase/base.ts b/src/glyphs/lowercase/base.ts index 1387afd..3929ff7 100644 --- a/src/glyphs/lowercase/base.ts +++ b/src/glyphs/lowercase/base.ts @@ -313,7 +313,7 @@ const base = { ɗ: [ [ [0.95, 0.1], - [0.9, 0.1], + [0.91, 0.11], [0.85, 0.15], [0.85, 0.725], ], @@ -327,6 +327,7 @@ const base = { ƌ: [ [ [0.15, 0.15], + [0.85, 0.15], [0.85, 0.725], ], [ @@ -892,8 +893,8 @@ const base = { [0.15, 0.9], ], [ - [0.45, 0.45], - [0.75, 0.45], + [0.45, 0.65], + [0.75, 0.65], ], ], ʄ: [ @@ -906,8 +907,8 @@ const base = { [0.15, 0.9], ], [ - [0.45, 0.45], - [0.75, 0.45], + [0.45, 0.65], + [0.75, 0.65], ], ], @@ -1586,15 +1587,15 @@ const base = { ], ʁ: [ [ - [0.73, 0.5], [0.265, 0.5], - [0.265, 0.7], + [0.73, 0.5], [0.73, 0.7], - [0.73, 0.364], + [0.265, 0.7], + [0.265, 0.364], ], [ - [0.73, 0.5], - [0.265, 0.364], + [0.265, 0.496], + [0.7270000000000001, 0.36400000000000005], ], ], @@ -1608,6 +1609,27 @@ const base = { [0.15, 0.7], ], ], + ſ: [ + [ + [0.85, 0.3], + [0.35, 0.3], + [0.35, 0.9], + ], + ], + ß: [ + [ + [0.15, 0.7], + [0.15, 0.25], + [0.5, 0.25], + [0.5, 0.35], + [0.35, 0.35], + [0.35, 0.5], + [0.85, 0.5], + [0.85, 0.7], + [0.35, 0.7], + ], + ], + t: [ [ [0.15, 0.3], diff --git a/src/glyphs/lowercase/diaBaseAssociation.ts b/src/glyphs/lowercase/diaBaseAssociation.ts index 9819c1e..90d5902 100644 --- a/src/glyphs/lowercase/diaBaseAssociation.ts +++ b/src/glyphs/lowercase/diaBaseAssociation.ts @@ -56,7 +56,7 @@ const diaBaseAssociation = { ḍ: ["d", ["db"]], ḓ: ["d", ["crb"]], ḏ: ["d", ["lb"]], - ɖ: ["d", ["crs"]], + ɖ: ["d", ["gnk"]], // e é: ["e", ["ct"]], è: ["e", ["gr"]], @@ -69,7 +69,7 @@ const diaBaseAssociation = { ě: ["e", ["hc"]], ë: ["e", ["dr"]], ẽ: ["e", ["tl"]], - ė: ["e", ["gs"]], + ė: ["e", ["da"]], ȩ: ["e", ["cd"]], ḝ: ["e", ["br", "cd"]], ę: ["e", ["gnk"]], @@ -96,14 +96,14 @@ const diaBaseAssociation = { ġ: ["g", ["da"]], ģ: ["g", ["gr"]], ḡ: ["g", ["mc"]], - ɠ: ["g", ["hr"]], + ɠ: ["g", ["crs"]], // h ĥ: ["h", ["cr"]], ȟ: ["h", ["hc"]], ḧ: ["h", ["dr"]], ḣ: ["h", ["da"]], - ḩ: ["h", ["cdl"]], + ḩ: ["h", ["cd"]], ḥ: ["h", ["db"]], ḫ: ["h", ["brb"]], ẖ: ["h", ["lb"]], @@ -117,7 +117,7 @@ const diaBaseAssociation = { ï: ["ı", ["dr"]], ḯ: ["ı", ["ct", "dr"]], ĩ: ["ı", ["tl"]], - į: ["i", ["gnk"]], + į: ["i", ["gnkc"]], ī: ["ı", ["mc"]], ỉ: ["ı", ["ha"]], ȉ: ["ı", ["gr", "gr"]], @@ -134,7 +134,7 @@ const diaBaseAssociation = { // k ḱ: ["k", ["ct"]], ǩ: ["k", ["hc"]], - ķ: ["k", ["cdr"]], + ķ: ["k", ["cm"]], ḳ: ["k", ["db"]], ḵ: ["k", ["lb"]], @@ -159,7 +159,7 @@ const diaBaseAssociation = { ň: ["n", ["hc"]], ñ: ["n", ["tl"]], ṅ: ["n", ["da"]], - ņ: ["n", ["cd"]], + ņ: ["n", ["cm"]], ṇ: ["n", ["db"]], ṋ: ["n", ["crb"]], ṉ: ["n", ["lb"]], @@ -214,9 +214,9 @@ const diaBaseAssociation = { ŕ: ["r", ["ct"]], ř: ["r", ["hc"]], ṙ: ["r", ["da"]], - ŗ: ["r", ["cdl"]], + ŗ: ["r", ["cm"]], ȑ: ["r", ["gr", "gr"]], - ȓ: ["r", ["br"]], + ȓ: ["r", ["bri"]], ṛ: ["r", ["db"]], ṝ: ["r", ["db", "mc"]], ṟ: ["r", ["lb"]], @@ -231,7 +231,9 @@ const diaBaseAssociation = { ş: ["s", ["cd"]], ṣ: ["s", ["db"]], ṩ: ["s", ["da", "db"]], - + ș: ["s", ["cm"]], + ẛ: ["ſ", ["da"]], + ʂ: ["s", ["gnk"]], // u ụ: ["u", ["db"]], ủ: ["u", ["ha"]], diff --git a/src/glyphs/lowercase/index.ts b/src/glyphs/lowercase/index.ts index 24c420c..c8a9cd4 100644 --- a/src/glyphs/lowercase/index.ts +++ b/src/glyphs/lowercase/index.ts @@ -18,14 +18,15 @@ const topDia = [ "gs", "da", "ha", + "hc" ] as Array; const topDiaCount = (diaKey: keyof Font): number => topDia.includes(diaKey) ? 1 : 0; const moveDia = { - tp: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], p[1] - 0.2])), - bt: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], p[1] + 0.08])), + tp: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], p[1] - 0.125])), + bt: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], p[1] + 0.1])), lf: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0] - 0.125, p[1]])), rg: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0] + 0.125, p[1]])), }; @@ -67,7 +68,7 @@ const mergeDia = (diaKeys: DiaGroup): Glyph => { moveDia.bt(diacritics["tl"]), ); } - // move tild down + // move hacek down else if (diaKeys.includes("hc")) { return joinVector( diaKeys.filter((k) => k != "hc").map((k) => diacritics[k]), @@ -94,14 +95,8 @@ const mergeDia = (diaKeys: DiaGroup): Glyph => { diaKeys.filter((k) => k != "gr").map((k) => diacritics[k]), moveDia.bt(diacritics["gr"]), ); - } - // move breve bottom - else if (diaKeys.includes("br")) { - return joinVector( - diaKeys.filter((k) => k != "br").map((k) => diacritics[k]), - moveDia.bt(diacritics["br"]), - ); - } else { + } + else { return diaKeys.reduce( (acc: Glyph, k: keyof Font) => [...acc, ...diacritics[k]], [] as Glyph,