ntk 8.12.8 → 8.12.10
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/lib/renderingcontext_2d.js +14 -0
- package/lib/text/layout.js +5 -2
- package/lib/text/shape.js +6 -8
- package/package.json +1 -1
|
@@ -4637,6 +4637,8 @@ class RenderingContext2d {
|
|
|
4637
4637
|
1,
|
|
4638
4638
|
]);
|
|
4639
4639
|
picture.setFilter("bilinear");
|
|
4640
|
+
// the edge clamped, as drawImage's scaled path explains
|
|
4641
|
+
R.ChangePicture(picture.id, { repeat: 2 }); // Repeat.Pad
|
|
4640
4642
|
}
|
|
4641
4643
|
// with a transform in place the mask is already sampled from (sx, sy)
|
|
4642
4644
|
const mx = scaled ? 0 : sx;
|
|
@@ -4756,6 +4758,7 @@ class RenderingContext2d {
|
|
|
4756
4758
|
// restore defaults so the cached surface stays reusable as-is
|
|
4757
4759
|
R.SetPictureTransform(picture.id, [1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
4758
4760
|
picture.setFilter("nearest");
|
|
4761
|
+
R.ChangePicture(picture.id, { repeat: 0 }); // Repeat.None
|
|
4759
4762
|
}
|
|
4760
4763
|
this._markDirty();
|
|
4761
4764
|
}
|
|
@@ -4814,6 +4817,16 @@ class RenderingContext2d {
|
|
|
4814
4817
|
1,
|
|
4815
4818
|
]);
|
|
4816
4819
|
picture.setFilter("bilinear");
|
|
4820
|
+
// Bilinear sampling at the rim reads half a source pixel past the
|
|
4821
|
+
// image, and a picture's default repeat reads transparent there: an
|
|
4822
|
+
// upscaled image faded into whatever it was drawn over across its
|
|
4823
|
+
// outer pixels — three of them for a 15-pixel swatch drawn at 96.
|
|
4824
|
+
// The canvas spec's drawImage clamps to the image's edge, and so do
|
|
4825
|
+
// browsers; RepeatPad is that. Only on this axis-aligned path, whose
|
|
4826
|
+
// composite box is the destination rectangle exactly: under a
|
|
4827
|
+
// rotation the box is the bounding box, and pad would paint its
|
|
4828
|
+
// corners.
|
|
4829
|
+
this.Render.ChangePicture(picture.id, { repeat: 2 }); // Repeat.Pad
|
|
4817
4830
|
this.Render.Composite(
|
|
4818
4831
|
op,
|
|
4819
4832
|
picture.id,
|
|
@@ -4834,6 +4847,7 @@ class RenderingContext2d {
|
|
|
4834
4847
|
[1, 0, 0, 0, 1, 0, 0, 0, 1],
|
|
4835
4848
|
);
|
|
4836
4849
|
picture.setFilter("nearest");
|
|
4850
|
+
this.Render.ChangePicture(picture.id, { repeat: 0 }); // Repeat.None
|
|
4837
4851
|
} else {
|
|
4838
4852
|
this.Render.Composite(
|
|
4839
4853
|
op,
|
package/lib/text/layout.js
CHANGED
|
@@ -5,9 +5,12 @@ import { drawGlyphRuns } from './glyphs.js';
|
|
|
5
5
|
import { embeddingLevels, normalizedLevels, reorderRuns } from './shape.js';
|
|
6
6
|
import { worthKeeping } from './paragraphs.js';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// The white space a line may end on and hang past its edge: spaces and tabs,
|
|
9
|
+
// as CSS hangs them. A no-break space is not one — CSS measures it, and
|
|
10
|
+
// ` ` at the end of a cell or a span is there to take room.
|
|
11
|
+
const WS = new Set([0x20, 0x09]);
|
|
9
12
|
const HARD_BREAKS = /[\n\r\u2028\u2029]+$/;
|
|
10
|
-
const TRAILING_WS = /[ \t
|
|
13
|
+
const TRAILING_WS = /[ \t]+$/;
|
|
11
14
|
|
|
12
15
|
function isWsGlyph(g) {
|
|
13
16
|
return g.codePoints.length > 0 && g.codePoints.every((cp) => WS.has(cp));
|
package/lib/text/shape.js
CHANGED
|
@@ -104,18 +104,16 @@ function spacedFeatures(features) {
|
|
|
104
104
|
/**
|
|
105
105
|
* Space a shaped run's glyphs apart by `spacing` px: added to the advance of
|
|
106
106
|
* every glyph that has one, so a combining mark keeps sitting on its base.
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
107
|
+
* The gap is on each glyph's right in an rtl run as in an ltr one — where
|
|
108
|
+
* CoreText's kerning attribute and browsers put it — so a line that changes
|
|
109
|
+
* direction keeps one gap between every two neighbours: on the reading side
|
|
110
|
+
* of an rtl run's glyphs it came out twice where the direction changed one
|
|
111
|
+
* way and not at all where it changed back.
|
|
110
112
|
*/
|
|
111
113
|
function spaceGlyphs(shaped, spacing) {
|
|
112
|
-
const rtl = shaped.direction === 'rtl';
|
|
113
114
|
let width = 0;
|
|
114
115
|
for (const g of shaped.glyphs) {
|
|
115
|
-
if (g.ax > 0)
|
|
116
|
-
g.ax += spacing;
|
|
117
|
-
if (rtl) g.dx += spacing;
|
|
118
|
-
}
|
|
116
|
+
if (g.ax > 0) g.ax += spacing;
|
|
119
117
|
width += g.ax;
|
|
120
118
|
}
|
|
121
119
|
shaped.width = width;
|