react-x11 2.20.0 → 2.21.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-x11",
3
- "version": "2.20.0",
3
+ "version": "2.21.1",
4
4
  "description": "react renderer with X11 as a target",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -108,9 +108,9 @@
108
108
  "yoga-layout": "^3.2.1"
109
109
  },
110
110
  "optionalDependencies": {
111
- "@windowkit/appkit": "^0.12.0",
111
+ "@windowkit/appkit": "^0.13.0",
112
112
  "@windowkit/wayland": "^3.1.1",
113
- "@windowkit/win32": "^0.0.3",
113
+ "@windowkit/win32": "^0.0.4",
114
114
  "dbus-native": "^0.15.1",
115
115
  "x11-dri": "^0.9.0"
116
116
  },
@@ -5,7 +5,7 @@
5
5
  // fonts.layout(spans, base, { maxWidth, align, lineHeight, maxLines,
6
6
  // overflow, direction })
7
7
  // -> { width, height, lines, draw(ctx, x, y),
8
- // indexAt(x, y), caretPosition(cp) }
8
+ // indexAt(x, y), caretPosition(cp), coverage({ pad }) }
9
9
  // fonts.match(family, { weight, style }) -> face
10
10
  // fonts.fallbackFor(codepoint, family, { weight, style }) -> face | null
11
11
  //
@@ -144,6 +144,25 @@ class CocoaTextLayout {
144
144
  caretPosition(cp) {
145
145
  return this._native.layoutCaret(this._handle, this._cuOf(cp));
146
146
  }
147
+
148
+ /**
149
+ * How much of each device pixel the glyphs cover, one byte a pixel,
150
+ * without drawing them anywhere (#673) — for text that is drawn where a 2D
151
+ * context is not, a GL surface's labels. The raster is the layout's box in
152
+ * whole pixels with `pad` round it, the layout's origin at (pad, pad).
153
+ *
154
+ * The bridge's `layoutCoverage`: each glyph's CoreText outline where the
155
+ * run put it, unrounded, filled once by the signed-area accumulation ntk
156
+ * rasterizes with, so the X11 engine and this one give the same bytes for
157
+ * the same outlines — and none of the font smoothing the screen gets. Not
158
+ * CoreText's glyph rasterizer, which shrinks a small glyph's counters even
159
+ * with smoothing off. Null on a bridge that predates it (`@windowkit/appkit`
160
+ * before 0.13.0), so a caller keeps its readback.
161
+ */
162
+ coverage({ pad = 0 } = {}) {
163
+ if (typeof this._native.layoutCoverage !== 'function') return null;
164
+ return this._native.layoutCoverage(this._handle, pad) ?? null;
165
+ }
147
166
  }
148
167
 
149
168
  /**
@@ -154,6 +154,25 @@ class Win32TextLayout {
154
154
  return this._native.layoutCaret(this._handle, this._cuOf(cp));
155
155
  }
156
156
 
157
+ /**
158
+ * How much of each device pixel the glyphs cover, one byte a pixel,
159
+ * without drawing them anywhere (#673) — for text that is drawn where a 2D
160
+ * context is not, a GL surface's labels. The raster is the layout's box in
161
+ * whole pixels with `pad` round it, the layout's origin at (pad, pad).
162
+ *
163
+ * DirectWrite's own glyph-run analysis rather than a surface read back:
164
+ * grayscale, grid fit off, and none of the gamma or enhanced contrast
165
+ * Direct2D gives text it blends — the outlines' coverage, which is what a
166
+ * distance field is made from. Null on a bridge that predates it
167
+ * (`@windowkit/win32` before `layoutCoverage`), so a caller keeps its
168
+ * readback.
169
+ */
170
+ coverage({ pad = 0 } = {}) {
171
+ if (this._handle == null) return null;
172
+ if (typeof this._native.layoutCoverage !== 'function') return null;
173
+ return this._native.layoutCoverage(this._handle, pad) ?? null;
174
+ }
175
+
157
176
  _cuOf(cp) {
158
177
  this._offsets ??= codeUnitOffsets(this._text);
159
178
  const at = Math.max(0, Math.min(this._offsets.length - 1, cp));