ntk 8.30.0 → 8.30.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/lib/text/layout.js +10 -2
- package/package.json +1 -1
package/lib/text/layout.js
CHANGED
|
@@ -1636,9 +1636,16 @@ function stripTrailingWhitespace(entries, text) {
|
|
|
1636
1636
|
let wsWidth = 0;
|
|
1637
1637
|
// the code unit a glyph at the logical end stands for
|
|
1638
1638
|
let at = entries[i].end - 1;
|
|
1639
|
-
|
|
1639
|
+
// the soft hyphen a line wraps at is no content of it, which its
|
|
1640
|
+
// hyphen stands for at the end, but it is no white space either: what
|
|
1641
|
+
// is before it stays in the line, as Chromium and WebKit keep it
|
|
1642
|
+
let last = false;
|
|
1643
|
+
while (count < run.glyphs.length && !last) {
|
|
1640
1644
|
const g = run.glyphs[fromFront ? count : run.glyphs.length - 1 - count];
|
|
1641
|
-
if (!isWsGlyph(g)
|
|
1645
|
+
if (!isWsGlyph(g)) break;
|
|
1646
|
+
const cu = text.charCodeAt(at);
|
|
1647
|
+
if (cu === SOFT_HYPHEN && stripped.length === 0 && count === 0) last = true;
|
|
1648
|
+
else if (!hangs(cu)) break;
|
|
1642
1649
|
at -= cuLength(g.codePoints);
|
|
1643
1650
|
count++;
|
|
1644
1651
|
wsWidth += g.ax;
|
|
@@ -1658,6 +1665,7 @@ function stripTrailingWhitespace(entries, text) {
|
|
|
1658
1665
|
strippedStart = entries[i].end - cuStripped;
|
|
1659
1666
|
if (count === run.glyphs.length) {
|
|
1660
1667
|
entries.splice(i, 1);
|
|
1668
|
+
if (last) return result();
|
|
1661
1669
|
continue;
|
|
1662
1670
|
}
|
|
1663
1671
|
entries[i] = {
|