Skip to content

Commit

Permalink
rework t (lowercase) & enhance demo (debug view)
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed May 17, 2024
1 parent b04990c commit a32b860
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
26 changes: 15 additions & 11 deletions demo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { font, getGlyphPath } from "../../src/index.ts";
import { Glyph, Line, Vec } from "../../src/type";
import letters from "./letters"
import letters from "./letters";

const DEBUG = false;
const DEBUG = true;

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.33 - 0.166, p[1] * 1.33 - 0.33]));
g.map((l: Line) =>
l.map((p: Vec) => [p[0] * 1.33 - 0.166, p[1] * 1.33 - 0.33]),
);

const scaleGlyph = (g: Glyph) =>
g.map((l: Line) =>
Expand All @@ -21,12 +23,14 @@ const mirrorYGlyph = (g: Glyph) =>
// font["ɜ"] = mirrorYGlyph(font["ɛ"])
// alert(`Ɣ: ${JSON.stringify(upscaleGlyph(font["ɣ"]))},`);

const fontFamily =
'ui-monospace, Menlo, Monaco,"Cascadia Mono", "Segoe UI Mono", "Roboto Mono","Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;';
for (let l = 0; l < letters.length; l++) {
if (font[letters[l]] === undefined) {
console.log(`%c ${letters[l]}`, "font-size: 3em");
console.log(`%c ${letters[l]}`, `${fontFamily} font-size: 3em`);
break;
} else {
console.log(`%c ✅${letters[l]}`, "font-size: 2.5em");
console.log(`%c ✅${letters[l]}`, `${fontFamily} font-size: 2.5em`);
}
}

Expand All @@ -50,7 +54,7 @@ const update = () => {
16,
Math.min(Math.floor(Math.hypot(width, height) * fontScale), 264),
),
textSize = [baseSize, baseSize],
textSize = [baseSize, baseSize * 1.6],
charPerLine = Math.floor(width / textSize[0]),
nbLines = Math.ceil(text.length / charPerLine),
margin = [(width - charPerLine * textSize[0]) / 2, 40];
Expand All @@ -74,16 +78,16 @@ const update = () => {
rect.setAttribute("width", `${textSize[0]}`);
rect.setAttribute("height", `${textSize[1]}`);
rect.setAttribute("title", char);

if (DEBUG) {
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*15}em`)
label.setAttribute("font-size", `${fontScale * 15}em`);
label.textContent = char;
group.appendChild(label);
}

lines.map((d: string) => {
const path = document.createElementNS(namespace, "path");
path.setAttribute("d", d);
Expand All @@ -92,7 +96,7 @@ const update = () => {
group.appendChild(rect);
}
}
group.setAttribute("stroke-width", `${fontScale * 40}`);
group.setAttribute("stroke-width", `${fontScale * 30}`);

svg.setAttribute("width", `${width}`);
svg.setAttribute("height", `${height + 40}`);
Expand All @@ -115,7 +119,7 @@ const init = () => {
input.addEventListener("change", update);

inputSize.type = "range";
inputSize.min = "0.05";
inputSize.min = "0.01";
inputSize.max = "0.2";
inputSize.step = "0.01";
inputSize.value = "0.1";
Expand Down
20 changes: 10 additions & 10 deletions src/lowercase/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ const base = {
[0.85, 0.414],
],
[
[0.35, 0.343],
[0.35, 0.271],
[0.35, 0.7],
[0.85, 0.7],
],
Expand All @@ -1706,7 +1706,7 @@ const base = {
[0.5, 0.414],
],
[
[0.25, 0.343],
[0.25, 0.271],
[0.25, 0.7],
[0.85, 0.629],
[0.85, 0.7],
Expand All @@ -1721,7 +1721,7 @@ const base = {
[0.85, 0.414],
],
[
[0.35, 0.343],
[0.35, 0.271],
[0.35, 0.557],
[0.65, 0.557],
[0.65, 0.7],
Expand All @@ -1734,7 +1734,7 @@ const base = {
[0.5, 0.414],
],
[
[0.25, 0.343],
[0.25, 0.271],
[0.25, 0.7],
[0.85, 0.7],
[0.85, 0.557],
Expand All @@ -1749,7 +1749,7 @@ const base = {
[0.5, 0.414],
],
[
[0.25, 0.343],
[0.25, 0.271],
[0.25, 0.7],
[0.5, 0.7],
],
Expand All @@ -1770,7 +1770,7 @@ const base = {
[0.85, 0.557],
],
[
[0.35, 0.343],
[0.35, 0.271],
[0.35, 0.7],
[0.85, 0.7],
],
Expand All @@ -1781,7 +1781,7 @@ const base = {
[0.85, 0.414],
],
[
[0.5, 0.343],
[0.5, 0.271],
[0.35, 0.343],
[0.35, 0.7],
[0.85, 0.7],
Expand All @@ -1793,7 +1793,7 @@ const base = {
[0.85, 0.414],
],
[
[0.35, 0.343],
[0.35, 0.271],
[0.35, 0.843],
[0.65, 0.843],
],
Expand All @@ -1804,7 +1804,7 @@ const base = {
[0.85, 0.414],
],
[
[0.5, 0.343],
[0.5, 0.271],
[0.5, 0.7],
[0.85, 0.7],
[0.85, 0.557],
Expand All @@ -1817,7 +1817,7 @@ const base = {
[0.15, 0.7],
],
[
[0.65, 0.771],
[0.65, 0.7],
[0.65, 0.414],
[0.15, 0.414],
],
Expand Down

0 comments on commit a32b860

Please sign in to comment.