react-x11 2.55.1 → 2.55.2
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 +1 -1
- package/src/cocoa/fonts.js +30 -5
package/package.json
CHANGED
package/src/cocoa/fonts.js
CHANGED
|
@@ -757,6 +757,8 @@ export class CocoaFontManager {
|
|
|
757
757
|
this._fonts = new Map(); // family|weight|italic|size -> handle
|
|
758
758
|
// handle -> features key -> the handle with those features set
|
|
759
759
|
this._featured = new WeakMap();
|
|
760
|
+
// handle -> variations key -> the handle at those axis values
|
|
761
|
+
this._varied = new WeakMap();
|
|
760
762
|
this._faces = new Map(); // family|weight|italic -> face wrapper
|
|
761
763
|
this._registered = new Map(); // lowercase family -> [{cg, weight, italic}]
|
|
762
764
|
this._byKey = new Map(); // ntk Font key -> { cg } | { ps }
|
|
@@ -997,15 +999,38 @@ export class CocoaFontManager {
|
|
|
997
999
|
return false;
|
|
998
1000
|
}
|
|
999
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* `handle` at the values `variations` gives a variable face's axes —
|
|
1004
|
+
* `fontApplyVariations`, tag → value. Kept per handle, as `_withFeatures`
|
|
1005
|
+
* keeps a featured one: a paragraph set in a variable web font asked the
|
|
1006
|
+
* bridge for a fresh CTFont for every span of every layout, and a font
|
|
1007
|
+
* CoreText has never seen is one it shapes with none of its caches warm.
|
|
1008
|
+
* The featured font made from it was fresh each time for the same reason,
|
|
1009
|
+
* since `_withFeatures` keeps its fonts by the handle it is given. A
|
|
1010
|
+
* document in a variable face spent seconds in CoreText setting its text:
|
|
1011
|
+
* bun.com's blog, in Archivo and Martian Mono, laid out in 2.3 s, and in
|
|
1012
|
+
* 0.2 s with the handles kept. A kept handle lives as long as the one it was
|
|
1013
|
+
* made from, which `_fonts`, `_sized` and a face's sizes hold: the map is
|
|
1014
|
+
* weak on it, and the bridge's external releases the CTFont when it goes.
|
|
1015
|
+
*/
|
|
1000
1016
|
_withVariations(handle, variations) {
|
|
1001
1017
|
if (
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1018
|
+
!handle ||
|
|
1019
|
+
!variations ||
|
|
1020
|
+
typeof variations !== 'object' ||
|
|
1021
|
+
Object.keys(variations).length === 0
|
|
1005
1022
|
) {
|
|
1006
|
-
return
|
|
1023
|
+
return handle;
|
|
1007
1024
|
}
|
|
1008
|
-
|
|
1025
|
+
let perHandle = this._varied.get(handle);
|
|
1026
|
+
if (!perHandle) this._varied.set(handle, (perHandle = new Map()));
|
|
1027
|
+
const key = JSON.stringify(variations);
|
|
1028
|
+
let varied = perHandle.get(key);
|
|
1029
|
+
if (!varied) {
|
|
1030
|
+
varied = this._native.fontApplyVariations(handle, variations);
|
|
1031
|
+
perHandle.set(key, varied);
|
|
1032
|
+
}
|
|
1033
|
+
return varied;
|
|
1009
1034
|
}
|
|
1010
1035
|
|
|
1011
1036
|
/**
|