postext 1.45.0 → 1.46.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.
- package/dist/__tests__/composed/layout.test.js +18 -0
- package/dist/__tests__/composed/layout.test.js.map +1 -1
- package/dist/__tests__/design/dottedText.test.d.ts +2 -0
- package/dist/__tests__/design/dottedText.test.d.ts.map +1 -0
- package/dist/__tests__/design/dottedText.test.js +202 -0
- package/dist/__tests__/design/dottedText.test.js.map +1 -0
- package/dist/__tests__/exports.test.js +2 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/pipeline/flowColumns.test.js +8 -0
- package/dist/__tests__/pipeline/flowColumns.test.js.map +1 -1
- package/dist/__tests__/reshapedTracking.test.js +1 -1
- package/dist/__tests__/reshapedTracking.test.js.map +1 -1
- package/dist/__tests__/trackedLetters.test.js +1 -1
- package/dist/__tests__/trackedLetters.test.js.map +1 -1
- package/dist/__tests__/trackedLigatures.test.js +1 -1
- package/dist/__tests__/trackedLigatures.test.js.map +1 -1
- package/dist/canvas-backend/chip.d.ts.map +1 -1
- package/dist/canvas-backend/chip.js +7 -1
- package/dist/canvas-backend/chip.js.map +1 -1
- package/dist/canvas-backend/headerFooter.d.ts.map +1 -1
- package/dist/canvas-backend/headerFooter.js +10 -4
- package/dist/canvas-backend/headerFooter.js.map +1 -1
- package/dist/canvas-backend/textDots.d.ts +11 -0
- package/dist/canvas-backend/textDots.d.ts.map +1 -0
- package/dist/canvas-backend/textDots.js +36 -0
- package/dist/canvas-backend/textDots.js.map +1 -0
- package/dist/defaults/chipStyles.d.ts.map +1 -1
- package/dist/defaults/chipStyles.js +3 -0
- package/dist/defaults/chipStyles.js.map +1 -1
- package/dist/defaults/headerFooter.d.ts.map +1 -1
- package/dist/defaults/headerFooter.js +2 -0
- package/dist/defaults/headerFooter.js.map +1 -1
- package/dist/design/layout.d.ts +5 -0
- package/dist/design/layout.d.ts.map +1 -1
- package/dist/design/layout.js +54 -0
- package/dist/design/layout.js.map +1 -1
- package/dist/html-backend.d.ts.map +1 -1
- package/dist/html-backend.js +56 -3
- package/dist/html-backend.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/measure/rich.d.ts.map +1 -1
- package/dist/measure/rich.js +1 -0
- package/dist/measure/rich.js.map +1 -1
- package/dist/parse/types.d.ts +5 -0
- package/dist/parse/types.d.ts.map +1 -1
- package/dist/pipeline/calloutLayout.d.ts.map +1 -1
- package/dist/pipeline/calloutLayout.js +6 -2
- package/dist/pipeline/calloutLayout.js.map +1 -1
- package/dist/pipeline/chips.d.ts.map +1 -1
- package/dist/pipeline/chips.js +2 -0
- package/dist/pipeline/chips.js.map +1 -1
- package/dist/pipeline/columnsGroup.d.ts +5 -1
- package/dist/pipeline/columnsGroup.d.ts.map +1 -1
- package/dist/pipeline/columnsGroup.js +4 -3
- package/dist/pipeline/columnsGroup.js.map +1 -1
- package/dist/pipeline/headerFooter.d.ts.map +1 -1
- package/dist/pipeline/headerFooter.js +1 -0
- package/dist/pipeline/headerFooter.js.map +1 -1
- package/dist/textDots.d.ts +67 -0
- package/dist/textDots.d.ts.map +1 -0
- package/dist/textDots.js +393 -0
- package/dist/textDots.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vdt.d.ts +12 -0
- package/dist/vdt.d.ts.map +1 -1
- package/dist/vdt.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-backend.d.ts","sourceRoot":"","sources":["../src/html-backend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAuBX,aAAa,EACd,MAAM,OAAO,CAAC;AAIf,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"html-backend.d.ts","sourceRoot":"","sources":["../src/html-backend.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;QAClB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QACvC;2DACmD;QACnD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;KAClD,CAAC;CACH;AAgWD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAajE;AA8+FD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5C,8EAA8E;IAC9E,cAAc,EAAE,MAAM,CAAC;IACvB;4EACwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,KAAK,EAAE,mBAAmB,EAAE,CAAC;CAC9B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QAS4B,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,iBAAsB,GAC9B,eAAe,CAuGjB;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAEtF"}
|
package/dist/html-backend.js
CHANGED
|
@@ -22,6 +22,7 @@ import { fontFamilyOf } from './measure/vertical';
|
|
|
22
22
|
import { lineHighlightsHtml, lineMarksHtml, rubyHtml, verticalLineMarksHtml, warichuHtml, sideMarkerHtml, RT_OPEN, RUBY_OPEN, rubyGroupOf, kuntenHtml, verticalKuntenTateHtml } from './htmlAnnotations';
|
|
23
23
|
import { playMarkTriangle, qrModuleRuns } from './pipeline/videoOverlay';
|
|
24
24
|
import { isHlsMimeType, mediaFragment, videoElementAttributes, videoEmbedAllow } from './video/url';
|
|
25
|
+
import { textDots } from './textDots';
|
|
25
26
|
import { renderComicHtml } from './htmlComic';
|
|
26
27
|
import { comicBlockOnSheet, pageComics } from './comics/transform';
|
|
27
28
|
import { altWithLabels } from './composed/labelText';
|
|
@@ -1596,6 +1597,49 @@ function renderSwatch(x, baselineOffset, side, fill, ink) {
|
|
|
1596
1597
|
* gap margin), then the text runs as ordinary text spans on the line's
|
|
1597
1598
|
* baseline (`baselineOffset` from the line top), so the words stay real,
|
|
1598
1599
|
* selectable text. `lineFont` / `lineColor` are the line box's own. */
|
|
1600
|
+
/**
|
|
1601
|
+
* Letters to trace (#1017): the dots of `text` (its run painted at `left`
|
|
1602
|
+
* on the baseline `baseline`, `width` wide) in an SVG as wide as the run,
|
|
1603
|
+
* so that a mirrored flow turns them back about the run's box as it turns
|
|
1604
|
+
* every SVG; each dot a round cap of a stroke a hundredth of a pixel long.
|
|
1605
|
+
* `null` where there is no canvas to read the letters from.
|
|
1606
|
+
*/
|
|
1607
|
+
function textDotsSvg(text, fontString, dots, color, left, baseline, letterSpacingPx, rtl) {
|
|
1608
|
+
const found = textDots({ text, font: fontString, spacingPx: dots.spacingPx, letterSpacingPx: joiningScriptIn(text) ? 0 : letterSpacingPx, rtl });
|
|
1609
|
+
if (!found)
|
|
1610
|
+
return null;
|
|
1611
|
+
if (found.points.length === 0)
|
|
1612
|
+
return '';
|
|
1613
|
+
let d = '';
|
|
1614
|
+
for (let i = 0; i < found.points.length; i += 2)
|
|
1615
|
+
d += `M${found.points[i].toFixed(2)} ${found.points[i + 1].toFixed(2)}h.01`;
|
|
1616
|
+
const w = Math.max(0.01, found.width);
|
|
1617
|
+
return (`<svg aria-hidden="true" focusable="false" width="${w.toFixed(3)}" height="1" viewBox="0 0 ${w.toFixed(3)} 1" ` +
|
|
1618
|
+
`style="position:absolute;left:${left.toFixed(3)}px;top:${baseline.toFixed(3)}px;overflow:visible;">` +
|
|
1619
|
+
`<path d="${d}" fill="none" stroke="${color}" stroke-width="${dots.sizePx.toFixed(3)}" stroke-linecap="round"/></svg>`);
|
|
1620
|
+
}
|
|
1621
|
+
/** The dots of every run of a design text block, in its box's frame
|
|
1622
|
+
* (see {@link textDotsSvg}); `null` when they cannot be drawn. */
|
|
1623
|
+
function designTextDotsHtml(block, dots) {
|
|
1624
|
+
const out = [];
|
|
1625
|
+
for (const line of block.lines) {
|
|
1626
|
+
const baseline = line.baselineY - block.bbox.y;
|
|
1627
|
+
const runs = line.runs ?? [{ text: line.text, fontString: block.fontString, width: line.width }];
|
|
1628
|
+
const order = line.order && line.order.length === runs.length ? line.order : runs.map((_, i) => i);
|
|
1629
|
+
let x = line.xOffset;
|
|
1630
|
+
for (const i of order) {
|
|
1631
|
+
const run = runs[i];
|
|
1632
|
+
if (!run.leader) {
|
|
1633
|
+
const svg = textDotsSvg(run.text, run.fontString, dots, block.color, x + (run.inkOffset ?? 0), baseline + (run.baselineShift ?? 0), block.letterSpacingPx ?? 0, run.rtl === true);
|
|
1634
|
+
if (svg === null)
|
|
1635
|
+
return null;
|
|
1636
|
+
out.push(svg);
|
|
1637
|
+
}
|
|
1638
|
+
x += run.width;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
return out.join('');
|
|
1642
|
+
}
|
|
1599
1643
|
function renderChip(chip, x, baselineOffset, lineFont, lineColor, inkFor,
|
|
1600
1644
|
/** The direction the document's root declares (see {@link dirAttr}). */
|
|
1601
1645
|
rootDir = 'ltr') {
|
|
@@ -1618,7 +1662,11 @@ rootDir = 'ltr') {
|
|
|
1618
1662
|
const font = quoteFontString(run.fontString);
|
|
1619
1663
|
const color = chip.color ?? inkFor(run);
|
|
1620
1664
|
const fontDecl = font !== lineFont ? `font:${font};` : '';
|
|
1621
|
-
|
|
1665
|
+
// Letters to trace (#1017): the dots, the text transparent under them.
|
|
1666
|
+
const dots = chip.dotted ? textDotsSvg(run.text, run.fontString, chip.dotted, color, tx, baselineOffset + (run.baselineShift ?? 0), 0, run.rtl === true) : null;
|
|
1667
|
+
if (dots)
|
|
1668
|
+
parts.push(dots);
|
|
1669
|
+
const colorDecl = dots !== null ? 'color:transparent;' : color !== lineColor ? `color:${color};` : '';
|
|
1622
1670
|
const top = run.baselineShift ? `${run.baselineShift.toFixed(3)}px` : '0';
|
|
1623
1671
|
// A chip's runs were measured one by one, as a whole each.
|
|
1624
1672
|
// A run whose direction differs from what it inherits says so, so its
|
|
@@ -2759,9 +2807,14 @@ function renderDesignTextBlock(block, options) {
|
|
|
2759
2807
|
}
|
|
2760
2808
|
const clipDecl = block.clip ? 'overflow:hidden;' : '';
|
|
2761
2809
|
const trackingDecl = block.letterSpacingPx ? `letter-spacing:${block.letterSpacingPx}px;${ligaturesDecl()}` : '';
|
|
2810
|
+
// Letters to trace (#1017): the dots over the text, which stays,
|
|
2811
|
+
// transparent, to be selected and read.
|
|
2812
|
+
const dots = block.dotted ? designTextDotsHtml(block, block.dotted) : null;
|
|
2813
|
+
if (dots !== null)
|
|
2814
|
+
lineParts.push(dots);
|
|
2762
2815
|
// An outline over the glyphs (centred on their edges, as on canvas and in
|
|
2763
2816
|
// the PDF); hollow letters leave the fill transparent.
|
|
2764
|
-
const strokeDecl = block.stroke && block.stroke.widthPx > 0
|
|
2817
|
+
const strokeDecl = dots !== null ? '' : block.stroke && block.stroke.widthPx > 0
|
|
2765
2818
|
? `-webkit-text-stroke:${block.stroke.widthPx}px ${block.stroke.color};` +
|
|
2766
2819
|
(block.stroke.hollow ? '-webkit-text-fill-color:transparent;' : '')
|
|
2767
2820
|
: '';
|
|
@@ -2772,7 +2825,7 @@ function renderDesignTextBlock(block, options) {
|
|
|
2772
2825
|
`position:absolute;` +
|
|
2773
2826
|
`left:${block.bbox.x}px;top:${block.bbox.y}px;` +
|
|
2774
2827
|
`width:${block.bbox.width}px;height:${block.bbox.height}px;` +
|
|
2775
|
-
`font:${font};color:${block.color};` +
|
|
2828
|
+
`font:${font};color:${dots !== null ? 'transparent' : block.color};` +
|
|
2776
2829
|
clipDecl + trackingDecl + strokeDecl +
|
|
2777
2830
|
`">${lineParts.join('')}</div>`);
|
|
2778
2831
|
return parts.join('');
|