Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed May 21, 2024
2 parents 7376ad6 + 4e04bf3 commit a0c0eb5
Show file tree
Hide file tree
Showing 12 changed files with 1,349 additions and 2,562 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish on NPM
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20"
cache: "yarn"
- run: yarn install --immutable
- run: yarn build
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
36 changes: 3 additions & 33 deletions demo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,17 @@
import { font, getGlyphPath } from "../../src/index.ts";
import { Glyph, Line, Vec } from "../../src/type";
import letters from "./letters";

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

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["ɜ"] = 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]}`, `${fontFamily} font-size: 3em`);
break;
} else {
console.log(`%c ✅${letters[l]}`, `${fontFamily} font-size: 2.5em`);
}
}

const app = document.getElementById("app"),
form = document.createElement("form"),
namespace = "http://www.w3.org/2000/svg",
svg = document.createElementNS(namespace, "svg"),
input = document.createElement("textarea"),
inputSize = document.createElement("input"),
textAtLaunch = "Type text",
glyphKeys = Array.from(Object.keys(font)).join(""),
fontKey = Array.from(Object.keys(font)),
glyphKeys = letters.filter((l) => fontKey.includes(l)).join(""),
group = document.createElementNS(namespace, "g");

const update = () => {
Expand Down Expand Up @@ -96,7 +66,7 @@ const update = () => {
group.appendChild(rect);
}
}
group.setAttribute("stroke-width", `${fontScale * 30}`);
group.setAttribute("stroke-width", `${fontScale * 40}`);

svg.setAttribute("width", `${width}`);
svg.setAttribute("height", `${height + 40}`);
Expand Down
6 changes: 6 additions & 0 deletions demo/src/letters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ export default [
..."XẌẊ",
..."YÝỲŶŸỸẎȲỶỴɎƳỾ",
..."ȜZŹẐŽŻẒẔƵȤⱿƷǮƸÞǷƧƼƄɁ",
// Number
..."1234567890",
// Punctuation
...'"⁄_-–—,;;:!¡?¿.…··\'‘’‚‹›"“”„«»()[]{}§¶@*/\\&#%†•′″"',
// Currency
..."₠₡₢₣₤₥₦₧₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿₨$£¤¥",
];
Loading

0 comments on commit a0c0eb5

Please sign in to comment.