Skip to content

Commit

Permalink
punctuation diacritics placement rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed May 7, 2024
1 parent 6e4dcf4 commit 7ebd3b7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion demo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const init = () => {
inputSize.min = "0.05";
inputSize.max = "0.2";
inputSize.step = "0.01";
inputSize.value = "0.07";
inputSize.value = "0.1";

inputSize.addEventListener("change", update);

Expand Down
52 changes: 22 additions & 30 deletions src/glyphs/lowercase/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1342,19 +1342,11 @@ const base = {
],
ɷ: [
[
[0.5, 0.7],
[0.8, 0.7],
[0.9, 0.5],

[0.75, 0.35],
[0.66, 0.3],
[0.5, 0.25],
[0.33, 0.3],
[0.25, 0.35],

[0.1, 0.5],
[0.2, 0.7],
[0.5, 0.7],
[0.15, 0.7],
[0.15, 0.3],
[0.85, 0.3],
[0.85, 0.7],
[0.15, 0.7],
],
[
[0.5, 0.7],
Expand All @@ -1378,6 +1370,23 @@ const base = {
[0.85, 0.1],
],
],
œ: [
[
[0.5, 0.3],
[0.85, 0.3],
[0.85, 0.5],
[0.5, 0.5],
[0.5, 0.3],
[0.15, 0.3],
[0.15, 0.7],
[0.5, 0.7],
[0.5, 0.5],
],
[
[0.5, 0.7],
[0.85, 0.7],
],
],

p: [
[
Expand Down Expand Up @@ -1673,23 +1682,6 @@ const base = {
[0.85, 0.7],
],
],
œ: [
[
[0.5, 0.3],
[0.85, 0.3],
[0.85, 0.5],
[0.5, 0.5],
[0.5, 0.3],
[0.15, 0.3],
[0.15, 0.7],
[0.5, 0.7],
[0.5, 0.5],
],
[
[0.5, 0.7],
[0.85, 0.7],
],
],
} as Font;

export { base };
32 changes: 20 additions & 12 deletions src/glyphs/lowercase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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.2])),
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]])),
Expand All @@ -45,22 +45,37 @@ const mergeDia = (diaKeys: DiaGroup): Glyph => {
);
if (diaKeys.length > 1 && multipleTopDia > 1) {
// check double grave
if (diaKeys.reduce((ct: number, k: keyof Font)=> ct += k === 'gr' ? 1 : 0, 0) > 1) {
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'])]
)
}
// check double acute
if (diaKeys.reduce((ct: number, k: keyof Font)=> ct += k === 'ct' ? 1 : 0, 0) > 1) {
if (
diaKeys.reduce((ct: number, k: keyof Font)=> ct += k === 'ct' ? 1 : 0, 0) > 1) {
return joinVector(
diaKeys.filter((k) => k != "ct").map((k) => diacritics[k]),
[...moveDia.lf(diacritics['ct']), ...moveDia.rg(diacritics['ct'])]
)
}

// move tild down
if (diaKeys.includes("tl")) {
return joinVector(
diaKeys.filter((k) => k != "tl").map((k) => diacritics[k]),
moveDia.bt(diacritics["tl"]),
);
}
// move tild down
else if (diaKeys.includes("hc")) {
return joinVector(
diaKeys.filter((k) => k != "hc").map((k) => diacritics[k]),
moveDia.bt(diacritics["hc"]),
);
}  
// move macron down
if (diaKeys.includes("mc")) {
else if (diaKeys.includes("mc")) {
return joinVector(
diaKeys.filter((k) => k != "mc").map((k) => diacritics[k]),
moveDia.bt(diacritics["mc"]),
Expand All @@ -86,13 +101,6 @@ const mergeDia = (diaKeys: DiaGroup): Glyph => {
diaKeys.filter((k) => k != "br").map((k) => diacritics[k]),
moveDia.bt(diacritics["br"]),
);
}
// move tild up
else if (diaKeys.includes("tl")) {
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]],
Expand Down
26 changes: 13 additions & 13 deletions src/glyphs/poncuation.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const ponctuation = {
".": [
[
[0.5, 0.65],
[0.5, 0.675],
[0.5, 0.7],
],
],
",": [
[
[0.5, 0.65],
[0.5, 0.675],
[0.49, 0.69],
[0.45, 0.7],
],
],
Expand All @@ -29,7 +29,7 @@ const ponctuation = {
[0.5, 0.525],
],
[
[0.5, 0.65],
[0.5, 0.675],
[0.5, 0.7],
],
],
Expand All @@ -39,14 +39,14 @@ const ponctuation = {
[0.5, 0.525],
],
[
[0.5, 0.65],
[0.5, 0.675],
[0.5, 0.7],
],
],
"¡": [
[
[0.5, 0.2],
[0.5, 0.25],
[0.5, 0.225],
],
[
[0.5, 0.375],
Expand All @@ -63,7 +63,7 @@ const ponctuation = {
[0.5, 0.6],
],
[
[0.5, 0.65],
[0.5, 0.675],
[0.5, 0.7],
],
],
Expand All @@ -77,7 +77,7 @@ const ponctuation = {
[0.5, 0.3],
],
[
[0.5, 0.25],
[0.5, 0.225],
[0.5, 0.2],
],
],
Expand Down Expand Up @@ -140,11 +140,11 @@ const ponctuation = {
],
[
[0.25, 0.2],
[0.25, 0.25],
[0.25, 0.225],
],
[
[0.75, 0.7],
[0.75, 0.65],
[0.75, 0.675],
],
],
"|": [
Expand Down Expand Up @@ -195,12 +195,12 @@ const ponctuation = {
],
"×": [
[
[0.3, 0.35],
[0.6, 0.65]
[0.325, 0.305],
[0.675, 0.655]
],
[
[0.6, 0.35],
[0.3, 0.65]
[0.675, 0.305],
[0.325, 0.655]
]
],
_: [
Expand Down

0 comments on commit 7ebd3b7

Please sign in to comment.