@333eco/brand 1.12.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +53 -0
- package/README.md +3 -0
- package/brand.lock +3 -2
- package/data/brand.json +1 -1
- package/dist/Brand.kt +1 -1
- package/dist/Brand.swift +1 -1
- package/dist/tokens.json +1 -1
- package/package.json +3 -2
- package/qr/looks.ts +18 -7
- package/qr/script.ts +45 -0
package/NOTICE
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
brand.333.eco — the canonical brand layer for the institution
|
|
2
|
+
Copyright 2026 Thon Ly
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
|
5
|
+
|
|
6
|
+
--------------------------------------------------------------------------
|
|
7
|
+
TRADEMARKS — NOT LICENSED BY THE LICENSE ABOVE
|
|
8
|
+
--------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
Apache-2.0 section 6 grants no trademark rights, and none are granted here.
|
|
11
|
+
That is why this licence was chosen rather than a more permissive one: this
|
|
12
|
+
repository ships an actual mark, not only the code that renders it.
|
|
13
|
+
|
|
14
|
+
The following are trademarks or service marks of the institution and are
|
|
15
|
+
NOT licensed by the Apache Licence:
|
|
16
|
+
|
|
17
|
+
HeartBank(R) B-Emblem(TM)
|
|
18
|
+
B-Registry(SM) Thank with HeartBank(R)
|
|
19
|
+
Proof of Coordinate(SM) Proof of Humanity(SM)
|
|
20
|
+
Thank Your Future Kindness(SM)
|
|
21
|
+
|
|
22
|
+
This includes the B-Emblem design itself — the heart rotated 45 degrees
|
|
23
|
+
clockwise that reads bistably as both a heart and a capital B — wherever it
|
|
24
|
+
appears in this repository, notably `emblem/emblem.svg`, `emblem/emblem.ts`
|
|
25
|
+
and `emblem/emblem.path.txt`. The path data is source code and is licensed;
|
|
26
|
+
the MARK it draws is not. Copying the file does not convey the right to use
|
|
27
|
+
the mark as a mark.
|
|
28
|
+
|
|
29
|
+
WHAT YOU MAY DO under the Apache Licence, and what this repository is
|
|
30
|
+
published for: take the token architecture, the derivation machinery, the
|
|
31
|
+
generator, the drift guard, the concatenation model and the reasoning
|
|
32
|
+
recorded in the comments, and build your own identity on them. The design
|
|
33
|
+
patterns are described as commons in `Brand Identity as Architecture`
|
|
34
|
+
(CC0 1.0, DOI 10.5281/zenodo.21947287) and are meant to be portable.
|
|
35
|
+
|
|
36
|
+
WHAT YOU MAY NOT DO: use these marks to identify your goods or services, or
|
|
37
|
+
adopt a mark confusingly similar to them, or suggest that the institution
|
|
38
|
+
endorses your work. Fair, descriptive reference to the institution — saying
|
|
39
|
+
what this software is, where it came from, or that your work is derived from
|
|
40
|
+
it — is expressly fine and is what Apache-2.0 section 6 preserves.
|
|
41
|
+
|
|
42
|
+
If you want to render the B-Emblem as the institution's mark — a partner
|
|
43
|
+
integration, a vendor tag, a co-branded surface — that is a separate
|
|
44
|
+
permission and a separate conversation, not something a licence file can
|
|
45
|
+
grant you.
|
|
46
|
+
|
|
47
|
+
qr/script.ts carries font data from the Hershey Script 1-stroke face, as distributed in the npm package
|
|
48
|
+
`hersheytext` 2.0.0 (MIT License, Copyright (c) 2014 James T), from the EMSL Hershey Text SVG fonts. Its
|
|
49
|
+
distribution terms require these acknowledgements:
|
|
50
|
+
- The Hershey Fonts were originally created by Dr. A. V. Hershey while working at the U. S. National
|
|
51
|
+
Bureau of Standards.
|
|
52
|
+
- The format of the Font data in this distribution was originally created by James Hurt, Cognition, Inc.,
|
|
53
|
+
900 Technology Park Drive, Billerica, MA 01821.
|
package/README.md
CHANGED
|
@@ -156,6 +156,9 @@ an H3QR names whom you thank, and a B-QR is how that code is drawn.
|
|
|
156
156
|
B-Emblem faint, 0.4 white, a person's autograph on it) and the B-SYMBOL℠ (a tiny emblem beside a person's B-Autograph℠, as a ™). ⛔ Never without
|
|
157
157
|
the invisible mark in the same file (the caller forces it on and reads it back) · ⛔ no B-Autograph on a picture declared AI-made, so no B-Symbol
|
|
158
158
|
on one · `paintAutograph` is the lobe's own drawing, moved so both can use it (§looks LK1–LK4).
|
|
159
|
+
- **v1.13.0 (founder 2026-11-25):** the hand CENTERED in the B-Emblem on the silhouette (`SILHOUETTE_CENTER`, solved from the silhouette as the
|
|
160
|
+
lobe's was) · the B-Symbol℠ raised or lowered (`position: "super" | "sub"`) · the hand in any ink a person picks · ⭐ `qr/script.ts`: a
|
|
161
|
+
B-Autograph℠ TYPED in a one-stroke script (Hershey Script, acknowledged in NOTICE; Latin only, so a Khmer name is drawn) (§looks2 LK5–LK9).
|
|
159
162
|
- **The card's words are PLACED, never aligned (v1.6.1).** `paintQrCard` measures each line, shrinks its size until it fits,
|
|
160
163
|
and draws it from the left at the center minus half its width. Safari on iOS 26 ignores `textAlign = "center"` and the
|
|
161
164
|
`maxWidth` argument for a complex script: a Khmer caption printed starting at the center line. Measured on the Simulator
|
package/brand.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.13.0",
|
|
3
3
|
"files": {
|
|
4
4
|
"css/metta.css": "9bfe986c46c303bf9a48be85322d68e3d626571a424ef3a8aa81faaf5c866692",
|
|
5
5
|
"css/motion.css": "9bfbe39c0de6a9dfaf9fdc2c61e327b3c8e70221c34dff9befd85da448b9e0c2",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"qr/bqr-card.ts": "55b4cf3d742bb758f789fd18f91737e8da1169610b6b953ad71e95d8bb713168",
|
|
14
14
|
"qr/bqr.ts": "a5561877ddebefa170d7962b37485ac5b822c1c7454e153e11526fa199f0a99d",
|
|
15
15
|
"qr/fingerprint.ts": "4a587cdb3b5ff6026262f995889c329466a2513044a68c0b5d2fa31c2bdd45a3",
|
|
16
|
-
"qr/looks.ts": "
|
|
16
|
+
"qr/looks.ts": "3ae7615f27094df59aa873cf24f6cb83fd21449473db5dca4fd9df952d49aebb",
|
|
17
|
+
"qr/script.ts": "3e414d0d1668d114bd6e5706f33ba8b6f24e84c67d05a17c8e70f047a9d461b0"
|
|
17
18
|
}
|
|
18
19
|
}
|
package/data/brand.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"into brand.lock, which is vendored byte-identical into every consumer,",
|
|
9
9
|
"so 'which sites are on which brand version' is answerable by grep."
|
|
10
10
|
],
|
|
11
|
-
"version": "1.
|
|
11
|
+
"version": "1.13.0",
|
|
12
12
|
"wordmark": {
|
|
13
13
|
"$comment": [
|
|
14
14
|
"The composition has an internal short-name as of 2026-09-20: B-Wordmark",
|
package/dist/Brand.kt
CHANGED
|
@@ -18,7 +18,7 @@ import androidx.compose.ui.graphics.lerp
|
|
|
18
18
|
import androidx.compose.ui.unit.dp
|
|
19
19
|
|
|
20
20
|
object Brand {
|
|
21
|
-
const val VERSION = "1.
|
|
21
|
+
const val VERSION = "1.13.0"
|
|
22
22
|
|
|
23
23
|
/** The B-Gem media-type palette. A colour here MEANS a medium.
|
|
24
24
|
* Not a site palette, and not the six-TLD rainbow. */
|
package/dist/Brand.swift
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import SwiftUI
|
|
15
15
|
|
|
16
16
|
public enum Brand {
|
|
17
|
-
public static let version = "1.
|
|
17
|
+
public static let version = "1.13.0"
|
|
18
18
|
|
|
19
19
|
/// The B-Gem media-type palette. A colour here MEANS a medium.
|
|
20
20
|
/// ⚠️ Not a site palette, and not the six-TLD rainbow. Using a gem as an
|
package/dist/tokens.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "GENERATED by scripts/generate.mjs. Do not edit. Values are parsed from css/tokens.css, which is canonical; semantics come from data/. Run `node scripts/generate.mjs --check` to prove this file is current.",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"gems": [
|
|
5
5
|
{
|
|
6
6
|
"name": "ruby",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@333eco/brand",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "The canonical brand layer for the institution — design tokens, themes, motion, and the B-Emblem. A READ-ONLY MIRROR; institution repos vendor this layer, they do not install it.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Thon Ly",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"qr",
|
|
40
40
|
"data",
|
|
41
41
|
"dist",
|
|
42
|
-
"brand.lock"
|
|
42
|
+
"brand.lock",
|
|
43
|
+
"NOTICE"
|
|
43
44
|
],
|
|
44
45
|
"scripts": {
|
|
45
46
|
"check": "node scripts/check-brand.mjs",
|
package/qr/looks.ts
CHANGED
|
@@ -17,12 +17,23 @@ import { EMBLEM_BOX, EMBLEM_D, BQR_OUTLINE, bqrOwnerInk, isAutograph, paintAutog
|
|
|
17
17
|
/** How faint: the white let through inside the heart, and the edge's ink. ⭐ "yes to faint" (founder 2026-11-25). */
|
|
18
18
|
export const SILHOUETTE = { white: 0.4, edge: 0.35, line: BQR_OUTLINE * 2 } as const;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* ⭐ v1.13.0 (founder 2026-11-25: *"vertically and horizontally center the B-Autograph within the B-Emblem"*) — the emblem's CENTER, solved from
|
|
21
|
+
* the silhouette as the lobe's was (v1.10.0): the point midway between the edges on its own row AND midway between the edges on its own
|
|
22
|
+
* column, found by iterating from the painted box's center (12.72, 11.28) until it stands still: (12.41, 11.59). `scripts/bqr.test.mjs`
|
|
23
|
+
* §looks2 solves it again and holds these.
|
|
22
24
|
*/
|
|
23
|
-
export const
|
|
25
|
+
export const SILHOUETTE_CENTER = { x: 12.41, y: 11.59 } as const;
|
|
26
|
+
/**
|
|
27
|
+
* The autograph's box on the silhouette, 5 : 3, in viewBox units, CENTERED on the emblem (the fitted hand stands at the box's center). The
|
|
28
|
+
* largest 5 : 3 box there at least 0.6 units inside the edge is 8.17 wide; this one is 8. ⚠️ Smaller than v1.12's 12 (which stood low and to
|
|
29
|
+
* the left, where the body is widest): centered is the ruling, and the size is what the center allows.
|
|
30
|
+
*/
|
|
31
|
+
export const SILHOUETTE_AUTOGRAPH = { x: SILHOUETTE_CENTER.x - 4, y: SILHOUETTE_CENTER.y - 2.4, w: 8, h: 4.8 } as const;
|
|
24
32
|
/** The B-Symbol's emblem beside the ink: its height as a part of the ink's height, and the gap before it, as a part of that height. */
|
|
25
33
|
export const SYMBOL = { size: 0.3, gap: 0.2 } as const;
|
|
34
|
+
/** ⭐ v1.13.0 (founder 2026-11-25: *"let the user choose B-Symbol as subscript or superscript?"*): raised, at the ink's top (as a ™), or lowered,
|
|
35
|
+
* at its bottom. Raised is the default. */
|
|
36
|
+
export type SymbolPosition = "super" | "sub";
|
|
26
37
|
/** The ink a person's own hand is drawn in when the caller names none: Space's, as every mark of 333.eco (the body palette, `MA`). */
|
|
27
38
|
export const LOOK_INK = bqrOwnerInk("MA");
|
|
28
39
|
|
|
@@ -49,16 +60,16 @@ export function paintSilhouette(g: CanvasRenderingContext2D, o: { size: number;
|
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
/** Where a B-Symbol lands for an autograph fitted to `box`: the ink, the emblem beside it, and the whole. Pure: nothing is drawn. */
|
|
52
|
-
export function symbolLayout(a: BqrAutograph, box: { x: number; y: number; w: number; h: number }) {
|
|
63
|
+
export function symbolLayout(a: BqrAutograph, box: { x: number; y: number; w: number; h: number }, position: SymbolPosition = "super") {
|
|
53
64
|
if (!isAutograph(a)) throw new Error("B-Symbol: it stands beside a person's own B-Autograph, never alone.");
|
|
54
65
|
const ink = paintAutograph(nullContext(), a, box, "#000");
|
|
55
|
-
const s = ink.h * SYMBOL.size, em = { x: ink.x + ink.w + s * SYMBOL.gap, y: ink.y, w: s, h: s };
|
|
66
|
+
const s = ink.h * SYMBOL.size, em = { x: ink.x + ink.w + s * SYMBOL.gap, y: position === "sub" ? ink.y + ink.h - s : ink.y, w: s, h: s };
|
|
56
67
|
const x1 = Math.max(ink.x + ink.w, em.x + em.w), y1 = Math.max(ink.y + ink.h, em.y + em.h);
|
|
57
68
|
return { ink, emblem: em, all: { x: ink.x, y: ink.y, w: x1 - ink.x, h: y1 - ink.y } };
|
|
58
69
|
}
|
|
59
70
|
/** Paint the B-SYMBOL: the person's autograph fitted to `box`, and the B-Emblem at its upper right, in the same ink, as a ™. */
|
|
60
|
-
export function paintSymbol(g: CanvasRenderingContext2D, o: { autograph: BqrAutograph; box: { x: number; y: number; w: number; h: number }; ink?: string }) {
|
|
61
|
-
const L = symbolLayout(o.autograph, o.box), ink = o.ink ?? LOOK_INK;
|
|
71
|
+
export function paintSymbol(g: CanvasRenderingContext2D, o: { autograph: BqrAutograph; box: { x: number; y: number; w: number; h: number }; ink?: string; position?: SymbolPosition }) {
|
|
72
|
+
const L = symbolLayout(o.autograph, o.box, o.position), ink = o.ink ?? LOOK_INK;
|
|
62
73
|
paintAutograph(g, o.autograph, o.box, ink);
|
|
63
74
|
const k = L.emblem.w / Math.max(EMBLEM_BOX.w, EMBLEM_BOX.h);
|
|
64
75
|
g.save(); g.translate(L.emblem.x - EMBLEM_BOX.x * k, L.emblem.y - EMBLEM_BOX.y * k); g.scale(k, k);
|
package/qr/script.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⭐ v1.13.0 (founder 2026-11-25: *"user can choose @name typed in a script font (fast and easy)"*) — a B-Autograph℠ TYPED: the name set in a
|
|
3
|
+
* one-stroke script, as strokes on the same 100 × 60 pad a finger draws on, so a typed hand goes through exactly the drawn hand's recipe
|
|
4
|
+
* (`paintAutograph`, the lobe, the silhouette, the B-Symbol℠). Latin letters, digits and ASCII marks only (the face has no Khmer): a name in
|
|
5
|
+
* another script is drawn by hand. ⛔ Like a drawn hand, it is never a legal signature and never a claim: anyone can type any name.
|
|
6
|
+
*
|
|
7
|
+
* THE FONT DATA below is the Hershey Script 1-stroke face (glyphs for ASCII 32-126, each `[advance, strokes as x,y,x,y…]` in its own units,
|
|
8
|
+
* y up from the baseline, cubic segments flattened to four points), taken from the EMSL Hershey Text SVG fonts as distributed in the npm
|
|
9
|
+
* package `hersheytext` 2.0.0 (MIT, James T). Its distribution terms require these acknowledgements, which travel with it here and in NOTICE:
|
|
10
|
+
* - The Hershey Fonts were originally created by Dr. A. V. Hershey while working at the U. S. National Bureau of Standards.
|
|
11
|
+
* - The format of the Font data in this distribution was originally created by James Hurt, Cognition, Inc., 900 Technology Park Drive, (pii-ok: a company's address the font's terms require verbatim)
|
|
12
|
+
* Billerica, MA 01821.
|
|
13
|
+
* ⛔ VENDORED, NEVER EDITED IN A CONSUMER: `brand.lock` hashes this file.
|
|
14
|
+
*/
|
|
15
|
+
import { BQR_AUTOGRAPH_POINTS, BQR_PAD_H, BQR_PAD_W, type BqrAutograph } from "./bqr";
|
|
16
|
+
|
|
17
|
+
const FACE: Record<string, [number, number[][]]> = {" ":[378,[]],"!":[346,[[353,662,321,630,258,252],[353,630,258,252],[353,662,384,630,258,252],[195,63,164,32,195,0,227,32,195,63]]],"\"":[567,[[252,662,189,441],[284,662,189,441],[536,662,472,441],[567,662,472,441]]],"#":[662,[[378,788,158,-220],[567,788,346,-220],[158,378,598,378],[126,189,567,189]]],"$":[662,[[410,788,158,-126],[567,788,315,-126],[598,536,567,504,598,472,630,504,630,536,598,598,567,630,472,662,346,662,252,630,189,567,189,504,220,441,252,410,472,284,536,220],[189,504,252,441,472,315,504,284,536,220,536,126,504,63,472,32,378,0,252,0,158,32,126,63,94,126,94,158,126,189,158,158,126,126]]],"%":[756,[[693,662,126,0],[284,662,346,598,346,536,315,472,252,441,189,441,126,504,126,567,158,630,220,662,284,662,346,630,441,598,536,598,630,630,693,662],[567,220,504,189,472,126,472,63,536,0,598,0,662,32,693,94,693,158,630,220,567,220]]],"&":[819,[[756,410,724,378,756,346,788,378,788,410,756,441,724,441,662,410,598,346,441,94,378,32,315,0,220,0,126,32,94,94,94,158,126,220,158,252,220,284,378,346,441,378,504,441,536,504,536,567,504,630,441,662,378,630,346,567,346,472,378,284,410,189,472,94,536,32,598,0,662,0,693,63,693,94],[220,0,158,32,126,94,126,158,158,220,189,252,378,346],[346,472,378,315,410,220,472,126,536,63,598,32,662,32,693,63]]],"'":[346,[[284,598,252,630,284,662,315,630,315,598,284,536,220,472]]],"(":[472,[[504,788,378,693,284,598,220,504,158,378,126,220,126,94,158,-63,189,-158,220,-220],[378,693,284,567,220,441,189,346,158,189,158,32,189,-126,220,-220]]],")":[472,[[315,788,346,724,378,630,410,472,410,346,378,189,315,63,252,-32,158,-126,32,-220],[315,788,346,693,378,536,378,378,346,220,315,126,252,0,158,-126]]],"*":[536,[[346,662,346,284],[189,567,504,378],[504,567,189,378]]],"+":[819,[[441,567,441,0],[158,284,724,284]]],",":[346,[[126,0,94,32,126,63,158,32,158,0,126,-63,63,-126]]],"-":[819,[[158,284,724,284]]],".":[315,[[189,63,158,32,189,0,220,32,189,63]]],"/":[693,[[788,788,-32,-220]]],"0":[662,[[410,662,315,630,252,567,189,472,158,378,126,252,126,158,158,63,189,32,252,0,315,0,410,32,472,94,536,189,567,284,598,410,598,504,567,598,536,630,472,662,410,662],[410,662,346,630,284,567,220,472,189,378,158,252,158,158,189,63,252,0],[315,0,378,32,441,94,504,189,536,284,567,410,567,504,536,598,472,662]]],"1":[662,[[410,536,252,0],[472,662,284,0],[472,662,378,567,284,504,220,472],[441,567,315,504,220,472]]],"2":[662,[[252,536,284,504,252,472,220,504,220,536,252,598,284,630,378,662,472,662,567,630,598,567,598,504,567,441,504,378,410,315,284,252,189,189,126,126,63,0],[472,662,536,630,567,567,567,504,536,441,472,378,284,252],[94,63,126,94,189,94,346,32,441,32,504,63,536,126],[189,94,346,0,441,0,504,32,536,126]]],"3":[662,[[252,536,284,504,252,472,220,504,220,536,252,598,284,630,378,662,472,662,567,630,598,567,598,504,567,441,472,378,378,346],[472,662,536,630,567,567,567,504,536,441,472,378],[315,346,378,346,472,315,504,284,536,220,536,126,504,63,472,32,378,0,252,0,158,32,126,63,94,126,94,158,126,189,158,158,126,126],[378,346,441,315,472,284,504,220,504,126,472,63,441,32,378,0]]],"4":[662,[[536,630,346,0],[567,662,378,0],[567,662,94,189,598,189]]],"5":[662,[[315,662,158,346],[315,662,630,662],[315,630,472,630,630,662],[158,346,189,378,284,410,378,410,472,378,504,346,536,284,536,189,504,94,441,32,346,0,252,0,158,32,126,63,94,126,94,158,126,189,158,158,126,126],[378,410,441,378,472,346,504,284,504,189,472,94,410,32,346,0]]],"6":[662,[[567,567,536,536,567,504,598,536,598,567,567,630,504,662,410,662,315,630,252,567,189,472,158,378,126,252,126,126,158,63,189,32,252,0,346,0,441,32,504,94,536,158,536,252,504,315,472,346,410,378,315,378,252,346,189,284,158,220],[410,662,346,630,284,567,220,472,189,378,158,252,158,94,189,32],[346,0,410,32,472,94,504,158,504,284,472,346]]],"7":[662,[[220,662,158,472],[630,662,598,567,536,472,378,284,315,189,284,126,252,0],[536,472,346,284,284,189,252,126,220,0],[189,567,284,662,346,662,504,567],[220,598,284,630,346,630,504,567,567,567,598,598,630,662]]],"8":[662,[[378,662,284,630,252,598,220,536,220,441,252,378,315,346,410,346,536,378,567,410,598,472,598,567,567,630,472,662,378,662],[378,662,315,630,284,598,252,536,252,441,284,378,315,346],[410,346,504,378,536,410,567,472,567,567,536,630,472,662],[315,346,189,315,126,252,94,189,94,94,126,32,220,0,346,0,472,32,504,63,536,126,536,220,504,284,472,315,410,346],[315,346,220,315,158,252,126,189,126,94,158,32,220,0],[346,0,441,32,472,63,504,126,504,252,472,315]]],"9":[662,[[567,441,536,378,472,315,410,284,315,284,252,315,220,346,189,410,189,504,220,567,284,630,378,662,472,662,536,630,567,598,598,536,598,410,567,284,536,189,472,94,410,32,315,0,220,0,158,32,126,94,126,126,158,158,189,126,158,94],[252,315,220,378,220,504,252,567,315,630,378,662],[536,630,567,567,567,410,536,284,504,189,441,94,378,32,315,0]]],":":[346,[[220,441,189,410,220,378,252,410,220,441],[126,63,94,32,126,0,158,32]]],";":[346,[[220,441,189,410,220,378,252,410,220,441],[126,0,94,32,126,63,158,32,158,0,126,-63,63,-126]]],"<":[756,[[662,567,158,284,662,0]]],"=":[819,[[158,378,724,378],[158,189,724,189]]],">":[756,[[158,567,662,284,158,0]]],"?":[662,[[252,536,284,504,252,472,220,504,220,536,252,598,284,630,378,662,504,662,598,630,630,567,630,504,598,441,567,410,378,346,315,315,315,252,346,220,410,220],[504,662,567,630,598,567,598,504,567,441,536,410,472,378],[284,63,252,32,284,0,315,32,284,63]]],"@":[850,[[598,410,567,472,504,504,410,504,346,472,315,441,284,346,284,252,315,189,378,158,472,158,536,189,567,252],[410,504,346,441,315,346,315,252,346,189,378,158],[598,504,567,252,567,189,630,158,693,158,756,220,788,315,788,378,756,472,724,536,662,598,598,630,504,662,410,662,315,630,252,598,189,536,158,472,126,378,126,284,158,189,189,126,252,63,315,32,410,0,504,0,598,32,662,63,693,94],[630,504,598,252,598,189,630,158]]],"A":[630,[[32,0,94,32,189,126,284,252,410,472,504,662,504,0,472,94,410,189,346,252,252,315,189,315,158,284,158,220,189,158,252,94,346,32,441,0,598,0]]],"B":[724,[[441,598,472,567,472,472,441,346,410,252,378,189,315,94,252,32,189,0,158,0,126,32,126,126,158,284,189,378,220,441,284,536,346,598,410,630,504,662,598,662,662,630,693,567,693,504,662,441,630,410,567,378,472,346],[441,346,472,346,567,315,598,284,630,220,630,126,598,63,567,32,504,0,410,0,346,32,315,94]]],"C":[630,[[410,472,410,441,441,410,504,410,567,441,598,504,598,567,567,630,504,662,410,662,315,630,252,567,189,472,158,410,126,284,126,158,158,63,189,32,252,0,315,0,410,32,472,94,504,158]]],"D":[724,[[441,662,378,630,346,567,315,441,284,252,252,158,220,94,158,32,94,0,32,0,0,32,0,94,32,126,94,126,158,94,220,32,315,0,410,0,504,32,567,94,630,220,662,378,662,504,630,598,598,630,536,662,441,662,378,598,378,536,410,441,472,346,536,284,630,220,693,189]]],"E":[630,[[472,536,472,504,504,472,567,472,598,504,598,567,567,630,472,662,346,662,252,630,220,567,220,472,252,410,284,378,378,346,284,346,189,315,158,284,126,220,126,126,158,63,189,32,284,0,378,0,472,32,536,94,567,158]]],"F":[630,[[346,472,284,472,220,504,189,567,220,630,315,662,410,662,536,630,630,630,693,662],[536,630,472,410,410,220,346,94,284,32,220,0,158,0,94,32,63,94,63,158,94,189,158,189,220,158],[315,346,598,346]]],"G":[724,[[32,0,94,32,220,158,315,315,346,410,378,536,378,630,346,662,315,662,284,630,252,567,252,472,284,410,346,378,472,378,567,410,598,441,630,504,630,315,598,158,567,94,504,32,410,0,284,0,189,32,126,94,94,158,94,220]]],"H":[756,[[252,441,189,472,158,536,158,567,189,630,252,662,284,662,346,630,378,567,378,504,346,378,284,189,220,63,158,0,94,0,63,32,63,94],[252,284,536,378,598,410,693,472,756,536,788,598,788,630,756,662,724,662,662,598,598,472,536,284,504,126,504,32,536,0,567,0,630,32,662,63,724,158]]],"I":[536,[[472,158,410,220,346,315,315,378,284,472,284,567,315,630,346,662,410,662,441,630,472,567,472,472,441,315,378,158,346,94,284,32,220,0,158,0,94,32,63,94,63,158,94,189,158,189,220,158]]],"J":[472,[[346,-94,284,0,220,158,189,346,189,536,220,630,284,662,346,662,378,630,410,536,410,441,378,284,284,0,220,-189,189,-284,158,-346,94,-378,63,-346,63,-284,94,-189,158,-94,220,-32,315,32,441,94]]],"K":[756,[[252,441,189,472,158,536,158,567,189,630,252,662,284,662,346,630,378,567,378,504,346,378,284,189,220,63,158,0,94,0,63,32,63,94],[788,567,788,630,756,662,724,662,662,630,598,567,536,472,472,410,410,378,346,378],[410,378,441,315,441,94,472,32,504,0,536,0,598,32,630,63,693,158]]],"L":[598,[[158,284,220,284,346,315,441,378,504,441,536,504,536,598,504,662,441,662,410,630,378,567,346,410,315,252,284,158,252,94,189,32,126,0,63,0,32,32,32,94,63,126,126,126,189,94,284,32,378,0,441,0,536,32,598,94]]],"M":[1040,[[189,441,126,472,94,536,94,567,126,630,189,662,220,662,284,630,315,567,315,504,284,346,252,220,189,0],[252,220,346,472,410,598,441,630,504,662,536,662,598,630,630,567,630,504,598,346,567,220,504,0],[567,220,662,472,724,598,756,630,819,662,850,662,914,630,945,567,945,504,914,346,850,126,850,32,882,0,914,0,976,32,1008,63,1071,158]]],"N":[756,[[189,441,126,472,94,536,94,567,126,630,189,662,220,662,284,630,315,567,315,504,284,346,252,220,189,0],[252,220,346,472,410,598,441,630,504,662,567,662,630,630,662,567,662,504,630,346,567,126,567,32,598,0,630,0,693,32,724,63,788,158]]],"O":[662,[[410,662,315,630,252,567,189,472,158,410,126,284,126,158,158,63,189,32,252,0,315,0,410,32,472,94,536,189,567,252,598,378,598,504,567,598,536,630,472,662,410,662,346,598,346,504,378,410,441,315,504,252,598,189,662,158]]],"P":[788,[[441,598,472,567,472,472,441,346,410,252,378,189,315,94,252,32,189,0,158,0,126,32,126,126,158,284,189,378,220,441,284,536,346,598,410,630,504,662,662,662,724,630,756,598,788,536,788,441,756,378,724,346,662,315,567,315,504,346,472,378]]],"Q":[693,[[441,472,410,410,378,378,315,346,252,346,220,410,220,472,252,567,315,630,410,662,504,662,567,630,598,567,598,441,567,346,504,252,378,126,284,63,220,32,126,0,63,0,32,32,32,94,63,126,126,126,189,94,284,32,378,0,472,0,567,32,630,94]]],"R":[788,[[441,598,472,567,472,472,441,346,410,252,378,189,315,94,252,32,189,0,158,0,126,32,126,126,158,284,189,378,220,441,284,536,346,598,410,630,504,662,630,662,693,630,724,598,756,536,756,441,724,378,693,346,630,315,536,315,441,346,472,315,504,252,504,94,536,32,598,0,662,32,693,63,756,158]]],"S":[630,[[32,0,94,32,158,94,252,220,315,315,378,441,410,536,410,630,378,662,346,662,315,630,284,567,284,504,315,441,378,378,472,315,536,252,567,189,567,126,536,63,504,32,410,0,284,0,189,32,126,94,94,158,94,220]]],"T":[598,[[346,472,284,472,220,504,189,567,220,630,315,662,410,662,536,630,630,630,693,662],[536,630,472,410,410,220,346,94,284,32,220,0,158,0,94,32,63,94,63,158,94,189,158,189,220,158]]],"U":[756,[[189,441,126,472,94,536,94,567,126,630,189,662,220,662,284,630,315,567,315,504,284,378,252,284,220,158,220,94,252,32,315,0,378,0,441,32,472,63,536,189,630,441,693,662],[630,441,598,315,567,126,567,32,598,0,630,0,693,32,724,63,788,158]]],"V":[724,[[189,441,126,472,94,536,94,567,126,630,189,662,220,662,284,630,315,567,315,504,284,378,252,284,220,158,220,63,252,0,315,0,378,32,472,126,536,220,598,346,630,441,662,567,662,630,630,662,598,662,567,630,536,567,536,504,567,410,630,346,693,315]]],"W":[882,[[189,441,126,472,94,536,94,567,126,630,189,662,220,662,284,630,315,567,315,472,284,0],[598,662,284,0],[598,662,536,0],[976,662,914,630,819,536,724,410,630,220,536,0]]],"X":[756,[[284,472,220,472,189,504,189,567,220,630,284,662,346,662,410,630,441,567,441,472,378,189,378,94,410,32,472,0,536,0,598,32,630,94,630,158,598,189,536,189],[756,567,756,630,724,662,662,662,598,630,536,567,472,472,346,189,284,94,220,32,158,0,94,0,63,32,63,94]]],"Y":[724,[[189,441,126,472,94,536,94,567,126,630,189,662,220,662,284,630,315,567,315,504,284,378,252,284,220,158,220,94,252,32,284,0,346,0,410,32,472,94,536,189,567,252,630,441],[693,662,630,441,536,126,472,-63,410,-220,346,-346,284,-378,252,-346,252,-284,284,-189,346,-94,441,0,536,63,693,158]]],"Z":[662,[[441,472,410,410,378,378,315,346,252,346,220,410,220,472,252,567,315,630,410,662,504,662,567,630,598,567,598,441,567,346,504,220,410,126,284,32,220,0,126,0,94,32,94,94,126,126,220,126,284,94,315,63,346,0,346,-94,315,-189,284,-252,220,-346,158,-378,126,-346,126,-284,158,-189,220,-94,315,0,410,63,598,158]]],"[":[441,[[158,788,158,-220],[189,788,189,-220],[158,788,378,788],[158,-220,378,-220]]],"\\":[441,[[32,662,472,-94]]],"]":[441,[[315,788,315,-220],[346,788,346,-220],[126,788,346,788],[126,-220,346,-220]]],"^":[504,[[284,724,32,284],[284,724,536,284]]],"_":[504,[[32,-63,536,-63]]],"`":[346,[[315,662,252,598,220,536,220,504,252,472,284,504,252,536]]],"a":[504,[[315,189,284,252,220,284,158,284,94,252,63,220,32,158,32,94,63,32,126,0,189,0,252,32,284,94,346,284,315,126,315,32,346,0,378,0,441,32,472,63,536,158]]],"b":[441,[[32,158,94,252,189,410,220,472,252,567,252,630,220,662,158,630,126,567,94,441,63,220,63,32,94,0,126,0,189,32,252,94,284,189,284,284,315,158,346,126,410,126,472,158]]],"c":[346,[[252,220,252,252,220,284,158,284,94,252,63,220,32,158,32,94,63,32,126,0,220,0,315,63,378,158]]],"d":[504,[[315,189,284,252,220,284,158,284,94,252,63,220,32,158,32,94,63,32,126,0,189,0,252,32,284,94,472,662],[346,284,315,126,315,32,346,0,378,0,441,32,472,63,536,158]]],"e":[315,[[63,63,126,94,158,126,189,189,189,252,158,284,126,284,63,252,32,189,32,94,63,32,126,0,189,0,252,32,284,63,346,158]]],"f":[252,[[32,158,158,315,220,410,252,472,284,567,284,630,252,662,189,630,158,567,94,315,0,32,-94,-189,-126,-284,-126,-346,-94,-378,-32,-346,0,-252,32,32,63,0,126,0,189,32,220,63,284,158]]],"g":[472,[[315,189,284,252,220,284,158,284,94,252,63,220,32,158,32,94,63,32,126,0,189,0,252,32,284,63],[346,284,284,63,158,-284,126,-346,63,-378,32,-346,32,-284,63,-189,158,-94,252,-32,315,0,410,63,504,158]]],"h":[472,[[32,158,94,252,189,410,220,472,252,567,252,630,220,662,158,630,126,567,94,441,63,252,32,0],[32,0,63,94,94,158,158,252,220,284,284,284,315,252,315,189,284,94,284,32,315,0,346,0,410,32,441,63,504,158]]],"i":[220,[[126,441,126,410,158,410,158,441,126,441],[32,158,94,284,32,94,32,32,63,0,94,0,158,32,189,63,252,158]]],"j":[220,[[126,441,126,410,158,410,158,441,126,441],[32,158,94,284,-94,-284,-126,-346,-189,-378,-220,-346,-220,-284,-189,-189,-94,-94,0,-32,63,0,158,63,252,158]]],"k":[441,[[32,158,94,252,189,410,220,472,252,567,252,630,220,662,158,630,126,567,94,441,63,252,32,0],[32,0,63,94,94,158,158,252,220,284,284,284,315,252,315,189,252,158,158,158],[158,158,220,126,252,32,284,0,315,0,378,32,410,63,472,158]]],"l":[252,[[32,158,94,252,189,410,220,472,252,567,252,630,220,662,158,630,126,567,94,441,63,220,63,32,94,0,126,0,189,32,220,63,284,158]]],"m":[788,[[32,158,94,252,158,284,189,252,189,220,158,94,126,0],[158,94,189,158,252,252,315,284,378,284,410,252,410,220,378,94,346,0],[378,94,410,158,472,252,536,284,598,284,630,252,630,189,598,94,598,32,630,0,662,0,724,32,756,63,819,158]]],"n":[567,[[32,158,94,252,158,284,189,252,189,220,158,94,126,0],[158,94,189,158,252,252,315,284,378,284,410,252,410,189,378,94,378,32,410,0,441,0,504,32,536,63,598,158]]],"o":[441,[[220,284,158,284,94,252,63,220,32,158,32,94,63,32,126,0,189,0,252,32,284,63,315,126,315,189,284,252,220,284,189,252,189,189,220,126,284,94,378,94,441,126,472,158]]],"p":[472,[[32,158,94,252,126,315,94,189,-94,-378],[94,189,126,252,189,284,252,284,315,252,346,189,346,126,315,63,284,32,220,0],[94,32,158,0,252,0,346,32,410,63,504,158]]],"q":[472,[[315,189,284,252,220,284,158,284,94,252,63,220,32,158,32,94,63,32,126,0,189,0,252,32],[346,284,315,189,252,32,158,-189,126,-284,126,-346,158,-378,220,-346,252,-252,252,-32,315,0,410,63,504,158]]],"r":[410,[[32,158,94,252,126,315,126,252,220,252,252,220,252,158,220,63,220,32,252,0,284,0,346,32,378,63,441,158]]],"s":[346,[[32,158,94,252,126,315,126,252,189,158,220,94,220,32,158,0],[32,32,94,0,220,0,284,32,315,63,378,158]]],"t":[284,[[32,158,94,252,158,378],[252,662,63,94,63,32,94,0,158,0,220,32,252,63,315,158],[63,410,284,410]]],"u":[472,[[32,158,94,284,32,94,32,32,63,0,126,0,189,32,252,94,315,189],[346,284,284,94,284,32,315,0,346,0,410,32,441,63,504,158]]],"v":[472,[[32,158,94,284,63,126,63,32,94,0,126,0,220,32,284,94,315,189,315,284],[315,284,346,158,378,126,441,126,504,158]]],"w":[662,[[126,284,63,220,32,126,32,63,63,0,126,0,189,32,252,94],[315,284,252,94,252,32,284,0,346,0,410,32,472,94,504,189,504,284],[504,284,536,158,567,126,630,126,693,158]]],"x":[504,[[32,158,94,252,158,284,220,284,252,252,252,32,284,0,378,0,472,63,536,158],[441,252,410,284,346,284,315,252,189,32,158,0,94,0,63,32]]],"y":[472,[[32,158,94,284,32,94,32,32,63,0,126,0,189,32,252,94,315,189],[346,284,158,-284,126,-346,63,-378,32,-346,32,-284,63,-189,158,-94,252,-32,315,0,410,63,504,158]]],"z":[441,[[32,158,94,252,158,284,220,284,284,220,284,158,252,94,189,32,94,0,158,-32,189,-94,189,-189,158,-284,126,-346,63,-378,32,-346,32,-284,63,-189,158,-94,252,-32,378,63,472,158]]],"{":[441,[[315,788,252,756,220,724,189,662,189,598,220,536,252,504,284,441,284,378,220,315],[252,756,220,693,220,630,252,567,284,536,315,472,315,410,284,346,158,284,284,220,315,158,315,94,284,32,252,0,220,-63,220,-126,252,-189],[220,252,284,189,284,126,252,63,220,32,189,-32,189,-94,220,-158,252,-189,315,-220]]],"|":[252,[[158,788,158,-220]]],"}":[441,[[189,788,252,756,284,724,315,662,315,598,284,536,252,504,220,441,220,378,284,315],[252,756,284,693,284,630,252,567,220,536,189,472,189,410,220,346,346,284,220,220,189,158,189,94,220,32,252,0,284,-63,284,-126,252,-189],[284,252,220,189,220,126,252,63,284,32,315,-32,315,-94,284,-158,252,-189,189,-220]]],"~":[756,[[126,189,126,252,158,346,220,378,284,378,346,346,472,252,536,220,598,220,662,252,693,315],[126,252,158,315,220,346,284,346,346,315,472,220,536,189,598,189,662,220,693,315,693,378]]]};
|
|
18
|
+
/** The face's height above and below the baseline (its SVG font's ascent and descent), and the most characters a typed hand takes. */
|
|
19
|
+
const ASCENT = 800, DESCENT = 200;
|
|
20
|
+
export const TYPED_MAX = 24;
|
|
21
|
+
/** What a typed hand can hold: the characters this face draws. Anything else is left out, never guessed at. */
|
|
22
|
+
export const typedChars = (text: string) => [...text].filter((ch) => ch in FACE).slice(0, TYPED_MAX).join("");
|
|
23
|
+
/**
|
|
24
|
+
* The typed hand: `text` set in the script, fitted to the pad with a margin and centered on it. Null when nothing drawable is left (an
|
|
25
|
+
* empty name, or a name in a script this face lacks). Deterministic: the same text is always the same strokes.
|
|
26
|
+
*/
|
|
27
|
+
export function typedAutograph(text: string): BqrAutograph | null {
|
|
28
|
+
const chars = [...typedChars(text)];
|
|
29
|
+
const raw: [number, number][][] = [];
|
|
30
|
+
let x = 0;
|
|
31
|
+
for (const ch of chars) {
|
|
32
|
+
const [adv, strokes] = FACE[ch];
|
|
33
|
+
for (const st of strokes) { const s: [number, number][] = []; for (let i = 0; i < st.length; i += 2) s.push([x + st[i], ASCENT - st[i + 1]]); if (s.length) raw.push(s); }
|
|
34
|
+
x += adv;
|
|
35
|
+
}
|
|
36
|
+
if (!raw.length) return null;
|
|
37
|
+
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity;
|
|
38
|
+
for (const s of raw) for (const [a, b] of s) { x0 = Math.min(x0, a); x1 = Math.max(x1, a); y0 = Math.min(y0, b); y1 = Math.max(y1, b); }
|
|
39
|
+
// A name with no tall letters is never blown up to the pad's height: the height it is fitted by is at least the face's x-height and more.
|
|
40
|
+
const M = 4, k = Math.min((BQR_PAD_W - 2 * M) / Math.max(x1 - x0, 1), (BQR_PAD_H - 2 * M) / Math.max(y1 - y0, (ASCENT + DESCENT) * 0.6));
|
|
41
|
+
const ox = (BQR_PAD_W - (x1 - x0) * k) / 2, oy = (BQR_PAD_H - (y1 - y0) * k) / 2, r = (v: number) => Math.round(v * 10) / 10;
|
|
42
|
+
let n = 0;
|
|
43
|
+
const strokes = raw.map((s) => s.map(([a, b]) => [r(ox + (a - x0) * k), r(oy + (b - y0) * k)] as [number, number])).filter((s) => (n += s.length) <= BQR_AUTOGRAPH_POINTS);
|
|
44
|
+
return strokes.length ? { strokes } : null;
|
|
45
|
+
}
|