Skip to content

Commit

Permalink
clipboard comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed May 20, 2024
1 parent 357f6be commit 9f3be98
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { type Vec, Line, Glyph, Font } from "./type";
import lowercase from "./lowercase/index";
import uppercase from "./uppercase/index";
import ponctuation from "./punctuation";
import punctuation from "./punctuation";
import number from "./number";
import currency from "./currency";

/*
* Destructure every glyphs groups and assign glyph key to theirs paths
* font.a = [[[x1, y1], [x2, y2]...]]
* Destructure every glyphs groups to compose the font
* To go deeper on the font sructure please refer to type.d.ts
*/
const font = {
...lowercase,
...uppercase,
...number,
...ponctuation,
...punctuation,
...currency,
} as Font;

Expand Down Expand Up @@ -60,7 +60,7 @@ const getGlyphPath = (key: string, size: Vec, pos: Vec): string[] => {
);
} else {
console.warn(
`Missing glyph ${key}, You can create it (and add it to this repository by making a pull request) or open an issue.`,
`Missing glyph "${key}" You can create it (and add it to this repository by making a pull request) or open an issue.`,
);
return [];
}
Expand Down
105 changes: 95 additions & 10 deletions src/punctuation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Font } from "./type";
import { type Font } from "./type";

export default {
".": [
Expand Down Expand Up @@ -182,11 +182,52 @@ export default {
],
[
[0.25, 0.2],
[0.25, 0.225],
[0.35, 0.2],
[0.35, 0.3],
[0.25, 0.3],
[0.25, 0.2],
],
[
[0.65, 0.6],
[0.75, 0.6],
[0.75, 0.7],
[0.75, 0.675],
[0.65, 0.7],
[0.65, 0.6],
],
],
"†": [
[
[0.5, 0.2],
[0.5, 0.7],
],
[
[0.3, 0.35],
[0.7, 0.35],
],
],
"•": [
[
[0.4, 0.35],
[0.6, 0.35],
[0.6, 0.55],
[0.4, 0.55],
[0.4, 0.35],
],
],
"′": [
[
[0.6, 0.2],
[0.4, 0.35],
],
],
"″": [
[
[0.5, 0.2],
[0.3, 0.35],
],
[
[0.7, 0.2],
[0.5, 0.35],
],
],
"|": [
Expand Down Expand Up @@ -282,15 +323,15 @@ export default {
],
"&": [
[
[0.75, 0.75],
[0.75, 0.4],
[0.25, 0.4],
[0.25, 0.7],
[0.8, 0.7],
[0.8, 0.75],
[0.8, 0.4],
[0.15, 0.4],
[0.15, 0.7],
[0.85, 0.7],
],
[
[0.35, 0.4],
[0.35, 0.2],
[0.3, 0.4],
[0.3, 0.2],
[0.75, 0.2],
[0.75, 0.4],
],
Expand Down Expand Up @@ -500,6 +541,20 @@ export default {
[0.45, 0.771],
],
],
"‹": [
[
[0.55, 0.35],
[0.4, 0.45],
[0.55, 0.55],
],
],
"›": [
[
[0.4, 0.35],
[0.55, 0.45],
[0.4, 0.55],
],
],
"«": [
[
[0.5, 0.3],
Expand All @@ -524,6 +579,36 @@ export default {
[0.5, 0.6],
],
],
"“": [
[
[0.44, 0.2],
[0.38, 0.3],
],
[
[0.64, 0.2],
[0.58, 0.3],
],
],
"”": [
[
[0.38, 0.2],
[0.44, 0.3],
],
[
[0.58, 0.2],
[0.64, 0.3],
],
],
"„": [
[
[0.44, 0.7],
[0.38, 0.8],
],
[
[0.64, 0.7],
[0.58, 0.3],
],
],
º: [
[
[0.4125, 0.235],
Expand Down
12 changes: 6 additions & 6 deletions src/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// A simple 2D vector type
export interface Vec extends Array<number> {}

// Another for line (array of Vec)
// A line (array of Vec)
export interface Line extends Array<Vec> {}

// Another for letter (array of Line)
// A glyph/letter (array of Line)
export interface Glyph extends Array<Line> {}

// An array of diacritics key (two or three letters)
export interface DiaGroup extends Array<keyof Font> {}

// Table to dupplicate existing glyph with diacriticals marks
// The key is used to defined a diacriticized letter (à,ê,ï),
// the first item of the array define the base letter w/out diacritics (a, e, i),
// the last item is an array of diacricts name (described in diacritics/glyph.ts)
export interface ExtendedTable {
[key: string]: [string, string[]];
}

// And finally a type for the whole font
// where each glyph is defined in an object
// with the char as a key
// with the char as a key { a: [], b: []... }
export interface Font {
[key: string]: Glyph;
}

0 comments on commit 9f3be98

Please sign in to comment.