Skip to content

Commit

Permalink
refactoring lowercase (the merge of diacritics and base letters)
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed May 2, 2024
1 parent b3de439 commit f76bab3
Show file tree
Hide file tree
Showing 10 changed files with 939 additions and 437 deletions.
27 changes: 26 additions & 1 deletion demo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
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","ź","ẑ","ž","ż","ẓ","ẕ","ƍ","ƶ","ȥ","ʐ","ʑ","ɀ","ʒ","ǯ","ƹ","ƺ","ʓ","þ","ƿ","ƨ","ƽ","ƅ","ɂ","ʕ","ʡ","ʢ","ʖ","ʗ","ʘ","ʬ","ʭ"]
/*
console.log(
JSON.stringify(
font["3"].map(
(l: Line) => l.map((v: Vec) => [0.166 + v[0] * 0.33, 0.166 + v[1] * 0.33] as Vec) as Line,
) as Glyph,
),
);
*/


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]))

// font["ʙ"] = scaleGlyph(font["B"])
console.log(JSON.stringify(scaleGlyph(font['6'])))

for (let l = 0; l < lowercase.length; l++) {
if (font[lowercase[l]] === undefined) {
console.log(`%c ${lowercase[l]}`, "font-size: 3em" )
break;
} else {
console.log(`✅${lowercase[l]}`)
}
}


const app = document.getElementById("app"),
form = document.createElement("form"),
Expand Down Expand Up @@ -50,13 +71,17 @@ const update = () => {
rect.setAttribute("y", `${margin[1] + y * textSize[1]}`);
rect.setAttribute("width", `${textSize[0]}`);
rect.setAttribute("height", `${textSize[1]}`);
group.appendChild(rect);
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");
path.setAttribute("d", d);
group.appendChild(path);
});
group.appendChild(rect);
}
}
group.setAttribute("stroke-width", `${fontScale * 40}`);
Expand Down
1 change: 0 additions & 1 deletion demo/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ footer p {
#app svg g rect {
stroke: #ccc;
stroke-width: 0.5px;
fill: #fefefe66;
}

@media screen and (min-width: 900px) {
Expand Down
80 changes: 65 additions & 15 deletions src/glyphs/diacritics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const diacritics = {
[
[0.4, 0.85],
[0.5, 0.8],
[0.6, 0.85]
]
[0.6, 0.85],
],
],
// diaeresis
dr: [
Expand Down Expand Up @@ -72,6 +72,24 @@ const diacritics = {
[0.6, 0.1],
],
],
// inverse breve
bri: [
[
[0.4, 0.15],
[0.4, 0.1],
[0.6, 0.1],
[0.6, 0.15],
],
],
// half circle right
hcr: [
[
[0.6, 0.1],
[0.7, 0.1],
[0.7, 0.2],
[0.6, 0.2],
],
],
// haček or caron
hc: [
[
Expand All @@ -87,13 +105,13 @@ const diacritics = {
[0.7, 0.1],
],
],
// angstorm or circle or ring
// angstorm or circle or ring (top)
gs: [
[
[0.45, 0.2],
[0.45, 0.15],
[0.55, 0.15],
[0.55, 0.25],
[0.55, 0.2],
[0.45, 0.2],
],
],
Expand All @@ -108,7 +126,7 @@ const diacritics = {
],
],
// cedilla left
cdl: [
cdl: [
[
[0.25, 0.7],
[0.25, 0.75],
Expand All @@ -117,6 +135,16 @@ const diacritics = {
[0.2, 0.8],
],
],
// cedilla right
cdr: [
[
[0.75, 0.7],
[0.75, 0.75],
[0.8, 0.75],
[0.8, 0.8],
[0.7, 0.8],
],
],
// ring/dot below
db: [
[
Expand Down Expand Up @@ -144,24 +172,46 @@ const diacritics = {
[0.55, 0.2],
[0.55, 0.25],
[0.5, 0.25],
[0.5, 0.3]
[0.5, 0.3],
],
],
// hook bottom right
hbr: [
[
[0.75, 0.725],
[0.75, 0.85],
[0.85, 0.9]
]
],
// line below
// line below
lb: [
[
[0.3, 0.8],
[0.7, 0.8]
]
[0.7, 0.8],
],
],
// horn
hr: [
[
[0.75, 0.35],
[0.8, 0.25]
]
]

[0.8, 0.3],
[0.85, 0.25],
[0.85, 0.2],
],
],
crs: [
[
[0.8, 0.3],
[0.8, 0.25],
[0.85, 0.2],
],
],
// barred (kind of /)
brd: [
[
[0.55, 0.2],
[0.35, 0.8],
],
],
} as Font;

export default diacritics
export default diacritics;
Loading

0 comments on commit f76bab3

Please sign in to comment.