harmonink 0.3.0 → 0.3.1
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/package.json +5 -2
- package/src/live.js +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harmonink",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Tiny font metric normalizer — makes any font render at a consistent, readable x-height",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"./css": "./src/css.js"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"harmonink": "
|
|
15
|
+
"harmonink": "bin/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"src",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "node test/run.js",
|
|
27
|
+
"checks": "node test/checks.mjs",
|
|
27
28
|
"census": "node test/census.mjs",
|
|
29
|
+
"census:browser": "sh -c 'node test/census-live.mjs \"$@\" && node test/census-live-guard.mjs' --",
|
|
30
|
+
"census:browser:linux": "docker run --rm --ipc=host -v \"$PWD\":\"$PWD\" -w \"$PWD\" mcr.microsoft.com/playwright:v1.64.1-noble npm run census:browser --",
|
|
28
31
|
"guards": "node test/guards.mjs",
|
|
29
32
|
"fuzz": "node test/fuzz.mjs",
|
|
30
33
|
"released": "node test/released.mjs",
|
package/src/live.js
CHANGED
|
@@ -6,8 +6,11 @@ const MARGIN = 0.01;
|
|
|
6
6
|
// a canvas in the page inherits its font styles: all:initial resets every one but direction
|
|
7
7
|
const STYLE = 'all:initial;direction:ltr;display:none;font-optical-sizing:none;-webkit-font-smoothing:antialiased';
|
|
8
8
|
|
|
9
|
+
// the largest font size Firefox draws on a canvas, and the most any engine is asked for
|
|
10
|
+
const MOST = 2000;
|
|
11
|
+
|
|
9
12
|
export function measureLive(family, { em = 512, size, canvas } = {}) {
|
|
10
|
-
const unit = size ?? em;
|
|
13
|
+
const unit = Math.min(size ?? em, MOST);
|
|
11
14
|
// no page to style a canvas in, as in a worker: the handed canvas is drawn on as it is
|
|
12
15
|
if (!globalThis.document) return read(canvas, family, unit);
|
|
13
16
|
const cv = document.createElement('canvas');
|