postext 1.60.0 → 1.61.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/dist/__tests__/exercises/digital.test.js +38 -1
- package/dist/__tests__/exercises/digital.test.js.map +1 -1
- package/dist/__tests__/exports.test.js +16 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/figureStyle.test.d.ts +2 -0
- package/dist/__tests__/figureStyle.test.d.ts.map +1 -0
- package/dist/__tests__/figureStyle.test.js +218 -0
- package/dist/__tests__/figureStyle.test.js.map +1 -0
- package/dist/__tests__/headingLetterSpacing.test.js +1 -1
- package/dist/__tests__/headingLetterSpacing.test.js.map +1 -1
- package/dist/__tests__/pipeline/paragraphStyleFaces.test.js +1 -1
- package/dist/__tests__/pipeline/paragraphStyleFaces.test.js.map +1 -1
- package/dist/__tests__/pipeline/spanBands.test.js +2 -1
- package/dist/__tests__/pipeline/spanBands.test.js.map +1 -1
- package/dist/__tests__/pipeline/spanHeadingMidPage.test.js +53 -0
- package/dist/__tests__/pipeline/spanHeadingMidPage.test.js.map +1 -1
- package/dist/__tests__/pipeline/trailingBand.test.js +36 -1
- package/dist/__tests__/pipeline/trailingBand.test.js.map +1 -1
- package/dist/canvas-backend/verticalText.d.ts.map +1 -1
- package/dist/canvas-backend/verticalText.js +5 -2
- package/dist/canvas-backend/verticalText.js.map +1 -1
- package/dist/configWarnings.d.ts.map +1 -1
- package/dist/configWarnings.js +18 -4
- package/dist/configWarnings.js.map +1 -1
- package/dist/defaults/bodyText.d.ts.map +1 -1
- package/dist/defaults/bodyText.js +8 -1
- package/dist/defaults/bodyText.js.map +1 -1
- package/dist/defaults/captionStyle.d.ts.map +1 -1
- package/dist/defaults/captionStyle.js +7 -2
- package/dist/defaults/captionStyle.js.map +1 -1
- package/dist/defaults/headerFooter.d.ts.map +1 -1
- package/dist/defaults/headerFooter.js +3 -1
- package/dist/defaults/headerFooter.js.map +1 -1
- package/dist/defaults/headings.d.ts.map +1 -1
- package/dist/defaults/headings.js +15 -3
- package/dist/defaults/headings.js.map +1 -1
- package/dist/defaults/paragraphStyles.d.ts.map +1 -1
- package/dist/defaults/paragraphStyles.js +4 -1
- package/dist/defaults/paragraphStyles.js.map +1 -1
- package/dist/defaults/tableStyle.d.ts.map +1 -1
- package/dist/defaults/tableStyle.js +5 -2
- package/dist/defaults/tableStyle.js.map +1 -1
- package/dist/design/elementKeys.d.ts +1 -0
- package/dist/design/elementKeys.d.ts.map +1 -1
- package/dist/design/elementKeys.js +1 -1
- package/dist/design/elementKeys.js.map +1 -1
- package/dist/exercises/digital.d.ts +7 -0
- package/dist/exercises/digital.d.ts.map +1 -1
- package/dist/exercises/digital.js +8 -1
- package/dist/exercises/digital.js.map +1 -1
- package/dist/exercises/expand.d.ts +4 -0
- package/dist/exercises/expand.d.ts.map +1 -1
- package/dist/exercises/expand.js +65 -4
- package/dist/exercises/expand.js.map +1 -1
- package/dist/exercises/record.d.ts +4 -0
- package/dist/exercises/record.d.ts.map +1 -1
- package/dist/exercises/runtime.d.ts +6 -0
- package/dist/exercises/runtime.d.ts.map +1 -1
- package/dist/exercises/runtime.js +432 -59
- package/dist/exercises/runtime.js.map +1 -1
- package/dist/exercises/styles.d.ts +1 -0
- package/dist/exercises/styles.d.ts.map +1 -1
- package/dist/exercises/styles.js +3 -0
- package/dist/exercises/styles.js.map +1 -1
- package/dist/fonts/featureFaces.d.ts +32 -0
- package/dist/fonts/featureFaces.d.ts.map +1 -0
- package/dist/fonts/featureFaces.js +166 -0
- package/dist/fonts/featureFaces.js.map +1 -0
- package/dist/fonts/figureStyle.d.ts +69 -0
- package/dist/fonts/figureStyle.d.ts.map +1 -0
- package/dist/fonts/figureStyle.js +196 -0
- package/dist/fonts/figureStyle.js.map +1 -0
- package/dist/fonts/freezeFeatures.d.ts +10 -0
- package/dist/fonts/freezeFeatures.d.ts.map +1 -0
- package/dist/fonts/freezeFeatures.js +372 -0
- package/dist/fonts/freezeFeatures.js.map +1 -0
- package/dist/fonts/glyphFallback.d.ts.map +1 -1
- package/dist/fonts/glyphFallback.js +6 -3
- package/dist/fonts/glyphFallback.js.map +1 -1
- package/dist/fonts/prepare.d.ts.map +1 -1
- package/dist/fonts/prepare.js +22 -4
- package/dist/fonts/prepare.js.map +1 -1
- package/dist/fonts/usage.d.ts +10 -0
- package/dist/fonts/usage.d.ts.map +1 -1
- package/dist/fonts/usage.js +97 -0
- package/dist/fonts/usage.js.map +1 -1
- package/dist/html-backend.d.ts.map +1 -1
- package/dist/html-backend.js +8 -5
- package/dist/html-backend.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/bandCaps.d.ts +11 -0
- package/dist/pipeline/bandCaps.d.ts.map +1 -1
- package/dist/pipeline/bandCaps.js +22 -2
- package/dist/pipeline/bandCaps.js.map +1 -1
- package/dist/pipeline/build.d.ts.map +1 -1
- package/dist/pipeline/build.js +17 -7
- package/dist/pipeline/build.js.map +1 -1
- package/dist/pipeline/headingStyles.d.ts.map +1 -1
- package/dist/pipeline/headingStyles.js +3 -0
- package/dist/pipeline/headingStyles.js.map +1 -1
- package/dist/types.d.ts +45 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker/client.d.ts.map +1 -1
- package/dist/worker/client.js +13 -2
- package/dist/worker/client.js.map +1 -1
- package/dist/worker/fonts.d.ts +1 -1
- package/dist/worker/fonts.d.ts.map +1 -1
- package/dist/worker/fonts.js +1 -1
- package/dist/worker/fonts.js.map +1 -1
- package/dist/worker/protocol.d.ts +4 -0
- package/dist/worker/protocol.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The faces of a feature family (#1237, `figureStyle.ts`): the files of its
|
|
2
|
+
// base family's faces declared again under its name, with the
|
|
3
|
+
// `featureSettings` descriptor that turns its figures on. A face's file is
|
|
4
|
+
// known when the engine made the face (`prepareFonts`, a layout worker's
|
|
5
|
+
// `registerFonts`), which remembers it here, or when a style sheet of the
|
|
6
|
+
// page declares it (`@font-face`, read through the CSSOM: a sheet of
|
|
7
|
+
// another origin loaded without CORS cannot be read). A host that declares
|
|
8
|
+
// faces any other way declares the feature family's itself.
|
|
9
|
+
import { featureFamilyParts, fontFeatureSettings } from './figureStyle.js';
|
|
10
|
+
const sources = new WeakMap();
|
|
11
|
+
/** Remember the file `face` was made from, so a feature family of its
|
|
12
|
+
* family can be declared from it. */
|
|
13
|
+
export function rememberFaceSource(face, source, descriptors) {
|
|
14
|
+
sources.set(face, { source, descriptors });
|
|
15
|
+
}
|
|
16
|
+
function unquote(family) {
|
|
17
|
+
const f = family.trim();
|
|
18
|
+
return /^(["']).*\1$/.test(f) ? f.slice(1, -1).trim() : f;
|
|
19
|
+
}
|
|
20
|
+
/** A `src` value with its `url()`s made absolute against `base` (a style
|
|
21
|
+
* sheet's URL): a `FontFace` resolves them against the document. */
|
|
22
|
+
function absoluteSrc(src, base) {
|
|
23
|
+
if (!base)
|
|
24
|
+
return src;
|
|
25
|
+
return src.replace(/url\(\s*(["']?)([^"')]+)\1\s*\)/g, (whole, quote, url) => {
|
|
26
|
+
try {
|
|
27
|
+
return `url(${quote}${new URL(url, base).href}${quote})`;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return whole;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const FONT_FACE_RULE = 5;
|
|
35
|
+
const IMPORT_RULE = 3;
|
|
36
|
+
/** The `@font-face` rules of the page's style sheets for `family`. */
|
|
37
|
+
function sheetSources(family) {
|
|
38
|
+
const doc = globalThis.document;
|
|
39
|
+
if (!doc?.styleSheets)
|
|
40
|
+
return [];
|
|
41
|
+
const lower = family.toLowerCase();
|
|
42
|
+
const out = [];
|
|
43
|
+
const visit = (sheet, depth) => {
|
|
44
|
+
if (!sheet || depth > 4)
|
|
45
|
+
return;
|
|
46
|
+
let rules;
|
|
47
|
+
try {
|
|
48
|
+
rules = sheet.cssRules;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// A sheet of another origin, loaded without CORS.
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (let i = 0; i < (rules?.length ?? 0); i++) {
|
|
55
|
+
const rule = rules[i];
|
|
56
|
+
if (rule.type === IMPORT_RULE) {
|
|
57
|
+
visit(rule.styleSheet, depth + 1);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (rule.type !== FONT_FACE_RULE || !rule.style)
|
|
61
|
+
continue;
|
|
62
|
+
const read = (name) => rule.style.getPropertyValue(name).trim();
|
|
63
|
+
if (unquote(read('font-family')).toLowerCase() !== lower)
|
|
64
|
+
continue;
|
|
65
|
+
const src = read('src');
|
|
66
|
+
if (!src)
|
|
67
|
+
continue;
|
|
68
|
+
const descriptors = {};
|
|
69
|
+
const weight = read('font-weight');
|
|
70
|
+
const style = read('font-style');
|
|
71
|
+
const stretch = read('font-stretch');
|
|
72
|
+
const range = read('unicode-range');
|
|
73
|
+
if (weight)
|
|
74
|
+
descriptors.weight = weight;
|
|
75
|
+
if (style)
|
|
76
|
+
descriptors.style = style;
|
|
77
|
+
if (stretch)
|
|
78
|
+
descriptors.stretch = stretch;
|
|
79
|
+
if (range)
|
|
80
|
+
descriptors.unicodeRange = range;
|
|
81
|
+
out.push({ source: absoluteSrc(src, sheet.href ?? doc.baseURI), descriptors });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
for (let i = 0; i < doc.styleSheets.length; i++)
|
|
85
|
+
visit(doc.styleSheets[i], 0);
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
/** The files of `base`'s faces: those `fontSet` holds that the engine
|
|
89
|
+
* made, and those the page's style sheets declare. */
|
|
90
|
+
export function baseFaceSources(fontSet, base) {
|
|
91
|
+
const lower = base.toLowerCase();
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const face of fontSet) {
|
|
94
|
+
if (unquote(face.family).toLowerCase() !== lower)
|
|
95
|
+
continue;
|
|
96
|
+
const known = sources.get(face);
|
|
97
|
+
if (known)
|
|
98
|
+
out.push(known);
|
|
99
|
+
}
|
|
100
|
+
return [...out, ...sheetSources(base)];
|
|
101
|
+
}
|
|
102
|
+
const declared = new WeakMap();
|
|
103
|
+
function sourceKey(file) {
|
|
104
|
+
const d = file.descriptors;
|
|
105
|
+
return `${String(file.source)}|${d.weight ?? ''}|${d.style ?? ''}|${d.stretch ?? ''}|${d.unicodeRange ?? ''}`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Declare in `fontSet` the faces of feature family `family` (`Lora@onum`)
|
|
109
|
+
* from `files`, the files of its base family's faces, with the
|
|
110
|
+
* `featureSettings` of its features; each file once (by its bytes, or its
|
|
111
|
+
* `src` and descriptors), so a file the base family gains later is added
|
|
112
|
+
* on the next call. Returns the faces added, unloaded: `fontSet.load`
|
|
113
|
+
* loads the ones a text needs. None for a plain family, or with no
|
|
114
|
+
* `FontFace` constructor.
|
|
115
|
+
*/
|
|
116
|
+
export function addFeatureFaces(fontSet, family, files, FontFaceCtor) {
|
|
117
|
+
const parts = featureFamilyParts(family);
|
|
118
|
+
if (parts.features.length === 0)
|
|
119
|
+
return [];
|
|
120
|
+
const Ctor = FontFaceCtor ?? globalThis.FontFace;
|
|
121
|
+
if (!Ctor)
|
|
122
|
+
return [];
|
|
123
|
+
let byFamily = declared.get(fontSet);
|
|
124
|
+
if (!byFamily)
|
|
125
|
+
declared.set(fontSet, (byFamily = new Map()));
|
|
126
|
+
const name = unquote(family);
|
|
127
|
+
let seen = byFamily.get(name.toLowerCase());
|
|
128
|
+
if (!seen)
|
|
129
|
+
byFamily.set(name.toLowerCase(), (seen = { bytes: new WeakSet(), texts: new Set() }));
|
|
130
|
+
const featureSettings = fontFeatureSettings(parts.features);
|
|
131
|
+
const added = [];
|
|
132
|
+
for (const file of files) {
|
|
133
|
+
if (typeof file.source === 'string') {
|
|
134
|
+
const key = sourceKey(file);
|
|
135
|
+
if (seen.texts.has(key))
|
|
136
|
+
continue;
|
|
137
|
+
seen.texts.add(key);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
if (seen.bytes.has(file.source))
|
|
141
|
+
continue;
|
|
142
|
+
seen.bytes.add(file.source);
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const face = new Ctor(name, file.source, { ...file.descriptors, featureSettings });
|
|
146
|
+
fontSet.add(face);
|
|
147
|
+
added.push(face);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// A source the constructor refuses: the family stays as it is.
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return added;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Declare in `fontSet` the faces of feature family `family` from the files
|
|
157
|
+
* of its base family's faces the engine knows ({@link baseFaceSources}),
|
|
158
|
+
* as {@link addFeatureFaces} does.
|
|
159
|
+
*/
|
|
160
|
+
export function declareFeatureFaces(fontSet, family, FontFaceCtor) {
|
|
161
|
+
const parts = featureFamilyParts(family);
|
|
162
|
+
if (parts.features.length === 0)
|
|
163
|
+
return [];
|
|
164
|
+
return addFeatureFaces(fontSet, family, baseFaceSources(fontSet, parts.family), FontFaceCtor);
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=featureFaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featureFaces.js","sourceRoot":"","sources":["../../src/fonts/featureFaces.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8DAA8D;AAC9D,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,qEAAqE;AACrE,2EAA2E;AAC3E,4DAA4D;AAG5D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAW3E,MAAM,OAAO,GAAG,IAAI,OAAO,EAAsB,CAAC;AAElD;sCACsC;AACtC,MAAM,UAAU,kBAAkB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
|
+
import type { FigureStyle } from '../types.js';
|
|
2
|
+
/** Every {@link FigureStyle} value, in the order a picker lists them. */
|
|
3
|
+
export declare const FIGURE_STYLES: readonly FigureStyle[];
|
|
4
|
+
/** The features a feature family may carry, in the order it names them. */
|
|
5
|
+
declare const FEATURE_ORDER: readonly ["onum", "lnum", "pnum", "tnum"];
|
|
6
|
+
export type FigureFeature = (typeof FEATURE_ORDER)[number];
|
|
7
|
+
/** Whether `value` is a {@link FigureStyle} value. */
|
|
8
|
+
export declare function isFigureStyle(value: unknown): value is FigureStyle;
|
|
9
|
+
/** The features `style` turns on (none for `'default'` or a value it does
|
|
10
|
+
* not know). */
|
|
11
|
+
export declare function figureFeatures(style: FigureStyle | undefined): FigureFeature[];
|
|
12
|
+
/** A family name's parts: the family its files are, and the features a
|
|
13
|
+
* feature family sets them with (none for a plain family). */
|
|
14
|
+
export interface FeatureFamilyParts {
|
|
15
|
+
family: string;
|
|
16
|
+
features: readonly FigureFeature[];
|
|
17
|
+
}
|
|
18
|
+
/** The parts of a family name {@link featureFamily} wrote
|
|
19
|
+
* (`Lora@onum+tnum` → Lora, onum and tnum); a plain family comes back as
|
|
20
|
+
* it is, with no features. */
|
|
21
|
+
export declare function featureFamilyParts(family: string): FeatureFamilyParts;
|
|
22
|
+
/** Whether `family` is a feature family. */
|
|
23
|
+
export declare function isFeatureFamily(family: string): boolean;
|
|
24
|
+
/** The family a feature family's files are (`Lora@onum` → Lora); any
|
|
25
|
+
* other family as it is. */
|
|
26
|
+
export declare function baseFontFamily(family: string): string;
|
|
27
|
+
/** The feature family that sets `family`'s base family in `features` (the
|
|
28
|
+
* base family itself when there are none). */
|
|
29
|
+
export declare function featureFamily(family: string, features: readonly FigureFeature[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Tell the engine which families a host can declare with features (#1237):
|
|
32
|
+
* one whose files it has. A family it cannot (a face only installed on the
|
|
33
|
+
* reader's system, which no file declares again under a feature family's
|
|
34
|
+
* name) takes no figure style: its text keeps the font's own figures in
|
|
35
|
+
* the family itself, instead of a fallback face. Set it before the first
|
|
36
|
+
* build, in every thread that lays out (a layout worker too); `undefined`
|
|
37
|
+
* gives every family back. Configurations resolved before keep what they
|
|
38
|
+
* resolved to.
|
|
39
|
+
*/
|
|
40
|
+
export declare function setFigureStyleFamilies(test: ((family: string) => boolean) | undefined): void;
|
|
41
|
+
/**
|
|
42
|
+
* The family a style sets its text in once its `figureStyle` applies:
|
|
43
|
+
* unset keeps `fontFamily` as it is (with the figures it inherits),
|
|
44
|
+
* `'default'` sets its base family, any other value the feature family of
|
|
45
|
+
* the base family. A font stack is cut to its first family
|
|
46
|
+
* (`primaryFontFamily`); a generic family, and one the host cannot declare
|
|
47
|
+
* with features ({@link setFigureStyleFamilies}), takes no features.
|
|
48
|
+
*/
|
|
49
|
+
export declare function withFigureStyle(fontFamily: string, style: FigureStyle | undefined): string;
|
|
50
|
+
/** The `featureSettings` descriptor of a feature family's faces
|
|
51
|
+
* (`"onum" 1, "tnum" 1`); empty for none. */
|
|
52
|
+
export declare function fontFeatureSettings(features: readonly FigureFeature[]): string;
|
|
53
|
+
/** The CSS `font-variant-numeric` value of a feature family's features
|
|
54
|
+
* (`oldstyle-nums tabular-nums`); empty for none. */
|
|
55
|
+
export declare function fontVariantNumeric(features: readonly FigureFeature[]): string;
|
|
56
|
+
/**
|
|
57
|
+
* CSS (a style attribute's declarations, an HTML page's markup) with each
|
|
58
|
+
* `font:` that names a feature family in single quotes (as the HTML
|
|
59
|
+
* backend writes it, `'Lora@onum'`, or escaped, `'Lora@onum'`)
|
|
60
|
+
* set in the base family, followed by the `font-variant-numeric` of its
|
|
61
|
+
* features: a page sets the figures with the base family's faces as any
|
|
62
|
+
* host declares them. The `font` shorthand resets `font-variant-numeric`,
|
|
63
|
+
* so it follows the shorthand it belongs to. Read in one pass: a
|
|
64
|
+
* declaration ends at `;`, at the attribute's `"` (or `"`), or at a
|
|
65
|
+
* tag's bracket.
|
|
66
|
+
*/
|
|
67
|
+
export declare function featureFontCss(css: string): string;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=figureStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figureStyle.d.ts","sourceRoot":"","sources":["../../src/fonts/figureStyle.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,yEAAyE;AACzE,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAU/C,CAAC;AAEF,2EAA2E;AAC3E,QAAA,MAAM,aAAa,2CAA4C,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAY3D,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;iBACiB;AACjB,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,aAAa,EAAE,CAI9E;AAUD;+DAC+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;CACpC;AAED;;+BAE+B;AAC/B,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAMrE;AAED,4CAA4C;AAC5C,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;6BAC6B;AAC7B,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;+CAC+C;AAC/C,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAIxF;AAMD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAE5F;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAK1F;AAED;8CAC8C;AAC9C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAE9E;AAED;sDACsD;AACtD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAE7E;AAoBD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8BlD"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// Figure styles per text style (#1237): old-style figures in running text,
|
|
2
|
+
// lining and tabular ones in tables and headings. A style's `figureStyle`
|
|
3
|
+
// asks its font for the OpenType features that set them (`onum`, `lnum`,
|
|
4
|
+
// `tnum`, `pnum`), and the resolved configuration names its family with
|
|
5
|
+
// them: a *feature family* (`Lora@onum`, `Lora@lnum+tnum`). Every font
|
|
6
|
+
// string the pipeline writes carries it, so the widths of a style's text
|
|
7
|
+
// are measured apart from the same family's other text, and each painter
|
|
8
|
+
// knows what to set:
|
|
9
|
+
//
|
|
10
|
+
// - a canvas measures and paints in the faces a host declares under that
|
|
11
|
+
// name, the base family's files with `featureSettings` (Chrome applies
|
|
12
|
+
// the descriptor to canvas text, measured and painted);
|
|
13
|
+
// - HTML sets the base family with `font-variant-numeric`;
|
|
14
|
+
// - the PDF embeds the base family's files with the features, laid out by
|
|
15
|
+
// fontkit or HarfBuzz as the browser sets them;
|
|
16
|
+
// - Node (the CLI) registers a copy of the file whose `cmap` maps the
|
|
17
|
+
// characters to the glyphs the features choose (`freezeFontFeatures`).
|
|
18
|
+
//
|
|
19
|
+
// A generic family (`serif`) names no face to declare and takes no
|
|
20
|
+
// features.
|
|
21
|
+
import { isGenericFamily } from './faces.js';
|
|
22
|
+
import { primaryFontFamily } from '../measure/font.js';
|
|
23
|
+
/** Every {@link FigureStyle} value, in the order a picker lists them. */
|
|
24
|
+
export const FIGURE_STYLES = [
|
|
25
|
+
'default',
|
|
26
|
+
'oldstyle',
|
|
27
|
+
'lining',
|
|
28
|
+
'tabular',
|
|
29
|
+
'proportional',
|
|
30
|
+
'oldstyle-tabular',
|
|
31
|
+
'oldstyle-proportional',
|
|
32
|
+
'lining-tabular',
|
|
33
|
+
'lining-proportional',
|
|
34
|
+
];
|
|
35
|
+
/** The features a feature family may carry, in the order it names them. */
|
|
36
|
+
const FEATURE_ORDER = ['onum', 'lnum', 'pnum', 'tnum'];
|
|
37
|
+
const FORM = { oldstyle: 'onum', lining: 'lnum' };
|
|
38
|
+
const SPACING = { proportional: 'pnum', tabular: 'tnum' };
|
|
39
|
+
const CSS_VALUE = {
|
|
40
|
+
onum: 'oldstyle-nums',
|
|
41
|
+
lnum: 'lining-nums',
|
|
42
|
+
pnum: 'proportional-nums',
|
|
43
|
+
tnum: 'tabular-nums',
|
|
44
|
+
};
|
|
45
|
+
/** Whether `value` is a {@link FigureStyle} value. */
|
|
46
|
+
export function isFigureStyle(value) {
|
|
47
|
+
return typeof value === 'string' && FIGURE_STYLES.includes(value);
|
|
48
|
+
}
|
|
49
|
+
/** The features `style` turns on (none for `'default'` or a value it does
|
|
50
|
+
* not know). */
|
|
51
|
+
export function figureFeatures(style) {
|
|
52
|
+
if (!isFigureStyle(style) || style === 'default')
|
|
53
|
+
return [];
|
|
54
|
+
const out = style.split('-').map((part) => FORM[part] ?? SPACING[part]);
|
|
55
|
+
return FEATURE_ORDER.filter((f) => out.includes(f));
|
|
56
|
+
}
|
|
57
|
+
const SEPARATOR = '@';
|
|
58
|
+
const FEATURES_RE = /^(?:onum|lnum|pnum|tnum)(?:\+(?:onum|lnum|pnum|tnum))*$/;
|
|
59
|
+
function unquoted(family) {
|
|
60
|
+
const f = family.trim();
|
|
61
|
+
return /^(["']).*\1$/.test(f) ? f.slice(1, -1).trim() : f;
|
|
62
|
+
}
|
|
63
|
+
/** The parts of a family name {@link featureFamily} wrote
|
|
64
|
+
* (`Lora@onum+tnum` → Lora, onum and tnum); a plain family comes back as
|
|
65
|
+
* it is, with no features. */
|
|
66
|
+
export function featureFamilyParts(family) {
|
|
67
|
+
const f = unquoted(family);
|
|
68
|
+
const at = f.lastIndexOf(SEPARATOR);
|
|
69
|
+
const tail = at > 0 ? f.slice(at + 1) : '';
|
|
70
|
+
if (!FEATURES_RE.test(tail))
|
|
71
|
+
return { family, features: [] };
|
|
72
|
+
return { family: f.slice(0, at), features: tail.split('+') };
|
|
73
|
+
}
|
|
74
|
+
/** Whether `family` is a feature family. */
|
|
75
|
+
export function isFeatureFamily(family) {
|
|
76
|
+
return featureFamilyParts(family).features.length > 0;
|
|
77
|
+
}
|
|
78
|
+
/** The family a feature family's files are (`Lora@onum` → Lora); any
|
|
79
|
+
* other family as it is. */
|
|
80
|
+
export function baseFontFamily(family) {
|
|
81
|
+
return featureFamilyParts(family).family;
|
|
82
|
+
}
|
|
83
|
+
/** The feature family that sets `family`'s base family in `features` (the
|
|
84
|
+
* base family itself when there are none). */
|
|
85
|
+
export function featureFamily(family, features) {
|
|
86
|
+
const base = unquoted(baseFontFamily(family));
|
|
87
|
+
const list = FEATURE_ORDER.filter((f) => features.includes(f));
|
|
88
|
+
return list.length > 0 ? `${base}${SEPARATOR}${list.join('+')}` : base;
|
|
89
|
+
}
|
|
90
|
+
/** Whether a family can be declared with features; the host's answer, by
|
|
91
|
+
* default every family but a generic one. */
|
|
92
|
+
let takesFeatures = () => true;
|
|
93
|
+
/**
|
|
94
|
+
* Tell the engine which families a host can declare with features (#1237):
|
|
95
|
+
* one whose files it has. A family it cannot (a face only installed on the
|
|
96
|
+
* reader's system, which no file declares again under a feature family's
|
|
97
|
+
* name) takes no figure style: its text keeps the font's own figures in
|
|
98
|
+
* the family itself, instead of a fallback face. Set it before the first
|
|
99
|
+
* build, in every thread that lays out (a layout worker too); `undefined`
|
|
100
|
+
* gives every family back. Configurations resolved before keep what they
|
|
101
|
+
* resolved to.
|
|
102
|
+
*/
|
|
103
|
+
export function setFigureStyleFamilies(test) {
|
|
104
|
+
takesFeatures = test ?? (() => true);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The family a style sets its text in once its `figureStyle` applies:
|
|
108
|
+
* unset keeps `fontFamily` as it is (with the figures it inherits),
|
|
109
|
+
* `'default'` sets its base family, any other value the feature family of
|
|
110
|
+
* the base family. A font stack is cut to its first family
|
|
111
|
+
* (`primaryFontFamily`); a generic family, and one the host cannot declare
|
|
112
|
+
* with features ({@link setFigureStyleFamilies}), takes no features.
|
|
113
|
+
*/
|
|
114
|
+
export function withFigureStyle(fontFamily, style) {
|
|
115
|
+
if (!isFigureStyle(style))
|
|
116
|
+
return fontFamily;
|
|
117
|
+
const base = unquoted(baseFontFamily(primaryFontFamily(fontFamily)));
|
|
118
|
+
if (isGenericFamily(base) || !takesFeatures(base))
|
|
119
|
+
return base;
|
|
120
|
+
return featureFamily(base, figureFeatures(style));
|
|
121
|
+
}
|
|
122
|
+
/** The `featureSettings` descriptor of a feature family's faces
|
|
123
|
+
* (`"onum" 1, "tnum" 1`); empty for none. */
|
|
124
|
+
export function fontFeatureSettings(features) {
|
|
125
|
+
return features.map((f) => `"${f}" 1`).join(', ');
|
|
126
|
+
}
|
|
127
|
+
/** The CSS `font-variant-numeric` value of a feature family's features
|
|
128
|
+
* (`oldstyle-nums tabular-nums`); empty for none. */
|
|
129
|
+
export function fontVariantNumeric(features) {
|
|
130
|
+
return features.map((f) => CSS_VALUE[f]).join(' ');
|
|
131
|
+
}
|
|
132
|
+
/** The quotes a family takes in a style attribute, as written or escaped. */
|
|
133
|
+
const QUOTES = ["'", ''', ''', '''];
|
|
134
|
+
/** A `font:` value (`400 16px 'Lora@onum'`) whose family is a feature
|
|
135
|
+
* family in quotes, in the base family followed by the declaration of its
|
|
136
|
+
* figures; undefined for any other value. */
|
|
137
|
+
function featureFontValue(value) {
|
|
138
|
+
for (const q of QUOTES) {
|
|
139
|
+
if (value.length < 2 * q.length || !value.endsWith(q))
|
|
140
|
+
continue;
|
|
141
|
+
const open = value.lastIndexOf(q, value.length - q.length - 1);
|
|
142
|
+
if (open < 0)
|
|
143
|
+
return undefined;
|
|
144
|
+
const parts = featureFamilyParts(value.slice(open + q.length, value.length - q.length));
|
|
145
|
+
if (parts.features.length === 0)
|
|
146
|
+
return undefined;
|
|
147
|
+
return `${value.slice(0, open)}${q}${parts.family}${q};font-variant-numeric:${fontVariantNumeric(parts.features)}`;
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* CSS (a style attribute's declarations, an HTML page's markup) with each
|
|
153
|
+
* `font:` that names a feature family in single quotes (as the HTML
|
|
154
|
+
* backend writes it, `'Lora@onum'`, or escaped, `'Lora@onum'`)
|
|
155
|
+
* set in the base family, followed by the `font-variant-numeric` of its
|
|
156
|
+
* features: a page sets the figures with the base family's faces as any
|
|
157
|
+
* host declares them. The `font` shorthand resets `font-variant-numeric`,
|
|
158
|
+
* so it follows the shorthand it belongs to. Read in one pass: a
|
|
159
|
+
* declaration ends at `;`, at the attribute's `"` (or `"`), or at a
|
|
160
|
+
* tag's bracket.
|
|
161
|
+
*/
|
|
162
|
+
export function featureFontCss(css) {
|
|
163
|
+
if (!css.includes('@'))
|
|
164
|
+
return css;
|
|
165
|
+
let out = '';
|
|
166
|
+
let from = 0;
|
|
167
|
+
for (let at = css.indexOf('font:'); at >= 0; at = css.indexOf('font:', at + 5)) {
|
|
168
|
+
const start = at + 5;
|
|
169
|
+
let end = start;
|
|
170
|
+
while (end < css.length) {
|
|
171
|
+
const c = css[end];
|
|
172
|
+
if (c === ';' || c === '"' || c === '<' || c === '>')
|
|
173
|
+
break;
|
|
174
|
+
if (c === '&') {
|
|
175
|
+
// An entity is one character: `'` quotes the family.
|
|
176
|
+
if (css.startsWith('"', end))
|
|
177
|
+
break;
|
|
178
|
+
const semi = css.indexOf(';', end);
|
|
179
|
+
if (semi > end && semi - end <= 8) {
|
|
180
|
+
end = semi + 1;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
end++;
|
|
185
|
+
}
|
|
186
|
+
const rewritten = featureFontValue(css.slice(start, end));
|
|
187
|
+
if (rewritten !== undefined) {
|
|
188
|
+
out += `${css.slice(from, start)}${rewritten}`;
|
|
189
|
+
from = end;
|
|
190
|
+
}
|
|
191
|
+
// No declaration holds another: the next is looked for past this one.
|
|
192
|
+
at = Math.max(at, end - 5);
|
|
193
|
+
}
|
|
194
|
+
return out + css.slice(from);
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=figureStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figureStyle.js","sourceRoot":"","sources":["../../src/fonts/figureStyle.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,0EAA0E;AAC1E,yEAAyE;AACzE,wEAAwE;AACxE,uEAAuE;AACvE,yEAAyE;AACzE,yEAAyE;AACzE,qBAAqB;AACrB,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,0DAA0D;AAC1D,2DAA2D;AAC3D,0EAA0E;AAC1E,kDAAkD;AAClD,sEAAsE;AACtE,yEAAyE;AACzE,EAAE;AACF,mEAAmE;AACnE,YAAY;AAGZ,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,yEAAyE;AACzE,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,SAAS;IACT,UAAU;IACV,QAAQ;IACR,SAAS;IACT,cAAc;IACd,kBAAkB;IAClB,uBAAuB;IACvB,gBAAgB;IAChB,qBAAqB;CACtB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAGhE,MA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of a TrueType or OpenType file (`bytes`, not a collection nor a
|
|
3
|
+
* WOFF) whose `cmap` maps every character to the glyph the single
|
|
4
|
+
* substitutions of `features` (`['onum']`, `['lnum', 'tnum']`) give it,
|
|
5
|
+
* applied in lookup order; the other tables as they are. The file itself
|
|
6
|
+
* when the features substitute none of its characters, and null when it
|
|
7
|
+
* cannot be read.
|
|
8
|
+
*/
|
|
9
|
+
export declare function freezeFontFeatures(bytes: Uint8Array, features: readonly string[]): Uint8Array | null;
|
|
10
|
+
//# sourceMappingURL=freezeFeatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freezeFeatures.d.ts","sourceRoot":"","sources":["../../src/fonts/freezeFeatures.ts"],"names":[],"mappings":"AAiSA;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,GAAG,IAAI,CA2BpG"}
|