From 3572375777818bec2bc771ba2d8e11b2c36a8238 Mon Sep 17 00:00:00 2001 From: Nicolas Lebrun Date: Sun, 5 May 2024 13:57:07 +0200 Subject: [PATCH] egh diacrtics --- demo/src/index.ts | 86 ++++-- src/glyphs/diacritics.ts | 9 + src/glyphs/lowercase/base.ts | 327 ++++++++++++++++++++- src/glyphs/lowercase/diaBaseAssociation.ts | 58 +++- src/glyphs/lowercase/index.ts | 77 +++-- src/glyphs/uppercase.ts | 2 +- 6 files changed, 477 insertions(+), 82 deletions(-) diff --git a/demo/src/index.ts b/demo/src/index.ts index 8304417..9dd4f42 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -1,8 +1,33 @@ import { font, getGlyphPath } from "../../src/index.ts"; import { Glyph, Line, Vec } from "../../src/type"; - - -const lowercase = ["a","á","à","ă","ắ","ằ","ẵ","ẳ","â","ấ","ầ","ẫ","ẩ","ǎ","å","ǻ","ä","ǟ","ã","ȧ","ǡ","ą","ā","ả","ȁ","ȃ","ạ","ặ","ậ","ḁ","æ","ǽ","ǣ","ẚ","ɐ","ɑ","ɒ","b","ḃ","ḅ","ḇ","ʙ","ƀ","ɓ","ƃ","c","ć","ĉ","č","ċ","ç","ḉ","ȼ","ƈ","ɕ","d","ď","ḋ","ḑ","đ","ḍ","ḓ","ḏ","ð","ȸ","dz","ʣ","dž","ʥ","ʤ","ɖ","ɗ","ƌ","ȡ","ẟ","e","é","è","ĕ","ê","ế","ề","ễ","ể","ě","ë","ẽ","ė","ȩ","ḝ","ę","ē","ḗ","ḕ","ẻ","ȅ","ȇ","ẹ","ệ","ḙ","ḛ","ɇ","ǝ","ə","ɛ","ɘ","ɚ","ɜ","ɝ","ɞ","ʚ","ɤ","f","ḟ","ʩ","ƒ","g","ǵ","ğ","ĝ","ǧ","ġ","ģ","ḡ","ɡ","ɢ","ǥ","ɠ","ʛ","ɣ","ƣ","h","ĥ","ȟ","ḧ","ḣ","ḩ","ħ","ḥ","ḫ","ẖ","ʜ","ƕ","ɦ","ɧ","i","í","ì","ĭ","î","ǐ","ï","ḯ","ĩ","į","ī","ỉ","ȉ","ȋ","ị","ḭ","ij","ı","ɪ","ɨ","ɩ","j","ĵ","ǰ","ȷ","ɉ","ʝ","ɟ","ʄ","k","ḱ","ǩ","ķ","ḳ","ḵ","ƙ","ʞ","l","ĺ","ľ","ļ","ł","ḷ","ḹ","ḽ","ḻ","ŀ","lj","ỻ","ʪ","ʫ","ʟ","ƚ","ɫ","ɬ","ɭ","ȴ","ɮ","ƛ","ʎ","m","ḿ","ṁ","ṃ","ɱ","n","ń","ǹ","ň","ñ","ṅ","ņ","ṇ","ṋ","ṉ","nj","ɴ","ɲ","ƞ","ɳ","ȵ","ŋ","o","ó","ò","ŏ","ô","ố","ồ","ỗ","ổ","ǒ","ö","ȫ","ő","õ","ṍ","ṏ","ȭ","ȯ","ȱ","ø","ǿ","ǫ","ǭ","ō","ṓ","ṑ","ỏ","ȍ","ȏ","ơ","ớ","ờ","ỡ","ở","ợ","ọ","ộ","œ","ɶ","ɔ","ɵ","ɷ","ȣ","p","ṕ","ṗ","ƥ","ɸ","q","ȹ","ʠ","ɋ","ĸ","r","ŕ","ř","ṙ","ŗ","ȑ","ȓ","ṛ","ṝ","ṟ","ʀ","ɍ","ɹ","ɺ","ɻ","ɼ","ɽ","ɾ","ɿ","ʁ","s","ś","ṥ","ŝ","š","ṧ","ṡ","ş","ṣ","ṩ","ș","ſ","ẛ","ß","ʂ","ȿ","ẜ","ẝ","ʃ","ƪ","ʅ","ʆ","t","ť","ẗ","ṫ","ţ","ṭ","ț","ṱ","ṯ","ʨ","ƾ","ʦ","ʧ","ŧ","ƫ","ƭ","ʈ","ȶ","ʇ","u","ú","ù","ŭ","û","ǔ","ů","ü","ǘ","ǜ","ǚ","ǖ","ű","ũ","ṹ","ų","ū","ṻ","ủ","ȕ","ȗ","ư","ứ","ừ","ữ","ử","ự","ụ","ṳ","ṷ","ṵ","ʉ","ɥ","ʮ","ʯ","ɯ","ɰ","ʊ","v","ṽ","ṿ","ʋ","ỽ","ʌ","w","ẃ","ẁ","ŵ","ẘ","ẅ","ẇ","ẉ","ʍ","x","ẍ","ẋ","y","ý","ỳ","ŷ","ẙ","ÿ","ỹ","ẏ","ȳ","ỷ","ỵ","ʏ","ɏ","ƴ","ỿ","ȝ","z","ź","ẑ","ž","ż","ẓ","ẕ","ƍ","ƶ","ȥ","ʐ","ʑ","ɀ","ʒ","ǯ","ƹ","ƺ","ʓ","þ","ƿ","ƨ","ƽ","ƅ","ɂ","ʕ","ʡ","ʢ","ʖ","ʗ","ʘ","ʬ","ʭ"] +const lowercase = [ + ..."aáàăắằẵẳâấầẫẩǎåǻäǟãȧǡąāảȁȃạặậḁæǽǣẚɐɑɒ", + ..."bḃḅḇʙƀɓƃ", + ..."cćĉčċçḉȼƈɕ", + ..."dďḋḑđḍḓḏðȸdzʣdžʥʤɖɗƌȡẟ", + ..."eéèĕêếềễểěëẽėȩḝęēḗḕẻȅȇẹệḙḛɇǝəɛɘɚɜɝɞʚɤ", + ..."fḟʩƒ", + ..."gǵğĝǧġģḡɡɢǥɠʛɣ", + ..."ƣhĥȟḧḣḩħḥḫẖʜƕɦɧ", + ..."iíìĭîǐïḯĩįīỉȉȋịḭijıɪɨɩ", + ..."jĵǰȷɉʝɟʄ", + ..."kḱǩķḳḵƙʞ", + ..."lĺľļłḷḹḽḻŀljỻʪʫʟƚɫɬɭȴɮƛʎ", + ..."mḿṁṃɱ", + ..."nńǹňñṅņṇṋṉnjɴɲƞɳȵŋ", + ..."oóòŏôốồỗổǒöȫőõṍṏȭȯȱøǿǫǭōṓṑỏȍȏơớờỡởợọộœɶɔɵɷȣ", + ..."pṕṗƥɸqȹʠ", + ..."ɋĸ", + ..."rŕřṙŗȑȓṛṝṟʀɍɹɺɻɼɽɾɿʁ", + ..."sśṥŝšṧṡşṣṩșſẛßʂȿẜẝʃƪʅʆ", + ..."tťẗṫţṭțṱṯʨƾʦʧŧƫƭʈȶʇ", + ..."uúùŭûǔůüǘǜǚǖűũṹųūṻủȕȗưứừữửựụṳṷṵʉɥʮʯɯɰʊ", + ..."vṽṿʋỽʌ", + ..."wẃẁŵẘẅẇẉʍ", + ..."xẍẋ", + ..."yýỳŷẙÿỹẏȳỷỵʏɏƴỿȝ", + ..."zźẑžżẓẕƍƶȥʐʑɀʒǯƹƺʓþƿƨƽƅɂʕʡʢʖʗʘʬʭ", +]; /* console.log( JSON.stringify( @@ -13,23 +38,30 @@ console.log( ); */ +const rotateGlyph = (g: Glyph) => + g.map((l: Line) => l.map((p: Vec) => [1 - p[0], 1 - p[1]])); +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 rotateGlyph = (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [1 - p[0], 1 - p[1]])) -const scaleGlyph = (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [0.25 + p[0] * 0.5, 0.25 + p[1] * 0.5])) +const scaleGlyph = (g: Glyph) => + g.map((l: Line) => l.map((p: Vec) => [0.166 + p[0] * 0.66, 0.166 + p[1] * 0.66])); +const mirrorXGlyph = (g: Glyph) => + g.map((l: Line) => l.map((p: Vec) => [p[0], 1 - p[1]])); +const mirrorYGlyph = (g: Glyph) => + g.map((l: Line) => l.map((p: Vec) => [1 - p[0], p[1]])); -// font["ʙ"] = scaleGlyph(font["B"]) -// console.log(JSON.stringify(scaleGlyph(font['6']))) +// font["ɜ"] = mirrorYGlyph(font["ɛ"]) +console.log(JSON.stringify(scaleGlyph(font["H"]))); for (let l = 0; l < lowercase.length; l++) { - if (font[lowercase[l]] === undefined) { - console.log(`%c ${lowercase[l]}`, "font-size: 3em" ) + if (font[lowercase[l]] === undefined) { + console.log(`%c ${lowercase[l]}`, "font-size: 3em"); break; } else { - console.log(`✅${lowercase[l]}`) - } + console.log(`%c ✅${lowercase[l]}`, "font-size: 2.5em"); + } } - const app = document.getElementById("app"), form = document.createElement("form"), namespace = "http://www.w3.org/2000/svg", @@ -41,40 +73,42 @@ const app = document.getElementById("app"), group = document.createElementNS(namespace, "g"); const update = () => { - let height = window.innerHeight + let height = window.innerHeight; const userInput = input.value !== textAtLaunch ? input.value : glyphKeys, text = userInput.split("") as string[], fontScale = parseFloat(inputSize.value), width = window.innerWidth - 40, - baseSize = Math.max(16, Math.min(Math.floor(Math.hypot(width, height) * fontScale), 264)), + baseSize = Math.max( + 16, + Math.min(Math.floor(Math.hypot(width, height) * fontScale), 264), + ), textSize = [baseSize, baseSize], charPerLine = Math.floor(width / textSize[0]) - 2, nbLines = Math.ceil(text.length / charPerLine), - margin = [ - (width - charPerLine * textSize[0]) / 2, - 40, - ]; + margin = [(width - charPerLine * textSize[0]) / 2, 40]; group.textContent = ""; for (let y = 0; y < nbLines; y++) { const remainingChar = Math.min(charPerLine, text.length - y * charPerLine); - if ((y+1)*textSize[1] >= height-margin[1]) height += (textSize[1]+margin[1]) + if ((y + 1) * textSize[1] >= height - margin[1]) + height += textSize[1] + margin[1]; for (let x = 0; x < remainingChar; x++) { const char = text[y * charPerLine + x]; const lines = getGlyphPath(char, textSize, [ margin[0] + x * textSize[0], - margin[1] + y * textSize[1], textSize[1] + margin[1] + y * textSize[1], + textSize[1], ]); const rect = document.createElementNS(namespace, "rect"); rect.setAttribute("x", `${margin[0] + x * textSize[0]}`); rect.setAttribute("y", `${margin[1] + y * textSize[1]}`); 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) + rect.setAttribute("title", char); + const title = document.createElementNS(namespace, "title"); + title.textContent = char; + rect.appendChild(title); lines.map((d: string) => { const path = document.createElementNS(namespace, "path"); @@ -87,8 +121,8 @@ const update = () => { group.setAttribute("stroke-width", `${fontScale * 40}`); svg.setAttribute("width", `${width}`); - svg.setAttribute("height", `${height+40}`); - svg.setAttribute("viewbox", `0 0 ${width} ${height+40}`); + svg.setAttribute("height", `${height + 40}`); + svg.setAttribute("viewbox", `0 0 ${width} ${height + 40}`); }; const init = () => { diff --git a/src/glyphs/diacritics.ts b/src/glyphs/diacritics.ts index 2c2f87e..7b44b50 100644 --- a/src/glyphs/diacritics.ts +++ b/src/glyphs/diacritics.ts @@ -72,6 +72,15 @@ const diacritics = { [0.6, 0.1], ], ], + // breve below + brb: [ + [ + [0.4, 0.8], + [0.4, 0.85], + [0.6, 0.85], + [0.6, 0.8] + ] + ], // inverse breve bri: [ [ diff --git a/src/glyphs/lowercase/base.ts b/src/glyphs/lowercase/base.ts index 8954c79..ed43d33 100644 --- a/src/glyphs/lowercase/base.ts +++ b/src/glyphs/lowercase/base.ts @@ -357,7 +357,6 @@ const base = { ], ẟ: [ [ - [0.75, 0.15], [0.5, 0.1], [0.3, 0.1], @@ -365,7 +364,7 @@ const base = { [0.85, 0.5], [0.5, 0.7], [0.15, 0.5], - [0.5, 0.325] + [0.5, 0.325], ], ], @@ -379,6 +378,124 @@ const base = { [0.85, 0.7], ], ], + ə: [ + [ + [0.85, 0.5], + [0.15, 0.5], + [0.15, 0.7], + [0.85, 0.7], + [0.85, 0.3], + [0.15, 0.3], + ], + ], + ǝ: [ + [ + [0.75, 0.5], + [0.25, 0.5], + [0.25, 0.65], + [0.75, 0.65], + [0.75, 0.35], + [0.25, 0.35], + ], + ], + ɛ: [ + [ + [0.75, 0.35], + [0.6, 0.3], + [0.25, 0.4], + [0.6, 0.5], + [0.25, 0.6], + [0.6, 0.7], + [0.75, 0.65], + ], + ], + ɘ: [ + [ + [0.85, 0.5], + [0.15, 0.5], + [0.15, 0.3], + [0.85, 0.3], + [0.85, 0.7], + [0.15, 0.7], + ], + ], + ɚ: [ + [ + [0.95, 0.5], + [0.9, 0.45], + [0.9, 0.4], + [0.15, 0.55], + [0.225, 0.8], + [0.85, 0.7], + [0.75, 0.3], + [0.25, 0.4], + ], + ], + ɜ: [ + [ + [0.25, 0.35], + [0.4, 0.3], + [0.75, 0.4], + [0.4, 0.5], + [0.75, 0.6], + [0.4, 0.7], + [0.25, 0.65], + ], + ], + ɝ: [ + [ + [0.25, 0.35], + [0.4, 0.3], + [0.75, 0.4], + [0.4, 0.5], + [0.75, 0.6], + [0.4, 0.7], + [0.25, 0.65], + ], + [ + [0.85, 0.5], + [0.75, 0.45], + [0.75, 0.4], + ], + ], + ɞ: [ + [ + [0.25, 0.65], + [0.2, 0.55], + [0.2, 0.45], + [0.25, 0.35], + [0.4, 0.3], + [0.75, 0.4], + [0.4, 0.5], + [0.75, 0.6], + [0.4, 0.7], + [0.25, 0.65], + ], + ], + ʚ: [ + [ + [0.75, 0.65], + [0.8, 0.55], + [0.8, 0.45], + [0.75, 0.35], + [0.6, 0.3], + [0.25, 0.4], + [0.6, 0.5], + [0.25, 0.6], + [0.6, 0.7], + [0.75, 0.65], + ], + ], + ɤ: [ + [ + [0.15, 0.3], + [0.65, 0.6], + [0.5, 0.7], + [0.35, 0.6], + [0.85, 0.3], + ], + ], + f: [ [ [0.15, 0.5], @@ -390,6 +507,45 @@ const base = { [0.85, 0.2], ], ], + ʩ: [ + [ + [0.15, 0.5], + [0.5, 0.5], + ], + [ + [0.25, 0.7], + [0.25, 0.2], + [0.5, 0.2], + ], + [ + [0.5, 0.475], + [0.5, 0.7], + ], + [ + [0.5, 0.5], + [0.85, 0.5], + [0.85, 0.8], + [0.825, 0.85], + [0.75, 0.9], + ], + ], + ƒ: [ + [ + [0.15, 0.35], + [0.7, 0.35], + ], + [ + [0.25, 0.825], + [0.3, 0.89], + [0.325, 0.9], + [0.35, 0.89], + [0.4, 0.825], + [0.4, 0.8], + [0.4, 0.2], + [0.85, 0.2], + ], + ], + g: [ [ [0.85, 0.7], @@ -403,6 +559,84 @@ const base = { [0.5, 0.9], ], ], + ɡ: [ + [ + [0.885, 0.72], + [0.115, 0.72], + [0.115, 0.28], + [0.885, 0.28], + ], + [ + [0.885, 0.2525], + [0.885, 0.94], + [0.5, 0.94], + ], + ], + ɢ: [ + [ + [0.725, 0.3], + [0.265, 0.3], + [0.265, 0.628], + [0.725, 0.628], + [0.725, 0.496], + [0.496, 0.496], + ], + ], + ǥ: [ + [ + [0.75, 0.7], + [0.15, 0.7], + [0.15, 0.3], + [0.75, 0.3], + ], + [ + [0.75, 0.275], + [0.75, 0.9], + [0.5, 0.9], + ], + [ + [0.65, 0.8], + [0.85, 0.8], + ], + ], + ʛ: [ + [ + [0.8, 0.2], + [0.75, 0.225], + [0.725, 0.25], + [0.725, 0.3], + [0.265, 0.3], + [0.265, 0.628], + [0.725, 0.628], + [0.725, 0.496], + [0.496, 0.496], + ], + ], + ɣ: [ + [ + [0.35, 0.3], + [0.55, 0.8], + [0.5, 0.85], + [0.45, 0.8], + [0.65, 0.3], + ], + ], + ƣ: [ + [ + [0.15, 0.4], + [0.65, 0.4], + [0.65, 0.75], + [0.15, 0.75], + [0.15, 0.4], + ], + [ + [0.65, 0.4], + [0.75, 0.35], + [0.85, 0.4], + [0.85, 0.9], + ], + ], + h: [ [ [0.15, 0.7], @@ -414,6 +648,90 @@ const base = { [0.85, 0.7], ], ], + ħ: [ + [ + [0.25, 0.7], + [0.25, 0.1], + ], + [ + [0.225, 0.3], + [0.85, 0.3], + [0.85, 0.7], + ], + [ + [0.15, 0.2], + [0.35, 0.2], + ], + ], + ʜ: [ + [ + [0.265, 0.3], + [0.265, 0.628], + ], + [ + [0.265, 0.496], + [0.73, 0.496], + ], + [ + [0.73, 0.3], + [0.73, 0.628], + ], + ], + ƕ: [ + [ + [0.15, 0.7], + [0.15, 0.1], + ], + [ + [0.125, 0.3], + [0.5, 0.3], + [0.5, 0.7], + [0.85, 0.7], + [0.85, 0.3] + ], + ], + ɦ: [ + [ + [0.15, 0.7], + [0.15, 0.2], + [0.16, 0.145], + [0.20, 0.1] + ], + [ + [0.125, 0.3], + [0.85, 0.3], + [0.85, 0.7], + ], + ], + ɧ: [ + [ + [0.15, 0.7], + [0.15, 0.2], + [0.16, 0.145], + [0.20, 0.1] + ], + [ + [0.125, 0.3], + [0.85, 0.3], + [0.85, 0.8], + [0.83, 0.85], + [0.75, 0.9] + ], + ], + + i_: [ + [ + [0.15, 0.3], + [0.5, 0.3], + [0.5, 0.7], + [0.65, 0.7], + ], + [ + [0.15, 0.7], + [0.85, 0.7], + + ] + ], i: [ [ [0.5, 0.1], @@ -425,6 +743,11 @@ const base = { [0.5, 0.7], [0.65, 0.7], ], + [ + [0.15, 0.7], + [0.85, 0.7], + + ] ], j: [ [ diff --git a/src/glyphs/lowercase/diaBaseAssociation.ts b/src/glyphs/lowercase/diaBaseAssociation.ts index 046ebde..6b36611 100644 --- a/src/glyphs/lowercase/diaBaseAssociation.ts +++ b/src/glyphs/lowercase/diaBaseAssociation.ts @@ -58,45 +58,79 @@ const diaBaseAssociation = { ḏ: ["d", ["lb"]], ɖ: ["d", ["crs"]], // e - ẹ: ["e", ["db"]], é: ["e", ["ct"]], è: ["e", ["gr"]], ĕ: ["e", ["br"]], ê: ["e", ["cr"]], + ế: ["e", ["cr", "ct"]], + ề: ["e", ["cr", "gr"]], + ễ: ["e", ["cr", "tl"]], + ể: ["e", ["cr", "ha"]], ě: ["e", ["hc"]], ë: ["e", ["dr"]], + ẽ: ["e", ["tl"]], ė: ["e", ["gs"]], ȩ: ["e", ["cd"]], ḝ: ["e", ["br", "cd"]], ę: ["e", ["gnk"]], ē: ["e", ["mc"]], ḗ: ["e", ["ct", "mc"]], - + ḕ: ["e", ["gr", "mc"]], ẻ: ["e", ["ha"]], - ẽ: ["e", ["tl"]], - ế: ["e", ["cr", "ct"]], - ề: ["e", ["cr", "gr"]], - ể: ["e", ["cr", "ha"]], - ễ: ["e", ["cr", "tl"]], + ȅ: ["e", ["gr", "gr"]], + ȇ: ["e", ["bri"]], + ẹ: ["e", ["db"]], ệ: ["e", ["cr", "db"]], ḙ: ["e", ["crb"]], ḛ: ["e", ["tlb"]], + ɇ: ["e", ["brd"]], // f ḟ: ["f", ["da"]], // g + ǵ: ["g", ["ct"]], + ğ: ["g", ["br"]], + ĝ: ["g", ["cr"]], + ǧ: ["g", ["hc"]], + ġ: ["g", ["da"]], + ģ: ["g", ["gr"]], ḡ: ["g", ["mc"]], + ɠ: ["g", ["hr"]], // h - ḣ: ["h", ["da"]], - ḥ: ["h", ["db"]], + ĥ: ["h", ["cr"]], + ȟ: ["h", ["hc"]], ḧ: ["h", ["dr"]], + ḣ: ["h", ["da"]], ḩ: ["h", ["cdl"]], + ḥ: ["h", ["db"]], + ḫ: ["h", ["brb"]], + ẖ: ["h", ["lb"]], // i - Ỉ: ["i", ["ha"]], - Ị: ["i", ["db"]], + í: ["i_", ["ct"]], + ì: ["i_", ["gr"]], + ĭ: ["i_", ["br"]], + î: ["i_", ["cr"]], + ǐ: ["i_", ["hc"]], + ï: ["i_", ["dr"]], + ḯ: ["i_", ["ct", "dr"]], + ĩ: ["i_", ["tl"]], + į: ["i", ["gnk"]], + ī: ["i_", ["mc"]], + ỉ: ["i_", ["ha"]], + ȉ: ["i_", ["gr", "gr"]], + ȋ: ["i_", ["bri"]], + ị: ["i", ["db"]], + ḭ: ["i", ["tlb"]], + + + + + + //Ỉ: ["i", ["ha"]], + //Ị: ["i", ["db"]], // o ọ: ["o", ["db"]], @@ -128,4 +162,4 @@ const diaBaseAssociation = { ỹ: ["y", ["tl"]], } as ExtendedTable; -export { diaBaseAssociation } +export { diaBaseAssociation }; diff --git a/src/glyphs/lowercase/index.ts b/src/glyphs/lowercase/index.ts index 075ecc1..92169bb 100644 --- a/src/glyphs/lowercase/index.ts +++ b/src/glyphs/lowercase/index.ts @@ -24,13 +24,18 @@ 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.08])), + tp: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], p[1] - 0.08])), bt: (g: Glyph) => g.map((l: Line) => l.map((p: Vec) => [p[0], p[1] + 0.08])), 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]])), }; +const joinVector = (diaStack: Glyph[], movedDia: Glyph): Glyph => + diaStack.reduce( + (out: Glyph, curr: Glyph) => [...out, ...curr], + [...movedDia], + ); + const mergeDia = (diaKeys: DiaGroup): Glyph => { // check if theres is two diacritics and // both are situated on top of letter @@ -39,58 +44,48 @@ const mergeDia = (diaKeys: DiaGroup): Glyph => { 0, ); if (diaKeys.length > 1 && multipleTopDia > 1) { + // check double grave + if (diaKeys.reduce((ct: number, k: keyof Font)=> ct += k === 'gr' ? 1 : 0, 0) > 1) { + return joinVector( + diaKeys.filter((k) => k != "gr").map((k) => diacritics[k]), + [...moveDia.lf(diacritics['gr']), ...moveDia.rg(diacritics['gr'])] + ) + } // move macron down if (diaKeys.includes("mc")) { - return diaKeys - .filter((k: keyof Font) => k !== "mc") - .reduce( - (g: Glyph, k: keyof Font) => [...g, ...diacritics[k]], - [...moveDia.bt(diacritics["mc"])], - ); - } + return joinVector( + diaKeys.filter((k) => k != "mc").map((k) => diacritics[k]), + moveDia.bt(diacritics["mc"]), + ); + } // move acute accent left else if (diaKeys.includes("ct")) { - return diaKeys - .filter((k: keyof Font) => k !== "ct") - .reduce( - (g: Glyph, k: keyof Font) => [ - ...g, - ...(topDia.includes(k) ? moveDia.rg(diacritics[k]) : diacritics[k]), - ], - [...moveDia.lf(diacritics["ct"])], - ); + return joinVector( + diaKeys.filter((k) => k != "ct").map((k) => diacritics[k]), + moveDia.bt(diacritics["ct"]), + ); } // move grave accent right else if (diaKeys.includes("gr")) { - return diaKeys - .filter((k: keyof Font) => k !== "gr") - .reduce( - (g: Glyph, k: keyof Font) => [ - ...g, - ...(topDia.includes(k) ? moveDia.lf(diacritics[k]) : diacritics[k]), - ], - [...moveDia.rg(diacritics["gr"])], - ); + return joinVector( + diaKeys.filter((k) => k != "gr").map((k) => diacritics[k]), + moveDia.bt(diacritics["gr"]), + ); } // move breve bottom else if (diaKeys.includes("br")) { - return diaKeys - .filter((k: keyof Font) => k !== "br") - .reduce( - (g: Glyph, k: keyof Font) => [...g, ...diacritics[k]], - [...moveDia.bt(diacritics["br"])], - ); + return joinVector( + diaKeys.filter((k) => k != "br").map((k) => diacritics[k]), + moveDia.bt(diacritics["br"]), + ); } // move tild up else if (diaKeys.includes("tl")) { - return diaKeys - .filter((k: keyof Font) => k !== "tl") - .reduce( - (g: Glyph, k: keyof Font) => [...g, ...diacritics[k]], - [...moveDia.tp(diacritics["tl"])], - ); - } - else { + return joinVector( + diaKeys.filter((k) => k != "tl").map((k) => diacritics[k]), + moveDia.bt(diacritics["tl"]), + ); + } else { return diaKeys.reduce( (acc: Glyph, k: keyof Font) => [...acc, ...diacritics[k]], [] as Glyph, diff --git a/src/glyphs/uppercase.ts b/src/glyphs/uppercase.ts index 5e88c0d..54c26a2 100644 --- a/src/glyphs/uppercase.ts +++ b/src/glyphs/uppercase.ts @@ -178,7 +178,7 @@ const uppercase = { ], [ [0.6, 0.6], - [0.85, 0.75], + [0.95, 0.75], ], ], R: [