Skip to content

Commit

Permalink
fix some grapheme
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed May 7, 2024
1 parent 7ebd3b7 commit 5362d44
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 44 deletions.
16 changes: 10 additions & 6 deletions demo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down
9 changes: 9 additions & 0 deletions demo/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 17 additions & 7 deletions src/glyphs/diacritics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -183,6 +183,7 @@ const diacritics = {
[
[0.85, 0.7],
[0.85, 0.85],
[0.83, 0.88],
[0.75, 0.9]
]
],
Expand All @@ -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 /)
Expand All @@ -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;

Expand Down
42 changes: 32 additions & 10 deletions src/glyphs/lowercase/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
],
Expand All @@ -327,6 +327,7 @@ const base = {
ƌ: [
[
[0.15, 0.15],
[0.85, 0.15],
[0.85, 0.725],
],
[
Expand Down Expand Up @@ -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],
],
],
ʄ: [
Expand All @@ -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],
],
],

Expand Down Expand Up @@ -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],
],
],

Expand All @@ -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],
Expand Down
22 changes: 12 additions & 10 deletions src/glyphs/lowercase/diaBaseAssociation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const diaBaseAssociation = {
: ["d", ["db"]],
: ["d", ["crb"]],
: ["d", ["lb"]],
ɖ: ["d", ["crs"]],
ɖ: ["d", ["gnk"]],
// e
é: ["e", ["ct"]],
è: ["e", ["gr"]],
Expand All @@ -69,7 +69,7 @@ const diaBaseAssociation = {
ě: ["e", ["hc"]],
ë: ["e", ["dr"]],
: ["e", ["tl"]],
ė: ["e", ["gs"]],
ė: ["e", ["da"]],
ȩ: ["e", ["cd"]],
: ["e", ["br", "cd"]],
ę: ["e", ["gnk"]],
Expand All @@ -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"]],
Expand All @@ -117,7 +117,7 @@ const diaBaseAssociation = {
ï: ["ı", ["dr"]],
: ["ı", ["ct", "dr"]],
ĩ: ["ı", ["tl"]],
į: ["i", ["gnk"]],
į: ["i", ["gnkc"]],
ī: ["ı", ["mc"]],
: ["ı", ["ha"]],
ȉ: ["ı", ["gr", "gr"]],
Expand All @@ -134,7 +134,7 @@ const diaBaseAssociation = {
// k
: ["k", ["ct"]],
ǩ: ["k", ["hc"]],
ķ: ["k", ["cdr"]],
ķ: ["k", ["cm"]],
: ["k", ["db"]],
: ["k", ["lb"]],

Expand All @@ -159,7 +159,7 @@ const diaBaseAssociation = {
ň: ["n", ["hc"]],
ñ: ["n", ["tl"]],
: ["n", ["da"]],
ņ: ["n", ["cd"]],
ņ: ["n", ["cm"]],
: ["n", ["db"]],
: ["n", ["crb"]],
: ["n", ["lb"]],
Expand Down Expand Up @@ -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"]],
Expand All @@ -231,7 +231,9 @@ const diaBaseAssociation = {
ş: ["s", ["cd"]],
: ["s", ["db"]],
: ["s", ["da", "db"]],

ș: ["s", ["cm"]],
: ["ſ", ["da"]],
ʂ: ["s", ["gnk"]],
// u
: ["u", ["db"]],
: ["u", ["ha"]],
Expand Down
17 changes: 6 additions & 11 deletions src/glyphs/lowercase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const topDia = [
"gs",
"da",
"ha",
"hc"
] as Array<keyof Font>;

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]])),
};
Expand Down Expand Up @@ -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]),
Expand All @@ -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,
Expand Down

0 comments on commit 5362d44

Please sign in to comment.