postext 1.8.5 → 1.9.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/__bench__/cjkChapter.bench.test.d.ts +2 -0
- package/dist/__bench__/cjkChapter.bench.test.d.ts.map +1 -0
- package/dist/__bench__/cjkChapter.bench.test.js +71 -0
- package/dist/__bench__/cjkChapter.bench.test.js.map +1 -0
- package/dist/__tests__/bundle.test.js +16 -0
- package/dist/__tests__/bundle.test.js.map +1 -1
- package/dist/__tests__/canvasDirection.test.d.ts +2 -0
- package/dist/__tests__/canvasDirection.test.d.ts.map +1 -0
- package/dist/__tests__/canvasDirection.test.js +45 -0
- package/dist/__tests__/canvasDirection.test.js.map +1 -0
- package/dist/__tests__/chineseLocale.test.d.ts +2 -0
- package/dist/__tests__/chineseLocale.test.d.ts.map +1 -0
- package/dist/__tests__/chineseLocale.test.js +253 -0
- package/dist/__tests__/chineseLocale.test.js.map +1 -0
- package/dist/__tests__/chineseNumbering.test.d.ts +2 -0
- package/dist/__tests__/chineseNumbering.test.d.ts.map +1 -0
- package/dist/__tests__/chineseNumbering.test.js +376 -0
- package/dist/__tests__/chineseNumbering.test.js.map +1 -0
- package/dist/__tests__/cjk/annotations.test.d.ts +2 -0
- package/dist/__tests__/cjk/annotations.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/annotations.test.js +483 -0
- package/dist/__tests__/cjk/annotations.test.js.map +1 -0
- package/dist/__tests__/cjk/annotationsRender.test.d.ts +2 -0
- package/dist/__tests__/cjk/annotationsRender.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/annotationsRender.test.js +263 -0
- package/dist/__tests__/cjk/annotationsRender.test.js.map +1 -0
- package/dist/__tests__/cjk/composer.test.d.ts +2 -0
- package/dist/__tests__/cjk/composer.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/composer.test.js +237 -0
- package/dist/__tests__/cjk/composer.test.js.map +1 -0
- package/dist/__tests__/cjk/composerEdges.test.d.ts +2 -0
- package/dist/__tests__/cjk/composerEdges.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/composerEdges.test.js +352 -0
- package/dist/__tests__/cjk/composerEdges.test.js.map +1 -0
- package/dist/__tests__/cjk/dashRule.test.d.ts +2 -0
- package/dist/__tests__/cjk/dashRule.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/dashRule.test.js +261 -0
- package/dist/__tests__/cjk/dashRule.test.js.map +1 -0
- package/dist/__tests__/cjk/fuzz.test.d.ts +2 -0
- package/dist/__tests__/cjk/fuzz.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/fuzz.test.js +102 -0
- package/dist/__tests__/cjk/fuzz.test.js.map +1 -0
- package/dist/__tests__/cjk/grid.test.d.ts +2 -0
- package/dist/__tests__/cjk/grid.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/grid.test.js +261 -0
- package/dist/__tests__/cjk/grid.test.js.map +1 -0
- package/dist/__tests__/cjk/justifyRender.test.d.ts +2 -0
- package/dist/__tests__/cjk/justifyRender.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/justifyRender.test.js +139 -0
- package/dist/__tests__/cjk/justifyRender.test.js.map +1 -0
- package/dist/__tests__/cjk/latinFastPath.test.d.ts +2 -0
- package/dist/__tests__/cjk/latinFastPath.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/latinFastPath.test.js +208 -0
- package/dist/__tests__/cjk/latinFastPath.test.js.map +1 -0
- package/dist/__tests__/cjk/markCutsLatin.test.d.ts +2 -0
- package/dist/__tests__/cjk/markCutsLatin.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/markCutsLatin.test.js +69 -0
- package/dist/__tests__/cjk/markCutsLatin.test.js.map +1 -0
- package/dist/__tests__/cjk/markRuns.test.d.ts +2 -0
- package/dist/__tests__/cjk/markRuns.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/markRuns.test.js +347 -0
- package/dist/__tests__/cjk/markRuns.test.js.map +1 -0
- package/dist/__tests__/cjk/punctuation.test.d.ts +2 -0
- package/dist/__tests__/cjk/punctuation.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/punctuation.test.js +440 -0
- package/dist/__tests__/cjk/punctuation.test.js.map +1 -0
- package/dist/__tests__/cjk/punctuationRender.test.d.ts +2 -0
- package/dist/__tests__/cjk/punctuationRender.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/punctuationRender.test.js +135 -0
- package/dist/__tests__/cjk/punctuationRender.test.js.map +1 -0
- package/dist/__tests__/cjk/rubyDescenders.test.d.ts +2 -0
- package/dist/__tests__/cjk/rubyDescenders.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/rubyDescenders.test.js +77 -0
- package/dist/__tests__/cjk/rubyDescenders.test.js.map +1 -0
- package/dist/__tests__/cjk/runt.test.d.ts +2 -0
- package/dist/__tests__/cjk/runt.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/runt.test.js +103 -0
- package/dist/__tests__/cjk/runt.test.js.map +1 -0
- package/dist/__tests__/cjk/sharedMarks.test.d.ts +2 -0
- package/dist/__tests__/cjk/sharedMarks.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/sharedMarks.test.js +347 -0
- package/dist/__tests__/cjk/sharedMarks.test.js.map +1 -0
- package/dist/__tests__/cjk/uprightDots.test.d.ts +2 -0
- package/dist/__tests__/cjk/uprightDots.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/uprightDots.test.js +47 -0
- package/dist/__tests__/cjk/uprightDots.test.js.map +1 -0
- package/dist/__tests__/cjk/wordJoiner.test.d.ts +2 -0
- package/dist/__tests__/cjk/wordJoiner.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/wordJoiner.test.js +47 -0
- package/dist/__tests__/cjk/wordJoiner.test.js.map +1 -0
- package/dist/__tests__/cjk/zhuyinTones.test.d.ts +2 -0
- package/dist/__tests__/cjk/zhuyinTones.test.d.ts.map +1 -0
- package/dist/__tests__/cjk/zhuyinTones.test.js +72 -0
- package/dist/__tests__/cjk/zhuyinTones.test.js.map +1 -0
- package/dist/__tests__/contentLocale.test.d.ts +2 -0
- package/dist/__tests__/contentLocale.test.d.ts.map +1 -0
- package/dist/__tests__/contentLocale.test.js +167 -0
- package/dist/__tests__/contentLocale.test.js.map +1 -0
- package/dist/__tests__/defaults/cjk.test.d.ts +2 -0
- package/dist/__tests__/defaults/cjk.test.d.ts.map +1 -0
- package/dist/__tests__/defaults/cjk.test.js +70 -0
- package/dist/__tests__/defaults/cjk.test.js.map +1 -0
- package/dist/__tests__/design/designTextRender.test.js +31 -0
- package/dist/__tests__/design/designTextRender.test.js.map +1 -1
- package/dist/__tests__/design/imageAltText.test.d.ts +2 -0
- package/dist/__tests__/design/imageAltText.test.d.ts.map +1 -0
- package/dist/__tests__/design/imageAltText.test.js +126 -0
- package/dist/__tests__/design/imageAltText.test.js.map +1 -0
- package/dist/__tests__/exports.test.js +61 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/headingLetterSpacing.test.js +1 -1
- package/dist/__tests__/headingLetterSpacing.test.js.map +1 -1
- package/dist/__tests__/indexChinese.test.d.ts +2 -0
- package/dist/__tests__/indexChinese.test.d.ts.map +1 -0
- package/dist/__tests__/indexChinese.test.js +190 -0
- package/dist/__tests__/indexChinese.test.js.map +1 -0
- package/dist/__tests__/parse/annotations.test.d.ts +2 -0
- package/dist/__tests__/parse/annotations.test.d.ts.map +1 -0
- package/dist/__tests__/parse/annotations.test.js +175 -0
- package/dist/__tests__/parse/annotations.test.js.map +1 -0
- package/dist/__tests__/parse/attrQuoting.test.js +10 -8
- package/dist/__tests__/parse/attrQuoting.test.js.map +1 -1
- package/dist/__tests__/parse/chineseText.test.d.ts +2 -0
- package/dist/__tests__/parse/chineseText.test.d.ts.map +1 -0
- package/dist/__tests__/parse/chineseText.test.js +352 -0
- package/dist/__tests__/parse/chineseText.test.js.map +1 -0
- package/dist/__tests__/parts.test.js +25 -0
- package/dist/__tests__/parts.test.js.map +1 -1
- package/dist/__tests__/pipeline/colonListRoom.test.js +20 -0
- package/dist/__tests__/pipeline/colonListRoom.test.js.map +1 -1
- package/dist/__tests__/presets/hongloumeng.test.d.ts +2 -0
- package/dist/__tests__/presets/hongloumeng.test.d.ts.map +1 -0
- package/dist/__tests__/presets/hongloumeng.test.js +484 -0
- package/dist/__tests__/presets/hongloumeng.test.js.map +1 -0
- package/dist/__tests__/vertical/canvasPaint.test.d.ts +2 -0
- package/dist/__tests__/vertical/canvasPaint.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/canvasPaint.test.js +229 -0
- package/dist/__tests__/vertical/canvasPaint.test.js.map +1 -0
- package/dist/__tests__/vertical/compositionPaint.test.d.ts +2 -0
- package/dist/__tests__/vertical/compositionPaint.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/compositionPaint.test.js +538 -0
- package/dist/__tests__/vertical/compositionPaint.test.js.map +1 -0
- package/dist/__tests__/vertical/geometry.test.d.ts +2 -0
- package/dist/__tests__/vertical/geometry.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/geometry.test.js +276 -0
- package/dist/__tests__/vertical/geometry.test.js.map +1 -0
- package/dist/__tests__/vertical/htmlSmoke.test.d.ts +2 -0
- package/dist/__tests__/vertical/htmlSmoke.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/htmlSmoke.test.js +25 -0
- package/dist/__tests__/vertical/htmlSmoke.test.js.map +1 -0
- package/dist/__tests__/vertical/htmlTurnedCells.test.d.ts +2 -0
- package/dist/__tests__/vertical/htmlTurnedCells.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/htmlTurnedCells.test.js +99 -0
- package/dist/__tests__/vertical/htmlTurnedCells.test.js.map +1 -0
- package/dist/__tests__/vertical/htmlVertical.test.d.ts +2 -0
- package/dist/__tests__/vertical/htmlVertical.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/htmlVertical.test.js +145 -0
- package/dist/__tests__/vertical/htmlVertical.test.js.map +1 -0
- package/dist/__tests__/vertical/lineAxis.test.d.ts +2 -0
- package/dist/__tests__/vertical/lineAxis.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/lineAxis.test.js +128 -0
- package/dist/__tests__/vertical/lineAxis.test.js.map +1 -0
- package/dist/__tests__/vertical/measurePaint.test.d.ts +2 -0
- package/dist/__tests__/vertical/measurePaint.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/measurePaint.test.js +259 -0
- package/dist/__tests__/vertical/measurePaint.test.js.map +1 -0
- package/dist/__tests__/vertical/orientation.test.d.ts +2 -0
- package/dist/__tests__/vertical/orientation.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/orientation.test.js +153 -0
- package/dist/__tests__/vertical/orientation.test.js.map +1 -0
- package/dist/__tests__/vertical/stub.d.ts +8 -0
- package/dist/__tests__/vertical/stub.d.ts.map +1 -0
- package/dist/__tests__/vertical/stub.js +37 -0
- package/dist/__tests__/vertical/stub.js.map +1 -0
- package/dist/__tests__/vertical/tateChuYoko.test.d.ts +2 -0
- package/dist/__tests__/vertical/tateChuYoko.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/tateChuYoko.test.js +270 -0
- package/dist/__tests__/vertical/tateChuYoko.test.js.map +1 -0
- package/dist/__tests__/vertical/uprightResources.test.d.ts +2 -0
- package/dist/__tests__/vertical/uprightResources.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/uprightResources.test.js +182 -0
- package/dist/__tests__/vertical/uprightResources.test.js.map +1 -0
- package/dist/__tests__/vertical/verticalDesignText.test.d.ts +2 -0
- package/dist/__tests__/vertical/verticalDesignText.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/verticalDesignText.test.js +190 -0
- package/dist/__tests__/vertical/verticalDesignText.test.js.map +1 -0
- package/dist/__tests__/vertical/verticalSpans.d.ts +25 -0
- package/dist/__tests__/vertical/verticalSpans.d.ts.map +1 -0
- package/dist/__tests__/vertical/verticalSpans.js +39 -0
- package/dist/__tests__/vertical/verticalSpans.js.map +1 -0
- package/dist/__tests__/vertical/verticalTwins.test.d.ts +2 -0
- package/dist/__tests__/vertical/verticalTwins.test.d.ts.map +1 -0
- package/dist/__tests__/vertical/verticalTwins.test.js +71 -0
- package/dist/__tests__/vertical/verticalTwins.test.js.map +1 -0
- package/dist/bundle/adapters.d.ts +14 -5
- package/dist/bundle/adapters.d.ts.map +1 -1
- package/dist/bundle/adapters.js +4 -3
- package/dist/bundle/adapters.js.map +1 -1
- package/dist/bundle/codec.d.ts.map +1 -1
- package/dist/bundle/codec.js +27 -4
- package/dist/bundle/codec.js.map +1 -1
- package/dist/bundle/index.d.ts +1 -1
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/manifest.d.ts +6 -4
- package/dist/bundle/manifest.d.ts.map +1 -1
- package/dist/bundle/manifest.js +31 -32
- package/dist/bundle/manifest.js.map +1 -1
- package/dist/bundle/types.d.ts +7 -2
- package/dist/bundle/types.d.ts.map +1 -1
- package/dist/canvas-backend/annotations.d.ts +31 -0
- package/dist/canvas-backend/annotations.d.ts.map +1 -0
- package/dist/canvas-backend/annotations.js +120 -0
- package/dist/canvas-backend/annotations.js.map +1 -0
- package/dist/canvas-backend/blockRender.d.ts.map +1 -1
- package/dist/canvas-backend/blockRender.js +195 -15
- package/dist/canvas-backend/blockRender.js.map +1 -1
- package/dist/canvas-backend/decorations.d.ts +5 -0
- package/dist/canvas-backend/decorations.d.ts.map +1 -1
- package/dist/canvas-backend/decorations.js +27 -0
- package/dist/canvas-backend/decorations.js.map +1 -1
- package/dist/canvas-backend/headerFooter.d.ts.map +1 -1
- package/dist/canvas-backend/headerFooter.js +32 -16
- package/dist/canvas-backend/headerFooter.js.map +1 -1
- package/dist/canvas-backend/index.d.ts +2 -0
- package/dist/canvas-backend/index.d.ts.map +1 -1
- package/dist/canvas-backend/index.js +62 -2
- package/dist/canvas-backend/index.js.map +1 -1
- package/dist/canvas-backend/renderResourceBlock.d.ts.map +1 -1
- package/dist/canvas-backend/renderResourceBlock.js +42 -5
- package/dist/canvas-backend/renderResourceBlock.js.map +1 -1
- package/dist/canvas-backend/segmentText.d.ts +23 -0
- package/dist/canvas-backend/segmentText.d.ts.map +1 -0
- package/dist/canvas-backend/segmentText.js +41 -0
- package/dist/canvas-backend/segmentText.js.map +1 -0
- package/dist/canvas-backend/verticalText.d.ts +113 -0
- package/dist/canvas-backend/verticalText.d.ts.map +1 -0
- package/dist/canvas-backend/verticalText.js +437 -0
- package/dist/canvas-backend/verticalText.js.map +1 -0
- package/dist/chineseNumerals.d.ts +39 -0
- package/dist/chineseNumerals.d.ts.map +1 -0
- package/dist/chineseNumerals.js +192 -0
- package/dist/chineseNumerals.js.map +1 -0
- package/dist/cjkMarks.d.ts +61 -0
- package/dist/cjkMarks.d.ts.map +1 -0
- package/dist/cjkMarks.js +441 -0
- package/dist/cjkMarks.js.map +1 -0
- package/dist/columnClip.d.ts +13 -4
- package/dist/columnClip.d.ts.map +1 -1
- package/dist/columnClip.js +33 -5
- package/dist/columnClip.js.map +1 -1
- package/dist/configWarnings.d.ts.map +1 -1
- package/dist/configWarnings.js +18 -3
- package/dist/configWarnings.js.map +1 -1
- package/dist/defaults/bodyText.d.ts +4 -1
- package/dist/defaults/bodyText.d.ts.map +1 -1
- package/dist/defaults/bodyText.js +27 -5
- package/dist/defaults/bodyText.js.map +1 -1
- package/dist/defaults/calloutStyles.js +1 -1
- package/dist/defaults/calloutStyles.js.map +1 -1
- package/dist/defaults/captionStyle.d.ts.map +1 -1
- package/dist/defaults/captionStyle.js +14 -0
- package/dist/defaults/captionStyle.js.map +1 -1
- package/dist/defaults/cjk.d.ts +33 -0
- package/dist/defaults/cjk.d.ts.map +1 -0
- package/dist/defaults/cjk.js +234 -0
- package/dist/defaults/cjk.js.map +1 -0
- 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/defaults/headingStyles.d.ts.map +1 -1
- package/dist/defaults/headingStyles.js +4 -0
- package/dist/defaults/headingStyles.js.map +1 -1
- package/dist/defaults/headings.d.ts.map +1 -1
- package/dist/defaults/headings.js +13 -6
- package/dist/defaults/headings.js.map +1 -1
- package/dist/defaults/index.d.ts +1 -0
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +10 -1
- package/dist/defaults/index.js.map +1 -1
- package/dist/defaults/indexConfig.d.ts +2 -1
- package/dist/defaults/indexConfig.d.ts.map +1 -1
- package/dist/defaults/indexConfig.js +5 -0
- package/dist/defaults/indexConfig.js.map +1 -1
- package/dist/defaults/layout.d.ts.map +1 -1
- package/dist/defaults/layout.js +7 -0
- package/dist/defaults/layout.js.map +1 -1
- package/dist/defaults/orderedLists.d.ts +5 -2
- package/dist/defaults/orderedLists.d.ts.map +1 -1
- package/dist/defaults/orderedLists.js +20 -5
- package/dist/defaults/orderedLists.js.map +1 -1
- package/dist/defaults/page.d.ts +8 -2
- package/dist/defaults/page.d.ts.map +1 -1
- package/dist/defaults/page.js +24 -7
- package/dist/defaults/page.js.map +1 -1
- package/dist/defaults/resourceTypes.d.ts +3 -3
- package/dist/defaults/resourceTypes.d.ts.map +1 -1
- package/dist/defaults/resourceTypes.js +23 -9
- package/dist/defaults/resourceTypes.js.map +1 -1
- package/dist/defaults/tableStyle.d.ts.map +1 -1
- package/dist/defaults/tableStyle.js +8 -5
- package/dist/defaults/tableStyle.js.map +1 -1
- package/dist/design/layout.d.ts +33 -0
- package/dist/design/layout.d.ts.map +1 -1
- package/dist/design/layout.js +124 -18
- package/dist/design/layout.js.map +1 -1
- package/dist/design/placeholders.d.ts.map +1 -1
- package/dist/design/placeholders.js +5 -1
- package/dist/design/placeholders.js.map +1 -1
- package/dist/design/richText.d.ts +24 -4
- package/dist/design/richText.d.ts.map +1 -1
- package/dist/design/richText.js +77 -16
- package/dist/design/richText.js.map +1 -1
- package/dist/html-backend.d.ts.map +1 -1
- package/dist/html-backend.js +635 -25
- package/dist/html-backend.js.map +1 -1
- package/dist/htmlAnnotations.d.ts +29 -0
- package/dist/htmlAnnotations.d.ts.map +1 -0
- package/dist/htmlAnnotations.js +86 -0
- package/dist/htmlAnnotations.js.map +1 -0
- package/dist/hyphenate.js +2 -1
- package/dist/hyphenate.js.map +1 -1
- package/dist/index.d.ts +28 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/knuthPlass/pretextAdapter.d.ts +4 -1
- package/dist/knuthPlass/pretextAdapter.d.ts.map +1 -1
- package/dist/knuthPlass/pretextAdapter.js +9 -5
- package/dist/knuthPlass/pretextAdapter.js.map +1 -1
- package/dist/knuthPlass/richAdapter.d.ts +15 -2
- package/dist/knuthPlass/richAdapter.d.ts.map +1 -1
- package/dist/knuthPlass/richAdapter.js +16 -6
- package/dist/knuthPlass/richAdapter.js.map +1 -1
- package/dist/knuthPlass/tracking.d.ts +1 -1
- package/dist/knuthPlass/tracking.d.ts.map +1 -1
- package/dist/knuthPlass/tracking.js +4 -3
- package/dist/knuthPlass/tracking.js.map +1 -1
- package/dist/knuthPlass/types.d.ts +3 -0
- package/dist/knuthPlass/types.d.ts.map +1 -1
- package/dist/lineInk.d.ts +13 -0
- package/dist/lineInk.d.ts.map +1 -1
- package/dist/lineInk.js +28 -1
- package/dist/lineInk.js.map +1 -1
- package/dist/locale.d.ts +91 -3
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +245 -1
- package/dist/locale.js.map +1 -1
- package/dist/looseLines.d.ts +11 -1
- package/dist/looseLines.d.ts.map +1 -1
- package/dist/looseLines.js +26 -1
- package/dist/looseLines.js.map +1 -1
- package/dist/measure/cache.d.ts.map +1 -1
- package/dist/measure/cache.js +51 -3
- package/dist/measure/cache.js.map +1 -1
- package/dist/measure/canvas.d.ts +25 -0
- package/dist/measure/canvas.d.ts.map +1 -1
- package/dist/measure/canvas.js +90 -1
- package/dist/measure/canvas.js.map +1 -1
- package/dist/measure/cjk.d.ts +8 -13
- package/dist/measure/cjk.d.ts.map +1 -1
- package/dist/measure/cjk.js +29 -53
- package/dist/measure/cjk.js.map +1 -1
- package/dist/measure/cjkAnnotate.d.ts +96 -0
- package/dist/measure/cjkAnnotate.d.ts.map +1 -0
- package/dist/measure/cjkAnnotate.js +237 -0
- package/dist/measure/cjkAnnotate.js.map +1 -0
- package/dist/measure/cjkClasses.d.ts +133 -0
- package/dist/measure/cjkClasses.d.ts.map +1 -0
- package/dist/measure/cjkClasses.js +273 -0
- package/dist/measure/cjkClasses.js.map +1 -0
- package/dist/measure/cjkCompose.d.ts +86 -0
- package/dist/measure/cjkCompose.d.ts.map +1 -0
- package/dist/measure/cjkCompose.js +2022 -0
- package/dist/measure/cjkCompose.js.map +1 -0
- package/dist/measure/cjkPunctuation.d.ts +248 -0
- package/dist/measure/cjkPunctuation.d.ts.map +1 -0
- package/dist/measure/cjkPunctuation.js +492 -0
- package/dist/measure/cjkPunctuation.js.map +1 -0
- package/dist/measure/graphemes.d.ts +13 -0
- package/dist/measure/graphemes.d.ts.map +1 -0
- package/dist/measure/graphemes.js +38 -0
- package/dist/measure/graphemes.js.map +1 -0
- package/dist/measure/index.d.ts +3 -0
- package/dist/measure/index.d.ts.map +1 -1
- package/dist/measure/index.js +2 -0
- package/dist/measure/index.js.map +1 -1
- package/dist/measure/links.d.ts +6 -2
- package/dist/measure/links.d.ts.map +1 -1
- package/dist/measure/links.js +15 -5
- package/dist/measure/links.js.map +1 -1
- package/dist/measure/markCuts.d.ts +37 -0
- package/dist/measure/markCuts.d.ts.map +1 -0
- package/dist/measure/markCuts.js +77 -0
- package/dist/measure/markCuts.js.map +1 -0
- package/dist/measure/plain.d.ts.map +1 -1
- package/dist/measure/plain.js +33 -11
- package/dist/measure/plain.js.map +1 -1
- package/dist/measure/rich.d.ts +88 -1
- package/dist/measure/rich.d.ts.map +1 -1
- package/dist/measure/rich.js +233 -111
- package/dist/measure/rich.js.map +1 -1
- package/dist/measure/rubyLift.d.ts +11 -0
- package/dist/measure/rubyLift.d.ts.map +1 -0
- package/dist/measure/rubyLift.js +57 -0
- package/dist/measure/rubyLift.js.map +1 -0
- package/dist/measure/spaces.d.ts +12 -2
- package/dist/measure/spaces.d.ts.map +1 -1
- package/dist/measure/spaces.js +21 -7
- package/dist/measure/spaces.js.map +1 -1
- package/dist/measure/types.d.ts +20 -1
- package/dist/measure/types.d.ts.map +1 -1
- package/dist/measure/types.js.map +1 -1
- package/dist/measure/vertical.d.ts +104 -0
- package/dist/measure/vertical.d.ts.map +1 -0
- package/dist/measure/vertical.js +184 -0
- package/dist/measure/vertical.js.map +1 -0
- package/dist/numberWords.d.ts +3 -10
- package/dist/numberWords.d.ts.map +1 -1
- package/dist/numberWords.js +21 -9
- package/dist/numberWords.js.map +1 -1
- package/dist/numbering.d.ts +23 -5
- package/dist/numbering.d.ts.map +1 -1
- package/dist/numbering.js +99 -14
- package/dist/numbering.js.map +1 -1
- package/dist/parse/annotations.d.ts +101 -0
- package/dist/parse/annotations.d.ts.map +1 -0
- package/dist/parse/annotations.js +556 -0
- package/dist/parse/annotations.js.map +1 -0
- package/dist/parse/attrs.d.ts +48 -1
- package/dist/parse/attrs.d.ts.map +1 -1
- package/dist/parse/attrs.js +121 -8
- package/dist/parse/attrs.js.map +1 -1
- package/dist/parse/blockParser.d.ts.map +1 -1
- package/dist/parse/blockParser.js +50 -24
- package/dist/parse/blockParser.js.map +1 -1
- package/dist/parse/index.d.ts +3 -1
- package/dist/parse/index.d.ts.map +1 -1
- package/dist/parse/index.js +1 -0
- package/dist/parse/index.js.map +1 -1
- package/dist/parse/injectSpans.d.ts +3 -1
- package/dist/parse/injectSpans.d.ts.map +1 -1
- package/dist/parse/injectSpans.js +29 -8
- package/dist/parse/injectSpans.js.map +1 -1
- package/dist/parse/inlineFormatting.d.ts +38 -6
- package/dist/parse/inlineFormatting.d.ts.map +1 -1
- package/dist/parse/inlineFormatting.js +139 -26
- package/dist/parse/inlineFormatting.js.map +1 -1
- package/dist/parse/inlineSnippet.d.ts +2 -1
- package/dist/parse/inlineSnippet.d.ts.map +1 -1
- package/dist/parse/inlineSnippet.js +6 -2
- package/dist/parse/inlineSnippet.js.map +1 -1
- package/dist/parse/orientationMarks.d.ts +49 -0
- package/dist/parse/orientationMarks.d.ts.map +1 -0
- package/dist/parse/orientationMarks.js +138 -0
- package/dist/parse/orientationMarks.js.map +1 -0
- package/dist/parse/softBreaks.d.ts +56 -0
- package/dist/parse/softBreaks.d.ts.map +1 -0
- package/dist/parse/softBreaks.js +271 -0
- package/dist/parse/softBreaks.js.map +1 -0
- package/dist/parse/sourceMapping.d.ts.map +1 -1
- package/dist/parse/sourceMapping.js +41 -0
- package/dist/parse/sourceMapping.js.map +1 -1
- package/dist/parse/types.d.ts +84 -0
- package/dist/parse/types.d.ts.map +1 -1
- package/dist/pipeline/annotations.d.ts +56 -0
- package/dist/pipeline/annotations.d.ts.map +1 -0
- package/dist/pipeline/annotations.js +181 -0
- package/dist/pipeline/annotations.js.map +1 -0
- package/dist/pipeline/build.d.ts.map +1 -1
- package/dist/pipeline/build.js +158 -47
- package/dist/pipeline/build.js.map +1 -1
- package/dist/pipeline/buildBlockKind.d.ts +3 -0
- package/dist/pipeline/buildBlockKind.d.ts.map +1 -1
- package/dist/pipeline/buildBlockKind.js +5 -3
- package/dist/pipeline/buildBlockKind.js.map +1 -1
- package/dist/pipeline/buildHelpers.d.ts +36 -6
- package/dist/pipeline/buildHelpers.d.ts.map +1 -1
- package/dist/pipeline/buildHelpers.js +55 -8
- package/dist/pipeline/buildHelpers.js.map +1 -1
- package/dist/pipeline/buildMeasurement.d.ts +4 -0
- package/dist/pipeline/buildMeasurement.d.ts.map +1 -1
- package/dist/pipeline/buildMeasurement.js +3 -1
- package/dist/pipeline/buildMeasurement.js.map +1 -1
- package/dist/pipeline/calloutLayout.d.ts.map +1 -1
- package/dist/pipeline/calloutLayout.js +25 -11
- package/dist/pipeline/calloutLayout.js.map +1 -1
- package/dist/pipeline/cjkGrid.d.ts +133 -0
- package/dist/pipeline/cjkGrid.d.ts.map +1 -0
- package/dist/pipeline/cjkGrid.js +191 -0
- package/dist/pipeline/cjkGrid.js.map +1 -0
- package/dist/pipeline/config.d.ts +13 -9
- package/dist/pipeline/config.d.ts.map +1 -1
- package/dist/pipeline/config.js +43 -18
- package/dist/pipeline/config.js.map +1 -1
- package/dist/pipeline/contentWarnings.d.ts +10 -0
- package/dist/pipeline/contentWarnings.d.ts.map +1 -1
- package/dist/pipeline/contentWarnings.js +174 -2
- package/dist/pipeline/contentWarnings.js.map +1 -1
- package/dist/pipeline/floatPlacement.d.ts +9 -3
- package/dist/pipeline/floatPlacement.d.ts.map +1 -1
- package/dist/pipeline/floatPlacement.js +17 -6
- package/dist/pipeline/floatPlacement.js.map +1 -1
- package/dist/pipeline/headerFooter.d.ts +5 -2
- package/dist/pipeline/headerFooter.d.ts.map +1 -1
- package/dist/pipeline/headerFooter.js +123 -28
- package/dist/pipeline/headerFooter.js.map +1 -1
- package/dist/pipeline/headingDesignCuts.d.ts.map +1 -1
- package/dist/pipeline/headingDesignCuts.js +3 -1
- package/dist/pipeline/headingDesignCuts.js.map +1 -1
- package/dist/pipeline/headingStyles.d.ts +9 -3
- package/dist/pipeline/headingStyles.d.ts.map +1 -1
- package/dist/pipeline/headingStyles.js +23 -5
- package/dist/pipeline/headingStyles.js.map +1 -1
- package/dist/pipeline/indexDirective.d.ts.map +1 -1
- package/dist/pipeline/indexDirective.js +64 -20
- package/dist/pipeline/indexDirective.js.map +1 -1
- package/dist/pipeline/indexGroups.d.ts +55 -0
- package/dist/pipeline/indexGroups.d.ts.map +1 -0
- package/dist/pipeline/indexGroups.js +151 -0
- package/dist/pipeline/indexGroups.js.map +1 -0
- package/dist/pipeline/lists.d.ts +17 -0
- package/dist/pipeline/lists.d.ts.map +1 -1
- package/dist/pipeline/lists.js +43 -51
- package/dist/pipeline/lists.js.map +1 -1
- package/dist/pipeline/measureContentBlock.d.ts +3 -0
- package/dist/pipeline/measureContentBlock.d.ts.map +1 -1
- package/dist/pipeline/measureContentBlock.js +31 -4
- package/dist/pipeline/measureContentBlock.js.map +1 -1
- package/dist/pipeline/outline.d.ts.map +1 -1
- package/dist/pipeline/outline.js +13 -8
- package/dist/pipeline/outline.js.map +1 -1
- package/dist/pipeline/parts.d.ts +6 -3
- package/dist/pipeline/parts.d.ts.map +1 -1
- package/dist/pipeline/parts.js +28 -5
- package/dist/pipeline/parts.js.map +1 -1
- package/dist/pipeline/placeholders.d.ts +11 -0
- package/dist/pipeline/placeholders.d.ts.map +1 -1
- package/dist/pipeline/placeholders.js +48 -18
- package/dist/pipeline/placeholders.js.map +1 -1
- package/dist/pipeline/placement.d.ts +10 -6
- package/dist/pipeline/placement.d.ts.map +1 -1
- package/dist/pipeline/placement.js +33 -16
- package/dist/pipeline/placement.js.map +1 -1
- package/dist/pipeline/resourceLayout.d.ts +18 -1
- package/dist/pipeline/resourceLayout.d.ts.map +1 -1
- package/dist/pipeline/resourceLayout.js +109 -21
- package/dist/pipeline/resourceLayout.js.map +1 -1
- package/dist/pipeline/toc.d.ts.map +1 -1
- package/dist/pipeline/toc.js +6 -5
- package/dist/pipeline/toc.js.map +1 -1
- package/dist/pipeline/verticalMetrics.d.ts +14 -0
- package/dist/pipeline/verticalMetrics.d.ts.map +1 -0
- package/dist/pipeline/verticalMetrics.js +154 -0
- package/dist/pipeline/verticalMetrics.js.map +1 -0
- package/dist/types.d.ts +344 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/vdt.d.ts +396 -6
- package/dist/vdt.d.ts.map +1 -1
- package/dist/vdt.js +49 -0
- package/dist/vdt.js.map +1 -1
- package/dist/writingMode.d.ts +156 -0
- package/dist/writingMode.d.ts.map +1 -0
- package/dist/writingMode.js +291 -0
- package/dist/writingMode.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertical text on the canvas (`VDTPage.flow`).
|
|
3
|
+
*
|
|
4
|
+
* `paintPage` paints a vertical page's flow through the page's frame — the
|
|
5
|
+
* context turned a quarter turn clockwise (`ctx.transform(0, 1, -1, 0, W,
|
|
6
|
+
* 0)`) — and switches the painter here on for as long as it does. Every
|
|
7
|
+
* text painter of the backend calls {@link fillFlowText} instead of
|
|
8
|
+
* `ctx.fillText`: on a horizontal page it IS `ctx.fillText`, with the same
|
|
9
|
+
* arguments; inside a vertical flow it cuts the text into sideways runs
|
|
10
|
+
* (Latin, numbers: painted as they are, which the frame turns sideways) and
|
|
11
|
+
* cells (Han, punctuation, dashes, upright symbols), each cell its length
|
|
12
|
+
* down the line (one em; half an em for the mainland interpunct), the
|
|
13
|
+
* character turned back to stand upright about the cell's centre on the
|
|
14
|
+
* font's central axis (`VDTFlowFrame.centralBaselines`). The runs are the
|
|
15
|
+
* ones the text was measured with (`verticalRuns`), so each segment paints
|
|
16
|
+
* within the width the layout gave it.
|
|
17
|
+
*
|
|
18
|
+
* Punctuation takes the font's vertical form (OpenType `vert`) through a
|
|
19
|
+
* twin face the host registers with {@link registerVerticalAlternates} —
|
|
20
|
+
* the same font file loaded under another family name with
|
|
21
|
+
* `featureSettings: '"vert" 1, "fwid" 1'`, which Chrome 140+ applies to
|
|
22
|
+
* canvas text. Without a twin, the fallbacks of `verticalOrientation`
|
|
23
|
+
* apply: brackets and quotes turned about the em box's centre, mainland
|
|
24
|
+
* pause and stop marks moved to the upper right of the cell (each by its
|
|
25
|
+
* glyph's `offset`). A dash, an ellipsis or a wave dash stands in the
|
|
26
|
+
* twin's vertical form when the font has one (Noto CJK's —— needs `fwid`
|
|
27
|
+
* with `vert`: a rule down the middle of the cell), else it is turned
|
|
28
|
+
* with its ink centred on the column's axis.
|
|
29
|
+
*/
|
|
30
|
+
import type { CjkRegion } from '../types';
|
|
31
|
+
import { type ForcedOrientation } from '../writingMode';
|
|
32
|
+
import { type MarkCutRule } from '../measure/markCuts';
|
|
33
|
+
/** What the painter needs while a vertical flow paints. */
|
|
34
|
+
export interface VerticalPaintState {
|
|
35
|
+
region: CjkRegion;
|
|
36
|
+
/** `VDTFlowFrame.centralBaselines` of the page. */
|
|
37
|
+
axes?: Record<string, number>;
|
|
38
|
+
/** `cjk.uprightDigits`: a number of at most this many digits stands in
|
|
39
|
+
* one upright cell (as the measurer found it, `verticalRuns`). */
|
|
40
|
+
uprightDigits?: number;
|
|
41
|
+
}
|
|
42
|
+
/** Switch vertical painting on (a state) or off (`null`); returns the state
|
|
43
|
+
* it replaces, for the caller to put back. */
|
|
44
|
+
export declare function setVerticalPaint(state: VerticalPaintState | null): VerticalPaintState | null;
|
|
45
|
+
/** Whether text painted now is set vertically. */
|
|
46
|
+
export declare function verticalPaintActive(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Paint the vertical forms of `family`'s punctuation (brackets, quotes,
|
|
49
|
+
* mainland pause marks, ellipses) with `twinFamily`: the same font loaded
|
|
50
|
+
* under that name with `featureSettings: '"vert" 1'` (see
|
|
51
|
+
* {@link loadVerticalAlternates}). Hosts that load fonts themselves call
|
|
52
|
+
* this once the twin is ready; without one the painter's fallbacks apply.
|
|
53
|
+
*/
|
|
54
|
+
export declare function registerVerticalAlternates(family: string, twinFamily: string): void;
|
|
55
|
+
/** Forget the twin of `family` (or of every family), removing the faces
|
|
56
|
+
* {@link loadVerticalAlternates} added for it: the family's font changed
|
|
57
|
+
* (a file uploaded again under the same name), so its twin must be loaded
|
|
58
|
+
* again from the new sources. A load still under way for it is dropped. */
|
|
59
|
+
export declare function unregisterVerticalAlternates(family?: string): void;
|
|
60
|
+
/** The twin family registered for `family`, if any. */
|
|
61
|
+
export declare function verticalAlternatesOf(family: string): string | undefined;
|
|
62
|
+
/** The family name a twin of `family` is registered under by
|
|
63
|
+
* {@link loadVerticalAlternates}. */
|
|
64
|
+
export declare function verticalTwinName(family: string): string;
|
|
65
|
+
/** One face of a family: its source (a URL or the font bytes) and
|
|
66
|
+
* descriptors, as `new FontFace` takes them. */
|
|
67
|
+
export interface VerticalAlternatesFace {
|
|
68
|
+
source: string | ArrayBuffer;
|
|
69
|
+
weight?: string;
|
|
70
|
+
style?: string;
|
|
71
|
+
unicodeRange?: string;
|
|
72
|
+
}
|
|
73
|
+
/** The characters a twin is loaded for (only these ever paint with it). */
|
|
74
|
+
export declare const VERTICAL_ALTERNATE_SAMPLE = "\u300C\u300D\u300E\u300F\uFF08\uFF09\u300A\u300B\u3008\u3009\u3010\u3011\u3014\u3015\u3016\u3017\uFF3B\uFF3D\uFF5B\uFF5D\uFF0C\u3002\u3001\uFF1A\uFF1B\uFF01\uFF1F\u201C\u201D\u2018\u2019\u2026\uFF5E";
|
|
75
|
+
/**
|
|
76
|
+
* Load a twin of `family` with its vertical forms on (`featureSettings:
|
|
77
|
+
* '"vert" 1'`) from the same sources, and register it when the browser
|
|
78
|
+
* applies the feature to canvas text — the probe draws 「(《 with both
|
|
79
|
+
* faces and compares their ink. Resolves to whether the twin is in use.
|
|
80
|
+
* Browser only; a no-op (false) elsewhere.
|
|
81
|
+
*/
|
|
82
|
+
export declare function loadVerticalAlternates(family: string, faces: readonly VerticalAlternatesFace[]): Promise<boolean>;
|
|
83
|
+
/** How text is put on the canvas: filled, stroked (an outline), or both
|
|
84
|
+
* (outline over the fill). */
|
|
85
|
+
export type TextPaintMode = 'fill' | 'stroke' | 'fillStroke';
|
|
86
|
+
/**
|
|
87
|
+
* Paint `text` from `x` on `baseline`, as `ctx.fillText` would (and
|
|
88
|
+
* `ctx.strokeText` for `mode` `'stroke'` / `'fillStroke'`). On a
|
|
89
|
+
* horizontal page it is exactly those calls, except that two CJK marks
|
|
90
|
+
* side by side that the layout measured apart are painted apart (see
|
|
91
|
+
* `putHorizontal`); `cuts` says how the layout measured the text
|
|
92
|
+
* (`MarkCutRule`: whole by default; word by word for a line of a Latin
|
|
93
|
+
* paragraph; character by character for a line of the CJK composer). In a
|
|
94
|
+
* vertical flow (see the module comment) it sets the text vertically:
|
|
95
|
+
* `tracking` (px after every character, default the context's
|
|
96
|
+
* `letterSpacing`) is added after each cell and inside each sideways run.
|
|
97
|
+
* Returns nothing; the caller advances by the width the layout measured.
|
|
98
|
+
*/
|
|
99
|
+
export declare function fillFlowText(ctx: CanvasRenderingContext2D, text: string, x: number, baseline: number, mode?: TextPaintMode, tracking?: number, cuts?: MarkCutRule,
|
|
100
|
+
/** The orientation the author gave the text (`VDTLineSegment.tcy` /
|
|
101
|
+
* `orientation`); vertical text only. */
|
|
102
|
+
orient?: ForcedOrientation): void;
|
|
103
|
+
/**
|
|
104
|
+
* Draw an image (or anything `draw` paints in a `w` × `h` box) inside a
|
|
105
|
+
* box of the current frame: as is on a horizontal page; turned back to
|
|
106
|
+
* stand upright on a vertical one, where the box's `w` runs down the sheet
|
|
107
|
+
* and `h` across it. A box `sized` for that (`VDTDesignImageBlock.upright`:
|
|
108
|
+
* its width is the picture's height) is filled; any other box was sized
|
|
109
|
+
* for the picture's own proportions as if horizontal, which upright keep
|
|
110
|
+
* them: scaled to fit the turned box, centred in it.
|
|
111
|
+
*/
|
|
112
|
+
export declare function drawUprightInBox(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, draw: (x: number, y: number, w: number, h: number) => void, sized?: boolean): void;
|
|
113
|
+
//# sourceMappingURL=verticalText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verticalText.d.ts","sourceRoot":"","sources":["../../src/canvas-backend/verticalText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAsD,KAAK,iBAAiB,EAAsB,MAAM,gBAAgB,CAAC;AAEhI,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAInE,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,CAAC;IAClB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;uEACmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;+CAC+C;AAC/C,wBAAg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C1C,MAAM,CAAC,EAAE,iBAAiB,GACzB,IAAI,CAUN;AAiKD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,wBAAwB,EAC7B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,EAC1D,KAAK,UAAQ,GACZ,IAAI,CAiBN"}
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertical text on the canvas (`VDTPage.flow`).
|
|
3
|
+
*
|
|
4
|
+
* `paintPage` paints a vertical page's flow through the page's frame — the
|
|
5
|
+
* context turned a quarter turn clockwise (`ctx.transform(0, 1, -1, 0, W,
|
|
6
|
+
* 0)`) — and switches the painter here on for as long as it does. Every
|
|
7
|
+
* text painter of the backend calls {@link fillFlowText} instead of
|
|
8
|
+
* `ctx.fillText`: on a horizontal page it IS `ctx.fillText`, with the same
|
|
9
|
+
* arguments; inside a vertical flow it cuts the text into sideways runs
|
|
10
|
+
* (Latin, numbers: painted as they are, which the frame turns sideways) and
|
|
11
|
+
* cells (Han, punctuation, dashes, upright symbols), each cell its length
|
|
12
|
+
* down the line (one em; half an em for the mainland interpunct), the
|
|
13
|
+
* character turned back to stand upright about the cell's centre on the
|
|
14
|
+
* font's central axis (`VDTFlowFrame.centralBaselines`). The runs are the
|
|
15
|
+
* ones the text was measured with (`verticalRuns`), so each segment paints
|
|
16
|
+
* within the width the layout gave it.
|
|
17
|
+
*
|
|
18
|
+
* Punctuation takes the font's vertical form (OpenType `vert`) through a
|
|
19
|
+
* twin face the host registers with {@link registerVerticalAlternates} —
|
|
20
|
+
* the same font file loaded under another family name with
|
|
21
|
+
* `featureSettings: '"vert" 1, "fwid" 1'`, which Chrome 140+ applies to
|
|
22
|
+
* canvas text. Without a twin, the fallbacks of `verticalOrientation`
|
|
23
|
+
* apply: brackets and quotes turned about the em box's centre, mainland
|
|
24
|
+
* pause and stop marks moved to the upper right of the cell (each by its
|
|
25
|
+
* glyph's `offset`). A dash, an ellipsis or a wave dash stands in the
|
|
26
|
+
* twin's vertical form when the font has one (Noto CJK's —— needs `fwid`
|
|
27
|
+
* with `vert`: a rule down the middle of the cell), else it is turned
|
|
28
|
+
* with its ink centred on the column's axis.
|
|
29
|
+
*/
|
|
30
|
+
import { DEFAULT_CENTRAL_BASELINE } from '../vdt';
|
|
31
|
+
import { forcedVerticalRuns, verticalRuns, CORNER_OFFSET_EM } from '../writingMode';
|
|
32
|
+
import { graphemeCount, graphemesOf } from '../measure/graphemes';
|
|
33
|
+
import { markPieces } from '../measure/markCuts';
|
|
34
|
+
import { measureRunWidth } from '../measure/canvas';
|
|
35
|
+
import { hasCJK } from '../measure/cjk';
|
|
36
|
+
let paintState = null;
|
|
37
|
+
/** Switch vertical painting on (a state) or off (`null`); returns the state
|
|
38
|
+
* it replaces, for the caller to put back. */
|
|
39
|
+
export function setVerticalPaint(state) {
|
|
40
|
+
const previous = paintState;
|
|
41
|
+
paintState = state;
|
|
42
|
+
return previous;
|
|
43
|
+
}
|
|
44
|
+
/** Whether text painted now is set vertically. */
|
|
45
|
+
export function verticalPaintActive() {
|
|
46
|
+
return paintState !== null;
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Vertical alternates through a twin face
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
const twins = new Map();
|
|
52
|
+
/** The faces {@link loadVerticalAlternates} added for a family's twin. */
|
|
53
|
+
const twinFaces = new Map();
|
|
54
|
+
/** Per family, how many times its twin was loaded or dropped: a load that
|
|
55
|
+
* another one (or an unregister) overtook while it waited is stale. */
|
|
56
|
+
const twinGeneration = new Map();
|
|
57
|
+
/**
|
|
58
|
+
* Paint the vertical forms of `family`'s punctuation (brackets, quotes,
|
|
59
|
+
* mainland pause marks, ellipses) with `twinFamily`: the same font loaded
|
|
60
|
+
* under that name with `featureSettings: '"vert" 1'` (see
|
|
61
|
+
* {@link loadVerticalAlternates}). Hosts that load fonts themselves call
|
|
62
|
+
* this once the twin is ready; without one the painter's fallbacks apply.
|
|
63
|
+
*/
|
|
64
|
+
export function registerVerticalAlternates(family, twinFamily) {
|
|
65
|
+
twins.set(family, twinFamily);
|
|
66
|
+
}
|
|
67
|
+
function removeFaces(faces) {
|
|
68
|
+
if (!faces || typeof document === 'undefined' || !document.fonts)
|
|
69
|
+
return;
|
|
70
|
+
for (const ff of faces) {
|
|
71
|
+
try {
|
|
72
|
+
document.fonts.delete(ff);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Already gone.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Forget the twin of `family` (or of every family), removing the faces
|
|
80
|
+
* {@link loadVerticalAlternates} added for it: the family's font changed
|
|
81
|
+
* (a file uploaded again under the same name), so its twin must be loaded
|
|
82
|
+
* again from the new sources. A load still under way for it is dropped. */
|
|
83
|
+
export function unregisterVerticalAlternates(family) {
|
|
84
|
+
const families = family === undefined ? [...new Set([...twins.keys(), ...twinFaces.keys(), ...twinGeneration.keys()])] : [family];
|
|
85
|
+
for (const f of families) {
|
|
86
|
+
twins.delete(f);
|
|
87
|
+
removeFaces(twinFaces.get(f));
|
|
88
|
+
twinFaces.delete(f);
|
|
89
|
+
twinGeneration.set(f, (twinGeneration.get(f) ?? 0) + 1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** The twin family registered for `family`, if any. */
|
|
93
|
+
export function verticalAlternatesOf(family) {
|
|
94
|
+
return twins.get(family);
|
|
95
|
+
}
|
|
96
|
+
/** The family name a twin of `family` is registered under by
|
|
97
|
+
* {@link loadVerticalAlternates}. */
|
|
98
|
+
export function verticalTwinName(family) {
|
|
99
|
+
return `${family} postext-vert`;
|
|
100
|
+
}
|
|
101
|
+
/** Brackets the probe compares: their vertical forms differ from the
|
|
102
|
+
* horizontal ones in every CJK face. */
|
|
103
|
+
const PROBE = '「(《';
|
|
104
|
+
/** The characters a twin is loaded for (only these ever paint with it). */
|
|
105
|
+
export const VERTICAL_ALTERNATE_SAMPLE = '「」『』()《》〈〉【】〔〕〖〗[]{},。、:;!?“”‘’…~';
|
|
106
|
+
function inkKey(ctx, font, text) {
|
|
107
|
+
ctx.font = font;
|
|
108
|
+
const m = ctx.measureText(text);
|
|
109
|
+
return [m.actualBoundingBoxLeft, m.actualBoundingBoxRight, m.actualBoundingBoxAscent, m.actualBoundingBoxDescent]
|
|
110
|
+
.map((v) => Math.round((v ?? 0) * 10))
|
|
111
|
+
.join(',');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Load a twin of `family` with its vertical forms on (`featureSettings:
|
|
115
|
+
* '"vert" 1'`) from the same sources, and register it when the browser
|
|
116
|
+
* applies the feature to canvas text — the probe draws 「(《 with both
|
|
117
|
+
* faces and compares their ink. Resolves to whether the twin is in use.
|
|
118
|
+
* Browser only; a no-op (false) elsewhere.
|
|
119
|
+
*/
|
|
120
|
+
export async function loadVerticalAlternates(family, faces) {
|
|
121
|
+
if (typeof document === 'undefined' || !document.fonts || typeof FontFace === 'undefined' || faces.length === 0)
|
|
122
|
+
return false;
|
|
123
|
+
if (twins.has(family))
|
|
124
|
+
return true;
|
|
125
|
+
const generation = (twinGeneration.get(family) ?? 0) + 1;
|
|
126
|
+
twinGeneration.set(family, generation);
|
|
127
|
+
// A family loaded again (after `unregisterVerticalAlternates`) takes a
|
|
128
|
+
// fresh name, so no face or glyph cache of the old file answers for it.
|
|
129
|
+
const twin = generation > 1 ? `${verticalTwinName(family)} ${generation}` : verticalTwinName(family);
|
|
130
|
+
const loaded = [];
|
|
131
|
+
for (const face of faces) {
|
|
132
|
+
try {
|
|
133
|
+
const src = typeof face.source === 'string' ? `url(${JSON.stringify(face.source)})` : face.source;
|
|
134
|
+
const ff = new FontFace(twin, src, {
|
|
135
|
+
...(face.weight ? { weight: face.weight } : {}),
|
|
136
|
+
...(face.style ? { style: face.style } : {}),
|
|
137
|
+
...(face.unicodeRange ? { unicodeRange: face.unicodeRange } : {}),
|
|
138
|
+
// `fwid` with `vert`: the full-width forms of dashes, whose
|
|
139
|
+
// vertical form Noto CJK keys to both; the marks the twin paints
|
|
140
|
+
// are full-width already.
|
|
141
|
+
featureSettings: '"vert" 1, "fwid" 1',
|
|
142
|
+
});
|
|
143
|
+
document.fonts.add(ff);
|
|
144
|
+
loaded.push(ff);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// A face the browser refuses: the others may still cover the marks.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (loaded.length === 0)
|
|
151
|
+
return false;
|
|
152
|
+
const q = (f) => JSON.stringify(f);
|
|
153
|
+
const current = () => twinGeneration.get(family) === generation;
|
|
154
|
+
try {
|
|
155
|
+
await Promise.all([
|
|
156
|
+
document.fonts.load(`16px ${q(twin)}`, VERTICAL_ALTERNATE_SAMPLE),
|
|
157
|
+
document.fonts.load(`16px ${q(family)}`, PROBE),
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
removeFaces(loaded);
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
const canvas = typeof OffscreenCanvas !== 'undefined' ? new OffscreenCanvas(8, 8) : document.createElement('canvas');
|
|
165
|
+
const ctx = canvas.getContext('2d');
|
|
166
|
+
const applied = !!ctx && current() && inkKey(ctx, `100px ${q(twin)}`, PROBE) !== inkKey(ctx, `100px ${q(family)}`, PROBE);
|
|
167
|
+
if (applied) {
|
|
168
|
+
twins.set(family, twin);
|
|
169
|
+
twinFaces.set(family, loaded);
|
|
170
|
+
}
|
|
171
|
+
else
|
|
172
|
+
removeFaces(loaded);
|
|
173
|
+
return applied;
|
|
174
|
+
}
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// The painter
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
const SIZE_RE = /(\d*\.?\d+)px(\s*\/\s*[^\s]+)?\s*/;
|
|
179
|
+
/** The em (px) and the first family of a CSS font shorthand. */
|
|
180
|
+
function parseFont(font) {
|
|
181
|
+
const m = SIZE_RE.exec(font);
|
|
182
|
+
if (!m)
|
|
183
|
+
return { em: 16, family: font.trim(), prefix: '' };
|
|
184
|
+
const prefix = font.slice(0, m.index + m[0].length);
|
|
185
|
+
const rest = font.slice(m.index + m[0].length);
|
|
186
|
+
let first = rest.split(',')[0].trim();
|
|
187
|
+
if (first.length >= 2 && /^["']/.test(first) && first.endsWith(first[0]))
|
|
188
|
+
first = first.slice(1, -1);
|
|
189
|
+
return { em: parseFloat(m[1]), family: first, prefix };
|
|
190
|
+
}
|
|
191
|
+
function put(ctx, text, x, y, mode) {
|
|
192
|
+
if (mode !== 'stroke')
|
|
193
|
+
ctx.fillText(text, x, y);
|
|
194
|
+
if (mode !== 'fill')
|
|
195
|
+
ctx.strokeText(text, x, y);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* {@link put} for horizontal text that may hold two CJK marks side by side
|
|
199
|
+
* (`)》`, `”“`, see `cjkMarkCuts`): Chrome would set the first half width
|
|
200
|
+
* in one run, where the layout may have measured each at its own advance.
|
|
201
|
+
* Such text is cut where the layout's measurer cut it (`rule`, see
|
|
202
|
+
* `markCuts`) and painted piece by piece, each piece where the one before
|
|
203
|
+
* ends as the browser sets it (`measureRunWidth`, the context's tracking
|
|
204
|
+
* and word spacing on top) — for a line of the CJK composer, where its
|
|
205
|
+
* characters are. Any other text is one call, as before.
|
|
206
|
+
*/
|
|
207
|
+
function putHorizontal(ctx, text, x, y, mode, rule) {
|
|
208
|
+
const pieces = markPieces(text, rule);
|
|
209
|
+
if (pieces.length === 1) {
|
|
210
|
+
put(ctx, text, x, y, mode);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const font = ctx.font;
|
|
214
|
+
const spacing = parseFloat(ctx.letterSpacing) || 0;
|
|
215
|
+
const wordSpacing = parseFloat(ctx.wordSpacing ?? '') || 0;
|
|
216
|
+
const widths = pieces.map((piece) => measureRunWidth(piece, font)
|
|
217
|
+
+ (spacing === 0 ? 0 : spacing * graphemeCount(piece))
|
|
218
|
+
+ (wordSpacing === 0 ? 0 : wordSpacing * (piece.split(' ').length - 1)));
|
|
219
|
+
const align = ctx.textAlign;
|
|
220
|
+
let px = x;
|
|
221
|
+
if (align === 'center' || align === 'right' || align === 'end') {
|
|
222
|
+
const total = widths.reduce((a, b) => a + b, 0);
|
|
223
|
+
px -= align === 'center' ? total / 2 : total;
|
|
224
|
+
ctx.textAlign = 'left';
|
|
225
|
+
}
|
|
226
|
+
for (let i = 0; i < pieces.length; i++) {
|
|
227
|
+
put(ctx, pieces[i], px, y, mode);
|
|
228
|
+
px += widths[i];
|
|
229
|
+
}
|
|
230
|
+
if (ctx.textAlign !== align)
|
|
231
|
+
ctx.textAlign = align;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Paint `text` from `x` on `baseline`, as `ctx.fillText` would (and
|
|
235
|
+
* `ctx.strokeText` for `mode` `'stroke'` / `'fillStroke'`). On a
|
|
236
|
+
* horizontal page it is exactly those calls, except that two CJK marks
|
|
237
|
+
* side by side that the layout measured apart are painted apart (see
|
|
238
|
+
* `putHorizontal`); `cuts` says how the layout measured the text
|
|
239
|
+
* (`MarkCutRule`: whole by default; word by word for a line of a Latin
|
|
240
|
+
* paragraph; character by character for a line of the CJK composer). In a
|
|
241
|
+
* vertical flow (see the module comment) it sets the text vertically:
|
|
242
|
+
* `tracking` (px after every character, default the context's
|
|
243
|
+
* `letterSpacing`) is added after each cell and inside each sideways run.
|
|
244
|
+
* Returns nothing; the caller advances by the width the layout measured.
|
|
245
|
+
*/
|
|
246
|
+
export function fillFlowText(ctx, text, x, baseline, mode = 'fill', tracking, cuts = 'text',
|
|
247
|
+
/** The orientation the author gave the text (`VDTLineSegment.tcy` /
|
|
248
|
+
* `orientation`); vertical text only. */
|
|
249
|
+
orient) {
|
|
250
|
+
const state = paintState;
|
|
251
|
+
if (!state) {
|
|
252
|
+
// Text with no CJK is cut only under the composer's rule (see
|
|
253
|
+
// `markCuts`): one call, with no cut to look for.
|
|
254
|
+
if (cuts !== 'composed' && !hasCJK(text))
|
|
255
|
+
put(ctx, text, x, baseline, mode);
|
|
256
|
+
else
|
|
257
|
+
putHorizontal(ctx, text, x, baseline, mode, cuts);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
paintVertical(ctx, state, text, x, baseline, mode, tracking, orient);
|
|
261
|
+
}
|
|
262
|
+
function paintVertical(ctx, state, text, x, y, mode, trackingArg, orient) {
|
|
263
|
+
const font = ctx.font;
|
|
264
|
+
const { em, family, prefix } = parseFont(font);
|
|
265
|
+
const central = (state.axes?.[family] ?? DEFAULT_CENTRAL_BASELINE) * em;
|
|
266
|
+
const spacing = ctx.letterSpacing;
|
|
267
|
+
const tracking = trackingArg ?? (parseFloat(spacing) || 0);
|
|
268
|
+
// A caller centring on `middle` (a list bullet) gives the axis itself.
|
|
269
|
+
const middle = ctx.textBaseline === 'middle';
|
|
270
|
+
const axis = middle ? y : y - central;
|
|
271
|
+
const baseline = axis + central;
|
|
272
|
+
const align = ctx.textAlign;
|
|
273
|
+
if (middle)
|
|
274
|
+
ctx.textBaseline = 'alphabetic';
|
|
275
|
+
if (align !== 'left' && align !== 'start')
|
|
276
|
+
ctx.textAlign = 'left';
|
|
277
|
+
const twin = twins.get(family);
|
|
278
|
+
const twinFont = twin ? `${prefix}${JSON.stringify(twin)}` : undefined;
|
|
279
|
+
let cx = x;
|
|
280
|
+
const graphemes = graphemesOf(text);
|
|
281
|
+
const runs = orient ? forcedVerticalRuns(graphemes, orient) : verticalRuns(graphemes, state.region, state.uprightDigits ?? 0);
|
|
282
|
+
for (const run of runs) {
|
|
283
|
+
if (run.cell === undefined) {
|
|
284
|
+
// The frame turns it sideways: painted as it is, the letters tracked.
|
|
285
|
+
put(ctx, run.text, cx, baseline, mode);
|
|
286
|
+
cx += ctx.measureText(run.text).width;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (run.glyph.orient === 'tcy') {
|
|
290
|
+
cx += paintCombined(ctx, run.text, cx, axis, em, central, mode) + tracking;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
cx += paintCell(ctx, run.text, run.glyph, cx, axis, em * run.cell, em, central, mode, twinFont, tracking !== 0) + tracking;
|
|
294
|
+
}
|
|
295
|
+
if (middle)
|
|
296
|
+
ctx.textBaseline = 'middle';
|
|
297
|
+
if (align !== 'left' && align !== 'start')
|
|
298
|
+
ctx.textAlign = align;
|
|
299
|
+
}
|
|
300
|
+
/** Whether the twin face (`twin`, a font string) gives `char` a glyph of
|
|
301
|
+
* its own — a vertical form — where the face (`face`) has the horizontal
|
|
302
|
+
* one: their ink at 100 px differs. Cached per family pair. */
|
|
303
|
+
const formCache = new Map();
|
|
304
|
+
function twinHasForm(ctx, face, twin, char) {
|
|
305
|
+
const at100 = (font) => font.replace(SIZE_RE, '100px ');
|
|
306
|
+
const key = `${at100(face)}|${at100(twin)}|${char}`;
|
|
307
|
+
const hit = formCache.get(key);
|
|
308
|
+
if (hit !== undefined)
|
|
309
|
+
return hit;
|
|
310
|
+
const saved = ctx.font;
|
|
311
|
+
const plain = inkKey(ctx, at100(face), char);
|
|
312
|
+
const vertical = inkKey(ctx, at100(twin), char);
|
|
313
|
+
ctx.font = saved;
|
|
314
|
+
const differs = plain !== vertical;
|
|
315
|
+
formCache.set(key, differs);
|
|
316
|
+
return differs;
|
|
317
|
+
}
|
|
318
|
+
/** Paint one cell (`cell` px along the line: an em, or half of one)
|
|
319
|
+
* centred on `(x + cell / 2, axis)`; returns its advance. */
|
|
320
|
+
function paintCell(ctx, g, glyph, x, axis, cell,
|
|
321
|
+
/** The font's em: the glyph's own box, whole across the column even
|
|
322
|
+
* where the cell is shorter along it. */
|
|
323
|
+
em, central, mode, twinFont, tracked) {
|
|
324
|
+
const cx = x + cell / 2;
|
|
325
|
+
const spacing = tracked ? ctx.letterSpacing : undefined;
|
|
326
|
+
if (spacing !== undefined)
|
|
327
|
+
ctx.letterSpacing = '0px';
|
|
328
|
+
let kind = 'upright';
|
|
329
|
+
let char = g;
|
|
330
|
+
let face;
|
|
331
|
+
if (glyph.orient === 'rotate') {
|
|
332
|
+
// A dash, an ellipsis, a wave dash: the font's vertical form when the
|
|
333
|
+
// twin has one, else turned.
|
|
334
|
+
if (twinFont && twinHasForm(ctx, ctx.font, twinFont, g))
|
|
335
|
+
face = twinFont;
|
|
336
|
+
else
|
|
337
|
+
kind = 'rotate';
|
|
338
|
+
}
|
|
339
|
+
else if (glyph.orient === 'alternate') {
|
|
340
|
+
if (twinFont)
|
|
341
|
+
face = twinFont;
|
|
342
|
+
else {
|
|
343
|
+
kind = glyph.fallback === 'corner' ? 'corner' : 'rotate';
|
|
344
|
+
if (glyph.substitute)
|
|
345
|
+
char = glyph.substitute;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const baseFont = face ? ctx.font : undefined;
|
|
349
|
+
if (face)
|
|
350
|
+
ctx.font = face;
|
|
351
|
+
const w = ctx.measureText(char).width;
|
|
352
|
+
ctx.save();
|
|
353
|
+
ctx.translate(cx, axis);
|
|
354
|
+
if (kind === 'rotate') {
|
|
355
|
+
// Turned with the frame; a dash stretched to fill its cell. A bracket
|
|
356
|
+
// or a quote turns about the em box's centre, so it hugs the character
|
|
357
|
+
// it belongs to; a dash, an ellipsis, an interpunct is centred on the
|
|
358
|
+
// axis by its ink (Noto's — sits 0.27 em above the baseline, not at the
|
|
359
|
+
// em box's 0.38).
|
|
360
|
+
if (glyph.stretch && w > 0 && w < cell)
|
|
361
|
+
ctx.scale(cell / w, 1);
|
|
362
|
+
let lift = central;
|
|
363
|
+
if (glyph.orient === 'rotate') {
|
|
364
|
+
const m = ctx.measureText(char);
|
|
365
|
+
const ascent = m.actualBoundingBoxAscent;
|
|
366
|
+
const descent = m.actualBoundingBoxDescent;
|
|
367
|
+
if (Number.isFinite(ascent) && Number.isFinite(descent) && ascent + descent > 0)
|
|
368
|
+
lift = (ascent - descent) / 2;
|
|
369
|
+
}
|
|
370
|
+
put(ctx, char, -w / 2, lift, mode);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
// Stood upright again about the cell's centre.
|
|
374
|
+
ctx.rotate(-Math.PI / 2);
|
|
375
|
+
const offset = kind === 'corner' ? glyph.offset ?? CORNER_OFFSET_EM : undefined;
|
|
376
|
+
const dx = offset ? offset.x * em : 0;
|
|
377
|
+
const dy = offset ? offset.y * em : 0;
|
|
378
|
+
put(ctx, char, -w / 2 + dx, central + dy, mode);
|
|
379
|
+
}
|
|
380
|
+
ctx.restore();
|
|
381
|
+
if (baseFont !== undefined)
|
|
382
|
+
ctx.font = baseFont;
|
|
383
|
+
if (spacing !== undefined)
|
|
384
|
+
ctx.letterSpacing = spacing;
|
|
385
|
+
return cell;
|
|
386
|
+
}
|
|
387
|
+
/** Tate-chu-yoko: `text` side by side in one upright cell of one em
|
|
388
|
+
* (`em` px along the line) centred on `(x + em / 2, axis)`, squeezed
|
|
389
|
+
* across to the em when wider; no tracking inside. Returns the cell's
|
|
390
|
+
* advance. */
|
|
391
|
+
function paintCombined(ctx, text, x, axis, em, central, mode) {
|
|
392
|
+
const spacing = ctx.letterSpacing;
|
|
393
|
+
const tracked = spacing !== '' && spacing !== '0px';
|
|
394
|
+
if (tracked)
|
|
395
|
+
ctx.letterSpacing = '0px';
|
|
396
|
+
const w = ctx.measureText(text).width;
|
|
397
|
+
const k = w > em ? em / w : 1;
|
|
398
|
+
ctx.save();
|
|
399
|
+
ctx.translate(x + em / 2, axis);
|
|
400
|
+
ctx.rotate(-Math.PI / 2);
|
|
401
|
+
if (k !== 1)
|
|
402
|
+
ctx.scale(k, 1);
|
|
403
|
+
put(ctx, text, -w / 2, central, mode);
|
|
404
|
+
ctx.restore();
|
|
405
|
+
if (tracked)
|
|
406
|
+
ctx.letterSpacing = spacing;
|
|
407
|
+
return em;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Draw an image (or anything `draw` paints in a `w` × `h` box) inside a
|
|
411
|
+
* box of the current frame: as is on a horizontal page; turned back to
|
|
412
|
+
* stand upright on a vertical one, where the box's `w` runs down the sheet
|
|
413
|
+
* and `h` across it. A box `sized` for that (`VDTDesignImageBlock.upright`:
|
|
414
|
+
* its width is the picture's height) is filled; any other box was sized
|
|
415
|
+
* for the picture's own proportions as if horizontal, which upright keep
|
|
416
|
+
* them: scaled to fit the turned box, centred in it.
|
|
417
|
+
*/
|
|
418
|
+
export function drawUprightInBox(ctx, x, y, w, h, draw, sized = false) {
|
|
419
|
+
if (!paintState) {
|
|
420
|
+
draw(x, y, w, h);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
ctx.save();
|
|
424
|
+
ctx.translate(x, y + h);
|
|
425
|
+
ctx.rotate(-Math.PI / 2);
|
|
426
|
+
// The box on the sheet is `h` wide and `w` tall.
|
|
427
|
+
if (sized)
|
|
428
|
+
draw(0, 0, h, w);
|
|
429
|
+
else {
|
|
430
|
+
const k = w > 0 && h > 0 ? Math.min(h / w, w / h) : 1;
|
|
431
|
+
const dw = w * k;
|
|
432
|
+
const dh = h * k;
|
|
433
|
+
draw((h - dw) / 2, (w - dh) / 2, dw, dh);
|
|
434
|
+
}
|
|
435
|
+
ctx.restore();
|
|
436
|
+
}
|
|
437
|
+
//# sourceMappingURL=verticalText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verticalText.js","sourceRoot":"","sources":["../../src/canvas-backend/verticalText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,g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,IAAI,EAAE,CAAC;IACX,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACzB,iDAAiD;IACjD,IAAI,KAAK;QAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SACvB,CAAC;QACJ,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chinese numerals, written and read: the CSS Counter Styles 3 longhand
|
|
3
|
+
* (`simp-chinese-informal` 一百二十, `trad-chinese-formal` 壹佰貳拾), the
|
|
4
|
+
* digit-by-digit `cjk-decimal` (二〇二六), the heavenly stems and earthly
|
|
5
|
+
* branches, circled and fullwidth digits — and the reverse, for part numbers
|
|
6
|
+
* an author typed (`卷三`, `第十二`, `一二〇`).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `n` (a positive integer) in Chinese numerals, as CSS Counter Styles 3
|
|
10
|
+
* writes the Chinese longhand, extended past 9 999 with the group units
|
|
11
|
+
* 万/萬, 亿/億: each digit followed by its marker (十 百 千, formal 拾 佰 仟),
|
|
12
|
+
* the marker dropped after a zero, a run of zeros written 零 once, zeros at
|
|
13
|
+
* the end dropped; in the informal style 10–19 open with 十, not 一十
|
|
14
|
+
* (十二, but 一百一十). 101 一百零一, 1010 一千零一十, 10010 一万零一十.
|
|
15
|
+
* Past 10¹⁶ − 1 the number prints in digits.
|
|
16
|
+
*/
|
|
17
|
+
export declare function chineseNumeral(n: number, kind: 'informal' | 'formal', traditional: boolean): string;
|
|
18
|
+
/** Digit by digit in Chinese numerals, with 〇 for zero: 2026 → 二〇二六
|
|
19
|
+
* (GB/T 15835—2011 §5.2.5, as years and serial numbers are written). */
|
|
20
|
+
export declare function cjkDecimal(n: number): string;
|
|
21
|
+
/** Fullwidth digits: 123 → 123. */
|
|
22
|
+
export declare function fullwidthDecimal(n: number): string;
|
|
23
|
+
/** Circled digits ① … ㊿ (U+2460–2473, U+3251–325F, U+32B1–32BF), ⓪ for
|
|
24
|
+
* zero; past 50 the number prints in digits. */
|
|
25
|
+
export declare function circledDecimal(n: number): string;
|
|
26
|
+
/** The ten heavenly stems, 甲 to 癸. */
|
|
27
|
+
export declare const CJK_HEAVENLY_STEMS: readonly string[];
|
|
28
|
+
/** The twelve earthly branches, 子 to 亥. */
|
|
29
|
+
export declare const CJK_EARTHLY_BRANCHES: readonly string[];
|
|
30
|
+
/** The `n`th symbol of a fixed series (1-based); past its end the number
|
|
31
|
+
* prints in digits. */
|
|
32
|
+
export declare function fixedSymbol(n: number, symbols: readonly string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* The value of a number written in Chinese numerals: the longhand, informal
|
|
35
|
+
* or formal, in either script (三, 十二, 一百零一, 一万零一十, 壹佰贰拾), or
|
|
36
|
+
* digit by digit (一二〇, 二〇二六). `undefined` for anything else.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseChineseNumeral(text: string): number | undefined;
|
|
39
|
+
//# sourceMappingURL=chineseNumerals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chineseNumerals.d.ts","sourceRoot":"","sources":["../src/chineseNumerals.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoCH;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAG,MAAM,CAyBnG;AAID;yEACyE;AACzE,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,mCAAmC;AACnC,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;iDACiD;AACjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,sCAAsC;AACtC,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAuD,CAAC;AACxG,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAiE,CAAC;AAEpH;wBACwB;AACxB,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzE;AA4DD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAapE"}
|