ntk 8.18.1 → 8.20.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.
@@ -916,6 +916,9 @@ export class TextLayout {
916
916
  draw(ctx, x = 0, y = 0) {
917
917
  const app = ctx.window.app;
918
918
  const Render = app.display.Render;
919
+ // The context's composite op, as `fillText` takes it. A context that is
920
+ // not ntk's has none to give, and its text goes source-over.
921
+ const op = ctx._op?.() ?? Render.PictOp.Over;
919
922
  // One batch for the whole layout, not one per line: every positioned
920
923
  // run carries its own absolute baseline, so a uniformly coloured
921
924
  // paragraph becomes a single glyph composite instead of one per line.
@@ -929,9 +932,9 @@ export class TextLayout {
929
932
  // (drawGlyphRuns composites straight onto the picture and can see
930
933
  // neither)
931
934
  if (typeof ctx.drawGlyphs === 'function') {
932
- ctx.drawGlyphs(Render.PictOp.Over, src, batch);
935
+ ctx.drawGlyphs(op, src, batch);
933
936
  } else {
934
- drawGlyphRuns(app, Render.PictOp.Over, src.id, ctx.picture.id, batch);
937
+ drawGlyphRuns(app, op, src.id, ctx.picture.id, batch);
935
938
  }
936
939
  batch = [];
937
940
  };
@@ -942,7 +945,7 @@ export class TextLayout {
942
945
  // height and its font's extent again on either side for ink that
943
946
  // overhangs the box, is outside the rows the clip lets through: nothing
944
947
  // of it could have landed on a pixel.
945
- const rows = visibleRows(ctx, y);
948
+ const rows = visibleRows(ctx, y, op);
946
949
  for (const line of this.lines) {
947
950
  if (rows) {
948
951
  const reach = line.height + line.ascent + line.descent;
@@ -1493,12 +1496,15 @@ function sliceLevels(key, start, end) {
1493
1496
  * The rows of a layout drawn at `y` that the context can show — its clip's
1494
1497
  * box, or the whole surface with no clip — in the layout's own coordinates.
1495
1498
  * Null where that cannot be said, and the whole layout is drawn: a context
1496
- * that is not ntk's, a transform that is more than a translation, or a
1497
- * shadow, which lands where the text is not.
1499
+ * that is not ntk's, a transform that is more than a translation, a
1500
+ * shadow, which lands where the text is not, or an `op` like `copy` that
1501
+ * clears the box round all the glyphs drawn — a line the clip hides still
1502
+ * widens that box along the rows it does not hide.
1498
1503
  */
1499
- function visibleRows(ctx, y) {
1504
+ function visibleRows(ctx, y, op) {
1500
1505
  if (typeof ctx.drawGlyphs !== 'function') return null;
1501
1506
  if (typeof ctx._clipExtents !== 'function') return null;
1507
+ if (typeof ctx._maskBounded === 'function' && !ctx._maskBounded(op)) return null;
1502
1508
  const m = ctx._m;
1503
1509
  if (!m || m[0] !== 1 || m[1] !== 0 || m[2] !== 0 || m[3] !== 1) return null;
1504
1510
  if (typeof ctx._shadowed !== 'function' || ctx._shadowed()) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ntk",
3
- "version": "8.18.1",
3
+ "version": "8.20.0",
4
4
  "description": "Desktop UI toolkit for X11 with canvas-like 2d and OpenGL rendering",
5
5
  "author": "Andrey Sidorov <sidorares@yandex.ru>",
6
6
  "license": "MIT",