@yft-design/engine 0.0.10 → 0.0.12
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/EngineCanvas.d.ts +6 -0
- package/dist/EngineCanvas.js +8 -0
- package/dist/debug/seed.d.ts +2 -1
- package/dist/debug/seed.js +8 -5
- package/dist/engineFlag.d.ts +12 -0
- package/dist/engineFlag.js +12 -0
- package/dist/export/svgExport.js +12 -9
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interact/tableCellEditing.js +2 -1
- package/dist/model/scene.d.ts +1 -1
- package/dist/model/scene.js +4 -3
- package/dist/model/tableLayout.js +3 -2
- package/dist/model/textAlign.d.ts +37 -0
- package/dist/model/textAlign.js +36 -0
- package/dist/model/textLayout.d.ts +11 -4
- package/dist/model/textLayout.js +46 -26
- package/dist/render/QuadBatch.d.ts +14 -5
- package/dist/render/QuadBatch.js +66 -10
- package/dist/render/SceneRenderer.d.ts +10 -0
- package/dist/render/SceneRenderer.js +13 -1
- package/dist/render/TextRenderer.js +10 -4
- package/dist/render/gpuFx.d.ts +14 -2
- package/dist/render/gpuFx.js +34 -4
- package/dist/render/gpuShadow.d.ts +15 -3
- package/dist/render/gpuShadow.js +37 -4
- package/dist/render/imageEffects.d.ts +3 -1
- package/dist/render/imageEffects.js +30 -5
- package/dist/render/lineDecorationSdf.d.ts +63 -0
- package/dist/render/lineDecorationSdf.js +188 -0
- package/dist/render/scrollText.js +8 -3
- package/dist/render/segmentTable.d.ts +53 -0
- package/dist/render/segmentTable.js +117 -0
- package/dist/render/shaders.d.ts +4 -2
- package/dist/render/shaders.js +98 -7
- package/dist/render/shadowPainter.d.ts +1 -1
- package/dist/render/shadowPainter.js +3 -3
- package/dist/render/sharedGpuPainters.d.ts +4 -2
- package/dist/render/sharedGpuPainters.js +7 -5
- package/dist/render/strokeMiterOutline.d.ts +39 -0
- package/dist/render/strokeMiterOutline.js +224 -0
- package/dist/render/strokePainter.d.ts +11 -0
- package/dist/render/strokePainter.js +80 -7
- package/dist/render/strokeSdf.d.ts +34 -13
- package/dist/render/strokeSdf.js +177 -13
- package/package.json +1 -1
package/dist/EngineCanvas.d.ts
CHANGED
|
@@ -289,6 +289,12 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
289
289
|
/** 光标锚定缩放(fabric zoomToPoint 语义的 vpt 直写版) */
|
|
290
290
|
zoomAt(cssX: number, cssY: number, factor: number): void;
|
|
291
291
|
pan(dx: number, dy: number): void;
|
|
292
|
+
/** 覆盖层拖拽会话交互标记(批次 386,蒙版工具栏把手拖图「不跟手」刀一):
|
|
293
|
+
* DOM 层把手拖拽(蒙版中心/旋转/缩放把手族)每个拖拽事件调用——k 档
|
|
294
|
+
* settle 补帧在此期间保持 stale 让路(SceneRenderer.noteExternalInteraction
|
|
295
|
+
* 头注的实测数据与语义)。不写 vpt、不触 hit 带、不请求渲染(调用方属性
|
|
296
|
+
* 写自带);settle 定时器停手 160ms 后自动补一帧收尾 */
|
|
297
|
+
noteExternalGesture(): void;
|
|
292
298
|
/** rAF 合并渲染请求(fabric requestRenderAll 同语义)+ rAF 饥饿超时兜底。
|
|
293
299
|
* 批次 44:失焦/被遮挡的内嵌浏览器窗格(IAB webview)实测 visibility 仍报
|
|
294
300
|
* 'visible' 但 rAF 永不回调——字体迟到自愈等「排帧后无人再触发」的补帧会
|
package/dist/EngineCanvas.js
CHANGED
|
@@ -443,6 +443,14 @@ export class EngineCanvas {
|
|
|
443
443
|
this.renderer.noteVptChange();
|
|
444
444
|
this.requestRenderAll();
|
|
445
445
|
}
|
|
446
|
+
/** 覆盖层拖拽会话交互标记(批次 386,蒙版工具栏把手拖图「不跟手」刀一):
|
|
447
|
+
* DOM 层把手拖拽(蒙版中心/旋转/缩放把手族)每个拖拽事件调用——k 档
|
|
448
|
+
* settle 补帧在此期间保持 stale 让路(SceneRenderer.noteExternalInteraction
|
|
449
|
+
* 头注的实测数据与语义)。不写 vpt、不触 hit 带、不请求渲染(调用方属性
|
|
450
|
+
* 写自带);settle 定时器停手 160ms 后自动补一帧收尾 */
|
|
451
|
+
noteExternalGesture() {
|
|
452
|
+
this.renderer.noteExternalInteraction();
|
|
453
|
+
}
|
|
446
454
|
/** rAF 合并渲染请求(fabric requestRenderAll 同语义)+ rAF 饥饿超时兜底。
|
|
447
455
|
* 批次 44:失焦/被遮挡的内嵌浏览器窗格(IAB webview)实测 visibility 仍报
|
|
448
456
|
* 'visible' 但 rAF 永不回调——字体迟到自愈等「排帧后无人再触发」的补帧会
|
package/dist/debug/seed.d.ts
CHANGED
|
@@ -78,7 +78,8 @@ export declare const makeFilterImageScene: () => SerializedNode[];
|
|
|
78
78
|
* 随字号增大而稀释)。覆盖:硬换行、自动换行、center/right、charSpacing、
|
|
79
79
|
* 多行 lineHeight、无换行 text 类型;P2-2 增补:逐字 fontSize/fontFamily
|
|
80
80
|
* 混排(t7 换行度量 + t8 无换行);justify 增补:t9 纯 justify 多行拉伸
|
|
81
|
-
*
|
|
81
|
+
* (段末行照拉、末行豁免——产品 fork 口径,末行为单词行两侧都拉不动)、
|
|
82
|
+
* t10 justify-center 段末行居中收尾 + CJK 行不拉伸(变体恒空格粒度)。
|
|
82
83
|
*/
|
|
83
84
|
export declare const makeTextScene: () => SerializedNode[];
|
|
84
85
|
/**
|
package/dist/debug/seed.js
CHANGED
|
@@ -410,7 +410,8 @@ export const makeFilterImageScene = () => {
|
|
|
410
410
|
* 随字号增大而稀释)。覆盖:硬换行、自动换行、center/right、charSpacing、
|
|
411
411
|
* 多行 lineHeight、无换行 text 类型;P2-2 增补:逐字 fontSize/fontFamily
|
|
412
412
|
* 混排(t7 换行度量 + t8 无换行);justify 增补:t9 纯 justify 多行拉伸
|
|
413
|
-
*
|
|
413
|
+
* (段末行照拉、末行豁免——产品 fork 口径,末行为单词行两侧都拉不动)、
|
|
414
|
+
* t10 justify-center 段末行居中收尾 + CJK 行不拉伸(变体恒空格粒度)。
|
|
414
415
|
*/
|
|
415
416
|
export const makeTextScene = () => {
|
|
416
417
|
const base = {
|
|
@@ -600,10 +601,12 @@ export const makeTextScene = () => {
|
|
|
600
601
|
left: 80,
|
|
601
602
|
top: 760,
|
|
602
603
|
width: 400,
|
|
603
|
-
// 两端对齐(fabric enlargeSpaces
|
|
604
|
-
//
|
|
605
|
-
//
|
|
606
|
-
|
|
604
|
+
// 两端对齐(fabric enlargeSpaces 同源 + 产品 fork 口径 2026-10-14):多行
|
|
605
|
+
// 词隙拉伸、段末行照拉、纯 justify 只豁免最后一行(编辑器 fork;fabric
|
|
606
|
+
// 上游含末行全拉——两侧在此分道)。末行故意用单词行(无空格可拉)+ 硬换行
|
|
607
|
+
// 隔出段末行,两档豁免/照拉在台面上一眼可辨;fabric 对拍面已退役(批次
|
|
608
|
+
// 275),语义由 textLayout.spec 注入度量锁
|
|
609
|
+
text: 'The quick brown fox jumps over the lazy dog\nwrapword.',
|
|
607
610
|
fontFamily: 'serif',
|
|
608
611
|
fontSize: 40,
|
|
609
612
|
lineHeight: 1.25,
|
package/dist/engineFlag.d.ts
CHANGED
|
@@ -64,6 +64,18 @@ export declare const isRetainedDebugEnabled: () => boolean;
|
|
|
64
64
|
* **默认开**;一键退 = ?sdfDash=0 / localStorage('engine.sdfDash'='0')——
|
|
65
65
|
* 虚线 SDF vs 烘焙回落的同状态运行时 A/B 开关(像素三连拍 parity 用) */
|
|
66
66
|
export declare const isStrokeSdfDashEnabled: () => boolean;
|
|
67
|
+
/** polygon 族描边 SDF 直绘(方向三第二刀,批次 383):polygon/polyline/triangle
|
|
68
|
+
* 的描边走段表数据纹理 + 着色器段循环(join 语义 CPU 化进段数据),消灭
|
|
69
|
+
* 多边形族的烘焙回落链(零重烘零纹理预算,分辨率无关)。
|
|
70
|
+
* **默认开**;一键退 = ?sdfPolygon=0 / localStorage('engine.sdfPolygon'='0')——
|
|
71
|
+
* 段表 SDF vs 烘焙回落的同状态运行时 A/B 开关(像素三连拍 parity 用) */
|
|
72
|
+
export declare const isStrokeSdfPolygonEnabled: () => boolean;
|
|
73
|
+
/** 线族装饰 SDF 直绘(方向三,批次 388):Arrow(杆线+三角头段表填充)与
|
|
74
|
+
* Dimension(主线+端刻,文本标签桶化小烘焙)从整元素连续 k 烘焙拆解为解析式
|
|
75
|
+
* 分片——缩放零重烘(Dimension 文本仅桶边界重烘)。
|
|
76
|
+
* **默认开**;一键退 = ?sdfLineDeco=0 / localStorage('engine.sdfLineDeco'='0')——
|
|
77
|
+
* 与烘焙回落的同状态运行时 A/B 开关(像素三连拍 parity 用) */
|
|
78
|
+
export declare const isStrokeSdfLineDecorationEnabled: () => boolean;
|
|
67
79
|
/** SVG 纯数据导出(P6-5,批次 19 第一片 + 批次 24 收官):svg 导出页与素材
|
|
68
80
|
* 口径(exportMaterialSVG)走引擎序列化器(store JSON → SVG 字符串,不经
|
|
69
81
|
* 渲染器)替代 FabricStatic 2D 路径。**默认开**(2026-09-23 批次 24 切——
|
package/dist/engineFlag.js
CHANGED
|
@@ -78,6 +78,18 @@ export const isRetainedDebugEnabled = () => isOperatorFlagEnabled('retainedDebug
|
|
|
78
78
|
* **默认开**;一键退 = ?sdfDash=0 / localStorage('engine.sdfDash'='0')——
|
|
79
79
|
* 虚线 SDF vs 烘焙回落的同状态运行时 A/B 开关(像素三连拍 parity 用) */
|
|
80
80
|
export const isStrokeSdfDashEnabled = () => isOperatorFlagEnabled('sdfDash', true);
|
|
81
|
+
/** polygon 族描边 SDF 直绘(方向三第二刀,批次 383):polygon/polyline/triangle
|
|
82
|
+
* 的描边走段表数据纹理 + 着色器段循环(join 语义 CPU 化进段数据),消灭
|
|
83
|
+
* 多边形族的烘焙回落链(零重烘零纹理预算,分辨率无关)。
|
|
84
|
+
* **默认开**;一键退 = ?sdfPolygon=0 / localStorage('engine.sdfPolygon'='0')——
|
|
85
|
+
* 段表 SDF vs 烘焙回落的同状态运行时 A/B 开关(像素三连拍 parity 用) */
|
|
86
|
+
export const isStrokeSdfPolygonEnabled = () => isOperatorFlagEnabled('sdfPolygon', true);
|
|
87
|
+
/** 线族装饰 SDF 直绘(方向三,批次 388):Arrow(杆线+三角头段表填充)与
|
|
88
|
+
* Dimension(主线+端刻,文本标签桶化小烘焙)从整元素连续 k 烘焙拆解为解析式
|
|
89
|
+
* 分片——缩放零重烘(Dimension 文本仅桶边界重烘)。
|
|
90
|
+
* **默认开**;一键退 = ?sdfLineDeco=0 / localStorage('engine.sdfLineDeco'='0')——
|
|
91
|
+
* 与烘焙回落的同状态运行时 A/B 开关(像素三连拍 parity 用) */
|
|
92
|
+
export const isStrokeSdfLineDecorationEnabled = () => isOperatorFlagEnabled('sdfLineDeco', true);
|
|
81
93
|
/** SVG 纯数据导出(P6-5,批次 19 第一片 + 批次 24 收官):svg 导出页与素材
|
|
82
94
|
* 口径(exportMaterialSVG)走引擎序列化器(store JSON → SVG 字符串,不经
|
|
83
95
|
* 渲染器)替代 FabricStatic 2D 路径。**默认开**(2026-09-23 批次 24 切——
|
package/dist/export/svgExport.js
CHANGED
|
@@ -45,6 +45,7 @@ import { arcTextKind, computeArcTextLayout } from '../model/arcLayout';
|
|
|
45
45
|
import { imageCropRect, textBitmapFillAlpha, WORKSPACE_IDS } from '../model/scene';
|
|
46
46
|
import { ElementTypes, typeKeyOf, IMAGE_LIKE_TYPES, TEXT_TYPES, SOLID_TYPES, LINE_TYPES, MASK_TYPES } from '../model/elementTypes';
|
|
47
47
|
import { charJitterY, layoutTextbox, verticalAnchorShiftX, verticalAnchorShiftY, verticalCharClass, verticalRenderAdvance } from '../model/textLayout';
|
|
48
|
+
import { TextAlignValues, isJustifyFamilyAlign } from '../model/textAlign';
|
|
48
49
|
import { planTextHighlight } from '../render/textHighlight';
|
|
49
50
|
// ---- 类型集(小写键口径,批次 360:家族集合复用 model/elementTypes,细分
|
|
50
51
|
// 子集本地小写化;比较位的 type 一律 typeKeyOf(raw) 派生,双形态就地坍缩) ----
|
|
@@ -385,7 +386,7 @@ const baseTextStyle = (raw) => ({
|
|
|
385
386
|
fontStyle: raw.fontStyle ?? undefined,
|
|
386
387
|
lineHeight: raw.lineHeight ?? 1.16,
|
|
387
388
|
charSpacing: raw.charSpacing ?? 0,
|
|
388
|
-
textAlign: raw.textAlign ??
|
|
389
|
+
textAlign: raw.textAlign ?? TextAlignValues.LEFT
|
|
389
390
|
});
|
|
390
391
|
/** 逐字覆写合成(render/arcText.glyphStyleOf 同源逻辑——export 不引 render 域,内联):
|
|
391
392
|
* 字体四件套覆写 + fill 覆写,其余取对象级 */
|
|
@@ -440,21 +441,23 @@ const stylesArrayToMap = (text, styles) => {
|
|
|
440
441
|
}
|
|
441
442
|
return Object.keys(map).length > 0 ? map : undefined;
|
|
442
443
|
};
|
|
443
|
-
/** 行左偏移(fabric _getLineLeftOffset:justify 非段末行恒 0——fabric
|
|
444
|
-
|
|
445
|
-
|
|
444
|
+
/** 行左偏移(fabric _getLineLeftOffset:justify 非段末行恒 0——fabric 口径;
|
|
445
|
+
* 纯 justify 末行豁免拉伸后也恒 0(左收尾,产品 fork 口径);disperse 全行
|
|
446
|
+
* 含末行都拉恒 0——拉伸本体在 layoutGlyphAnchors 消费的 boxes 里;
|
|
447
|
+
* 谓词显式枚举——值域外怪值不入族按 left 收尾) */ const lineLeftOffset = (align, boxWidth, lineWidth, isEndOfWrapping) => {
|
|
448
|
+
const a = align ?? TextAlignValues.LEFT;
|
|
449
|
+
if (isJustifyFamilyAlign(a)) {
|
|
446
450
|
if (!isEndOfWrapping)
|
|
447
451
|
return 0;
|
|
448
|
-
|
|
449
|
-
if (tail === '-center')
|
|
452
|
+
if (a === TextAlignValues.JUSTIFY_CENTER)
|
|
450
453
|
return (boxWidth - lineWidth) / 2;
|
|
451
|
-
if (
|
|
454
|
+
if (a === TextAlignValues.JUSTIFY_RIGHT)
|
|
452
455
|
return boxWidth - lineWidth;
|
|
453
456
|
return 0;
|
|
454
457
|
}
|
|
455
|
-
if (a ===
|
|
458
|
+
if (a === TextAlignValues.CENTER)
|
|
456
459
|
return (boxWidth - lineWidth) / 2;
|
|
457
|
-
if (a ===
|
|
460
|
+
if (a === TextAlignValues.RIGHT)
|
|
458
461
|
return boxWidth - lineWidth;
|
|
459
462
|
return 0;
|
|
460
463
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export { EngineDocument, type EngineDocumentEvents, type IndexedItem, type Selec
|
|
|
30
30
|
* 主仓 @/types/elements 的 ElementNames 即本导出的别名(引擎=渲染权限守门人,
|
|
31
31
|
* 类型词汇的单一事实源在引擎,新增元素类型须先在此登记可渲染) */
|
|
32
32
|
export { ElementTypes, typeKeyOf, TEXT_TYPES, SHAPE_TYPES, LINE_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES, type ElementTypeKey } from './model/elementTypes';
|
|
33
|
+
/** 文本对齐值域(ElementTypes 同款词汇表架构,批次 390 后记):引擎=渲染守门人,
|
|
34
|
+
* 对齐值域/谓词的单一事实源在引擎,主仓/其他项目 re-export 消费(类型面随发版
|
|
35
|
+
* 升版对齐——「引擎改签名未发版」窗口内主仓 vue-tsc 吃 dist .d.ts 尚不可见) */
|
|
36
|
+
export { TextAlignValues, TEXT_ALIGN_VALUES, isJustifyFamilyAlign, isJustifyVariantAlign, isStretchAlign, type TextAlignValue } from './model/textAlign';
|
|
33
37
|
export { buildScene, loadImageElement, IMAGE_LIKE_TYPES, SOLID_TYPES, MASK_TYPES, createNode, isTextBitmapState, textBitmapFillAlpha, SceneNode, TextNode, ShapeNode, PathNode, LineNode, GroupNode, MaskNode, PuzzleNode, TableNode, AnimatedNode, type SerializedNode } from './model/scene';
|
|
34
38
|
export { SvgExporter, serializePageToSvg, buildTextGlyphPathData, type SvgPageRequest, type SvgPageOptions, type SvgPageResult, type SvgExporterOptions, type SvgViewBox, type SvgFontResolver, type SvgGlyphFont, type SvgGlyphCommand, type SvgMeasureFn, type SvgTextBitmap, type SvgTextBitmapBaker, type SvgTextBitmapFamily } from './export/svgExport';
|
|
35
39
|
export { parsePathData, getBoundsOfPath, type PathCommand } from './core/pathData';
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,10 @@ export { EngineDocument } from './model/document';
|
|
|
34
34
|
* 主仓 @/types/elements 的 ElementNames 即本导出的别名(引擎=渲染权限守门人,
|
|
35
35
|
* 类型词汇的单一事实源在引擎,新增元素类型须先在此登记可渲染) */
|
|
36
36
|
export { ElementTypes, typeKeyOf, TEXT_TYPES, SHAPE_TYPES, LINE_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES } from './model/elementTypes';
|
|
37
|
+
/** 文本对齐值域(ElementTypes 同款词汇表架构,批次 390 后记):引擎=渲染守门人,
|
|
38
|
+
* 对齐值域/谓词的单一事实源在引擎,主仓/其他项目 re-export 消费(类型面随发版
|
|
39
|
+
* 升版对齐——「引擎改签名未发版」窗口内主仓 vue-tsc 吃 dist .d.ts 尚不可见) */
|
|
40
|
+
export { TextAlignValues, TEXT_ALIGN_VALUES, isJustifyFamilyAlign, isJustifyVariantAlign, isStretchAlign } from './model/textAlign';
|
|
37
41
|
export { buildScene, loadImageElement, IMAGE_LIKE_TYPES, SOLID_TYPES, MASK_TYPES, createNode, isTextBitmapState, textBitmapFillAlpha, SceneNode, TextNode, ShapeNode, PathNode, LineNode, GroupNode, MaskNode, PuzzleNode, TableNode, AnimatedNode } from './model/scene';
|
|
38
42
|
export { SvgExporter, serializePageToSvg, buildTextGlyphPathData } from './export/svgExport';
|
|
39
43
|
export { parsePathData, getBoundsOfPath } from './core/pathData';
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { TextNode } from '../model/scene';
|
|
24
24
|
import { getCellData, masterPosition } from '../model/tableEdit';
|
|
25
|
+
import { TextAlignValues } from '../model/textAlign';
|
|
25
26
|
/** 应用 TableDefaultOptions.fontSize(tableLayout 的 CONSTRUCTOR_FONT_SIZE 同源) */
|
|
26
27
|
const DEFAULT_FONT_SIZE = 14;
|
|
27
28
|
/** 应用 Table.defaults.fontFamily(fromObject 不透传——表格级恒为应用默认) */
|
|
@@ -106,7 +107,7 @@ export class TableCellEditingController {
|
|
|
106
107
|
fontWeight: data?.fontWeight,
|
|
107
108
|
fontStyle: data?.fontStyle,
|
|
108
109
|
fontFamily: data?.fontFamily || tableFontFamilyOf(raw),
|
|
109
|
-
textAlign: data?.textAlign ??
|
|
110
|
+
textAlign: data?.textAlign ?? TextAlignValues.CENTER,
|
|
110
111
|
lineHeight: 1.16,
|
|
111
112
|
splitByGrapheme: true,
|
|
112
113
|
opacity: 1,
|
package/dist/model/scene.d.ts
CHANGED
|
@@ -322,7 +322,7 @@ export declare class TextNode extends SceneNode {
|
|
|
322
322
|
setScrollOffset(offset: number): void;
|
|
323
323
|
/**
|
|
324
324
|
* 文本整块宽(应用 calcTextWidth 口径——ScrollText.calcTextTotalWidth 消费):
|
|
325
|
-
* 横排 = max(__lineWidths) 最长自然行宽(justify 拉伸不进,line.width 双口径);
|
|
325
|
+
* 横排 = max(__lineWidths) 最长自然行宽(justify/disperse 拉伸不进,line.width 双口径);
|
|
326
326
|
* 竖排 = 应用 Textbox 覆写分支(逐字累加的双重 spacing quirk + cursorWidth(2),
|
|
327
327
|
* 与盒宽无关——boxWidth 存在时布局盒宽不走该式而本值仍须用它)。
|
|
328
328
|
* 滚动循环距离 = 本值 + 视口宽(getScrollTextDuration 同式)。
|
package/dist/model/scene.js
CHANGED
|
@@ -54,6 +54,7 @@ export const WORKSPACE_IDS = new Set(['WorkSpaceDrawType', 'WorkSpaceClipType',
|
|
|
54
54
|
* 与家族语义见该模块。此处 re-export 维持既有消费面导入路径不变 */
|
|
55
55
|
export { ElementTypes, typeKeyOf, TEXT_TYPES, IMAGE_LIKE_TYPES, SOLID_TYPES, SHAPE_TYPES, LINE_TYPES, MASK_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES } from './elementTypes';
|
|
56
56
|
import { ElementTypes, GIF_TYPES, VIDEO_TYPES, typeKeyOf, TEXT_TYPES, IMAGE_LIKE_TYPES, SOLID_TYPES, SHAPE_TYPES, LINE_TYPES, MASK_TYPES, PUZZLE_TYPES } from './elementTypes';
|
|
57
|
+
import { TextAlignValues } from './textAlign';
|
|
57
58
|
/** 批次 314 图片文字:TextImage 位图态判定(raw.renderSrc 在场)——渲染/命中/
|
|
58
59
|
* 手柄/组语义全按图片口径(缩放手势走 scale、不做文本烘焙);转正(renderSrc
|
|
59
60
|
* 删除)后按文本口径(盒宽/字号烘焙、组改宽回流) */
|
|
@@ -669,7 +670,7 @@ export class TextNode extends SceneNode {
|
|
|
669
670
|
fontStyle: raw.fontStyle,
|
|
670
671
|
lineHeight: raw.lineHeight ?? 1.16,
|
|
671
672
|
charSpacing: raw.charSpacing ?? 0,
|
|
672
|
-
textAlign: raw.textAlign ??
|
|
673
|
+
textAlign: raw.textAlign ?? TextAlignValues.LEFT
|
|
673
674
|
};
|
|
674
675
|
}
|
|
675
676
|
/**
|
|
@@ -743,7 +744,7 @@ export class TextNode extends SceneNode {
|
|
|
743
744
|
}
|
|
744
745
|
/**
|
|
745
746
|
* 文本整块宽(应用 calcTextWidth 口径——ScrollText.calcTextTotalWidth 消费):
|
|
746
|
-
* 横排 = max(__lineWidths) 最长自然行宽(justify 拉伸不进,line.width 双口径);
|
|
747
|
+
* 横排 = max(__lineWidths) 最长自然行宽(justify/disperse 拉伸不进,line.width 双口径);
|
|
747
748
|
* 竖排 = 应用 Textbox 覆写分支(逐字累加的双重 spacing quirk + cursorWidth(2),
|
|
748
749
|
* 与盒宽无关——boxWidth 存在时布局盒宽不走该式而本值仍须用它)。
|
|
749
750
|
* 滚动循环距离 = 本值 + 视口宽(getScrollTextDuration 同式)。
|
|
@@ -904,7 +905,7 @@ export class TextNode extends SceneNode {
|
|
|
904
905
|
}
|
|
905
906
|
}
|
|
906
907
|
const line = layout.lines[target];
|
|
907
|
-
// 行末端点用哨兵盒口径(末盒 left+width,含行尾 charSpacing、justify 拉伸
|
|
908
|
+
// 行末端点用哨兵盒口径(末盒 left+width,含行尾 charSpacing、justify/disperse 拉伸
|
|
908
909
|
// 末端)——fabric _measureLine 行末哨兵盒同语义,勿用 line.width(自然行宽)
|
|
909
910
|
const x = -layout.width / 2 + line.leftOffset + (charInLine < line.boxes.length ? line.boxes[charInLine].left : lineEndOffset(line));
|
|
910
911
|
// 坐标系统一为中心系(与字形/选区高亮的矩阵消费一致):历史上这里返回
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { FONT_SIZE_MULT, layoutTextbox } from './textLayout';
|
|
26
26
|
import { buildCellMap } from './tableEdit';
|
|
27
|
+
import { TextAlignValues } from './textAlign';
|
|
27
28
|
/** 应用 TableDefaultOptions.fontSize——fromObject 不透传 fontSize,构造期空单元格
|
|
28
29
|
* 以它度量行高(摆位 quirk 的 h0 依赖;应用默认值变更时须同步此处) */
|
|
29
30
|
const CONSTRUCTOR_FONT_SIZE = 14;
|
|
@@ -84,7 +85,7 @@ export const computeTableLayout = (raw, measure, opts) => {
|
|
|
84
85
|
fontStyle: data.fontStyle,
|
|
85
86
|
lineHeight: 1.16,
|
|
86
87
|
charSpacing: 0,
|
|
87
|
-
textAlign: data.textAlign ??
|
|
88
|
+
textAlign: data.textAlign ?? TextAlignValues.CENTER
|
|
88
89
|
}, { boxWidth: textWidth, splitByGrapheme: true, measure }),
|
|
89
90
|
data
|
|
90
91
|
});
|
|
@@ -167,7 +168,7 @@ export const computeTableLayout = (raw, measure, opts) => {
|
|
|
167
168
|
fontSize: data?.fontSize ?? CONSTRUCTOR_FONT_SIZE,
|
|
168
169
|
fontWeight: data?.fontWeight,
|
|
169
170
|
fontStyle: data?.fontStyle,
|
|
170
|
-
textAlign: data?.textAlign ??
|
|
171
|
+
textAlign: data?.textAlign ?? TextAlignValues.CENTER,
|
|
171
172
|
lineHeight: 1.16,
|
|
172
173
|
splitByGrapheme: true,
|
|
173
174
|
originX: 'center',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本对齐值域(vocabulary——ElementTypes 同款架构:引擎=渲染守门人,值域在
|
|
3
|
+
* 引擎定义、主仓/其他项目 re-export 消费,批次 390 后记)。判断位(===/
|
|
4
|
+
* startsWith/includes/switch)一律走本模块常量与谓词,不得新增裸字符串判断;
|
|
5
|
+
* 数据层兜底(?? 默认值)同源用常量。**排除域**:2D canvas 的 `ctx.textAlign`
|
|
6
|
+
* 是 DOM API 自有枚举(同值不同域,ElementNames 排除域同款纪律),不在此列。
|
|
7
|
+
*
|
|
8
|
+
* 值域八值:left/center/right + justify 全家(纯 justify=只豁末行、justify-left/
|
|
9
|
+
* center/right 变体=段末豁免+行偏移收尾)+ disperse 分散对齐(全行含末行都拉)。
|
|
10
|
+
* 语义矩阵见 textLayout stretch 块头注;分布粒度(CJK 逐字/拉丁空格)见
|
|
11
|
+
* CJK_LINE_RE。谓词为**显式枚举**(非前缀匹配)——值域外的怪值(如 'justify-foo')
|
|
12
|
+
* 不入族、按 left 渲染,词汇表语义即从严。
|
|
13
|
+
*/
|
|
14
|
+
/** 文本对齐值域常量(judgment 用;值即序列化存储形) */
|
|
15
|
+
export declare const TextAlignValues: {
|
|
16
|
+
readonly LEFT: "left";
|
|
17
|
+
readonly CENTER: "center";
|
|
18
|
+
readonly RIGHT: "right";
|
|
19
|
+
readonly JUSTIFY: "justify";
|
|
20
|
+
readonly JUSTIFY_LEFT: "justify-left";
|
|
21
|
+
readonly JUSTIFY_CENTER: "justify-center";
|
|
22
|
+
readonly JUSTIFY_RIGHT: "justify-right";
|
|
23
|
+
readonly DISPERSE: "disperse";
|
|
24
|
+
};
|
|
25
|
+
export type TextAlignValue = (typeof TextAlignValues)[keyof typeof TextAlignValues];
|
|
26
|
+
/**
|
|
27
|
+
* 白名单清单(面板/chat 合法枚举的消费面;chat 面板按后端口径取其中五值子集)。
|
|
28
|
+
* string[] 而非 const 值域数组——后者在 includes(string) 入参处触发不变性拒绝
|
|
29
|
+
* (ElementTypes 同坑,主仓 AGENTS「Known pits」在案)。
|
|
30
|
+
*/
|
|
31
|
+
export declare const TEXT_ALIGN_VALUES: string[];
|
|
32
|
+
/** justify 家族(纯 justify + 三变体)——空格加宽与段末行豁免机制的适用域 */
|
|
33
|
+
export declare const isJustifyFamilyAlign: (a: unknown) => a is TextAlignValue;
|
|
34
|
+
/** justify-left/center/right 变体——段末行+末行豁免,left/center/right 行偏移收尾 */
|
|
35
|
+
export declare const isJustifyVariantAlign: (a: unknown) => a is TextAlignValue;
|
|
36
|
+
/** 纯拉伸档(纯 justify | disperse)——CJK 行逐字分布适用 + fork 末行豁免矩阵 */
|
|
37
|
+
export declare const isStretchAlign: (a: unknown) => boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本对齐值域(vocabulary——ElementTypes 同款架构:引擎=渲染守门人,值域在
|
|
3
|
+
* 引擎定义、主仓/其他项目 re-export 消费,批次 390 后记)。判断位(===/
|
|
4
|
+
* startsWith/includes/switch)一律走本模块常量与谓词,不得新增裸字符串判断;
|
|
5
|
+
* 数据层兜底(?? 默认值)同源用常量。**排除域**:2D canvas 的 `ctx.textAlign`
|
|
6
|
+
* 是 DOM API 自有枚举(同值不同域,ElementNames 排除域同款纪律),不在此列。
|
|
7
|
+
*
|
|
8
|
+
* 值域八值:left/center/right + justify 全家(纯 justify=只豁末行、justify-left/
|
|
9
|
+
* center/right 变体=段末豁免+行偏移收尾)+ disperse 分散对齐(全行含末行都拉)。
|
|
10
|
+
* 语义矩阵见 textLayout stretch 块头注;分布粒度(CJK 逐字/拉丁空格)见
|
|
11
|
+
* CJK_LINE_RE。谓词为**显式枚举**(非前缀匹配)——值域外的怪值(如 'justify-foo')
|
|
12
|
+
* 不入族、按 left 渲染,词汇表语义即从严。
|
|
13
|
+
*/
|
|
14
|
+
/** 文本对齐值域常量(judgment 用;值即序列化存储形) */
|
|
15
|
+
export const TextAlignValues = {
|
|
16
|
+
LEFT: 'left',
|
|
17
|
+
CENTER: 'center',
|
|
18
|
+
RIGHT: 'right',
|
|
19
|
+
JUSTIFY: 'justify',
|
|
20
|
+
JUSTIFY_LEFT: 'justify-left',
|
|
21
|
+
JUSTIFY_CENTER: 'justify-center',
|
|
22
|
+
JUSTIFY_RIGHT: 'justify-right',
|
|
23
|
+
DISPERSE: 'disperse'
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* 白名单清单(面板/chat 合法枚举的消费面;chat 面板按后端口径取其中五值子集)。
|
|
27
|
+
* string[] 而非 const 值域数组——后者在 includes(string) 入参处触发不变性拒绝
|
|
28
|
+
* (ElementTypes 同坑,主仓 AGENTS「Known pits」在案)。
|
|
29
|
+
*/
|
|
30
|
+
export const TEXT_ALIGN_VALUES = Object.values(TextAlignValues);
|
|
31
|
+
/** justify 家族(纯 justify + 三变体)——空格加宽与段末行豁免机制的适用域 */
|
|
32
|
+
export const isJustifyFamilyAlign = (a) => a === TextAlignValues.JUSTIFY || a === TextAlignValues.JUSTIFY_LEFT || a === TextAlignValues.JUSTIFY_CENTER || a === TextAlignValues.JUSTIFY_RIGHT;
|
|
33
|
+
/** justify-left/center/right 变体——段末行+末行豁免,left/center/right 行偏移收尾 */
|
|
34
|
+
export const isJustifyVariantAlign = (a) => a === TextAlignValues.JUSTIFY_LEFT || a === TextAlignValues.JUSTIFY_CENTER || a === TextAlignValues.JUSTIFY_RIGHT;
|
|
35
|
+
/** 纯拉伸档(纯 justify | disperse)——CJK 行逐字分布适用 + fork 末行豁免矩阵 */
|
|
36
|
+
export const isStretchAlign = (a) => a === TextAlignValues.JUSTIFY || a === TextAlignValues.DISPERSE;
|
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
* 装饰线(P2-4):underline/overline/linethrough 不进度量,渲染侧由
|
|
26
26
|
* lineDecorationRuns 按 fabric _renderTextDecoration 的 run 状态机产出线段 quad;
|
|
27
27
|
* 颜色逐字跟 fill(fabric ctx.fillStyle = getValueOfPropertyAt(FILL) 同语义)。
|
|
28
|
-
* Phase 2a 范围注记:ltr 子集(rtl 反向对齐不做);justify
|
|
29
|
-
*
|
|
30
|
-
* justify-left/center/right
|
|
31
|
-
*
|
|
28
|
+
* Phase 2a 范围注记:ltr 子集(rtl 反向对齐不做);justify 全家 + disperse
|
|
29
|
+
* 分散对齐已实现(enlargeSpaces 移植 + 编辑器 fork 口径:空格均摊加宽 +
|
|
30
|
+
* 字符盒平移,纯 justify 只豁免末行、justify-left/center/right 变体段末行
|
|
31
|
+
* 豁免并按对应方式收尾、disperse 全行含末行都拉、CJK 行逐字分布——详见
|
|
32
|
+
* stretch 块头注),grapheme 切分用码点级(CJK/拉丁与 fabric 一致,
|
|
33
|
+
* emoji 簇差异已知,后续对齐)。
|
|
32
34
|
* splitByGrapheme(P4-4 表格单元格模式):LayoutOptions.splitByGrapheme ——
|
|
33
35
|
* 词=单字素、无 infix 空格、样式映射不吃空格(fabric 三处守卫逐条对齐)。
|
|
34
36
|
* 竖排(P4-5c):LayoutOptions.vertical —— 应用 Textbox vertical:true 的
|
|
@@ -203,6 +205,11 @@ export interface TextStrokeDecl {
|
|
|
203
205
|
export declare const resolveStrokeDecl: (base: TextStrokeDecl | null, o?: CharStyleOverride) => TextStrokeDecl | null;
|
|
204
206
|
/** 装饰线三类型(fabric _renderTextDecoration 的三趟 pass) */
|
|
205
207
|
export type TextDecorationType = 'underline' | 'overline' | 'linethrough';
|
|
208
|
+
/** 行内 CJK 判定(编辑器 Textbox.enlargeSpaces fork 的 cjkRegex 原样:Han 统一
|
|
209
|
+
* 表意 + 平假名 + 片假名 + 谚文音节;扩展区/兼容区不在此列——fork 口径原样保留)。
|
|
210
|
+
* 纯 justify/disperse 的 CJK 行按逐字分布拉伸;渲染侧 run 断段(dash 描边/
|
|
211
|
+
* scrollText)同源判定逐字断段。 */
|
|
212
|
+
export declare const CJK_LINE_RE: RegExp;
|
|
206
213
|
/**
|
|
207
214
|
* 行末 x(相对行首):fabric `_measureLine` 的**行末哨兵盒**口径 =
|
|
208
215
|
* 末字符盒 left + width(width 含行尾 charSpacing)。justify 拉伸行的空格
|
package/dist/model/textLayout.js
CHANGED
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
* 装饰线(P2-4):underline/overline/linethrough 不进度量,渲染侧由
|
|
26
26
|
* lineDecorationRuns 按 fabric _renderTextDecoration 的 run 状态机产出线段 quad;
|
|
27
27
|
* 颜色逐字跟 fill(fabric ctx.fillStyle = getValueOfPropertyAt(FILL) 同语义)。
|
|
28
|
-
* Phase 2a 范围注记:ltr 子集(rtl 反向对齐不做);justify
|
|
29
|
-
*
|
|
30
|
-
* justify-left/center/right
|
|
31
|
-
*
|
|
28
|
+
* Phase 2a 范围注记:ltr 子集(rtl 反向对齐不做);justify 全家 + disperse
|
|
29
|
+
* 分散对齐已实现(enlargeSpaces 移植 + 编辑器 fork 口径:空格均摊加宽 +
|
|
30
|
+
* 字符盒平移,纯 justify 只豁免末行、justify-left/center/right 变体段末行
|
|
31
|
+
* 豁免并按对应方式收尾、disperse 全行含末行都拉、CJK 行逐字分布——详见
|
|
32
|
+
* stretch 块头注),grapheme 切分用码点级(CJK/拉丁与 fabric 一致,
|
|
33
|
+
* emoji 簇差异已知,后续对齐)。
|
|
32
34
|
* splitByGrapheme(P4-4 表格单元格模式):LayoutOptions.splitByGrapheme ——
|
|
33
35
|
* 词=单字素、无 infix 空格、样式映射不吃空格(fabric 三处守卫逐条对齐)。
|
|
34
36
|
* 竖排(P4-5c):LayoutOptions.vertical —— 应用 Textbox vertical:true 的
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
* 加 space;换行判定轴不覆写(fabric 原样近似)。
|
|
40
42
|
* 布局级 parity 由 e2e 直接对比 fabric Textbox 的 _textLines/__lineWidths/height。
|
|
41
43
|
*/
|
|
44
|
+
import { TextAlignValues, isJustifyFamilyAlign, isJustifyVariantAlign } from './textAlign';
|
|
42
45
|
/** fabric CACHE_FONT_SIZE:所有字体度量在固定字号下做缓存 */
|
|
43
46
|
export const CACHE_FONT_SIZE = 400;
|
|
44
47
|
/** fabric _fontSizeMult:行高实现值 = max(fontSize) × 1.13 */
|
|
@@ -292,6 +295,11 @@ export const resolveStrokeDecl = (base, o) => {
|
|
|
292
295
|
lineCap: base?.lineCap
|
|
293
296
|
};
|
|
294
297
|
};
|
|
298
|
+
/** 行内 CJK 判定(编辑器 Textbox.enlargeSpaces fork 的 cjkRegex 原样:Han 统一
|
|
299
|
+
* 表意 + 平假名 + 片假名 + 谚文音节;扩展区/兼容区不在此列——fork 口径原样保留)。
|
|
300
|
+
* 纯 justify/disperse 的 CJK 行按逐字分布拉伸;渲染侧 run 断段(dash 描边/
|
|
301
|
+
* scrollText)同源判定逐字断段。 */
|
|
302
|
+
export const CJK_LINE_RE = /[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/;
|
|
295
303
|
/**
|
|
296
304
|
* 行末 x(相对行首):fabric `_measureLine` 的**行末哨兵盒**口径 =
|
|
297
305
|
* 末字符盒 left + width(width 含行尾 charSpacing)。justify 拉伸行的空格
|
|
@@ -743,7 +751,7 @@ export const layoutTextbox = (text, style, options = {}) => {
|
|
|
743
751
|
};
|
|
744
752
|
const verticalWidth = options.vertical ? verticalCalcWidth() : undefined;
|
|
745
753
|
const boxW = options.boxWidth != null ? expandedBoxWidth : options.vertical ? verticalWidth : Math.max(0, ...lines.map((l) => l.width));
|
|
746
|
-
const align = style.textAlign ??
|
|
754
|
+
const align = style.textAlign ?? TextAlignValues.LEFT;
|
|
747
755
|
// 段末行判定(fabric Textbox.isEndOfWrapping:下一视觉行已属新原始行即段末;
|
|
748
756
|
// text/itext 无自动换行,fabric Text.isEndOfWrapping 只认最后一行)
|
|
749
757
|
const isEndOfWrapping = (i) => {
|
|
@@ -753,8 +761,8 @@ export const layoutTextbox = (text, style, options = {}) => {
|
|
|
753
761
|
return !next || next.line !== lines[i].styleMap.line;
|
|
754
762
|
};
|
|
755
763
|
for (let i = 0; i < lines.length; i++) {
|
|
756
|
-
const centerish = align ===
|
|
757
|
-
const rightish = align ===
|
|
764
|
+
const centerish = align === TextAlignValues.CENTER || (align === TextAlignValues.JUSTIFY_CENTER && isEndOfWrapping(i));
|
|
765
|
+
const rightish = align === TextAlignValues.RIGHT || (align === TextAlignValues.JUSTIFY_RIGHT && isEndOfWrapping(i));
|
|
758
766
|
// P4-5c 补丁(2026-09-20,仅 webgl2 引擎侧——登记为有意偏差):竖排
|
|
759
767
|
// center/right 的对齐量改按渲染链墨迹口径(verticalLineInkRun)。应用侧
|
|
760
768
|
// fabric 以度量列长收边(_measureLine 竖排 CJK=盒高、不含 charSpacing),
|
|
@@ -775,38 +783,50 @@ export const layoutTextbox = (text, style, options = {}) => {
|
|
|
775
783
|
lines[i].leftOffset = diff;
|
|
776
784
|
}
|
|
777
785
|
}
|
|
778
|
-
//
|
|
779
|
-
//
|
|
780
|
-
// __charBounds
|
|
781
|
-
// line.width 保持自然行宽(fabric
|
|
782
|
-
//
|
|
783
|
-
//
|
|
784
|
-
//
|
|
785
|
-
//
|
|
786
|
-
//
|
|
787
|
-
|
|
786
|
+
// 两端/分散对齐(fabric enlargeSpaces 移植 + 编辑器 fork 口径 a7e9b58cd):
|
|
787
|
+
// 把 (盒宽 − 自然行宽) 均摊进行内可拉单元的 width/kernedWidth 并平移后续
|
|
788
|
+
// 字符盒 left——fabric 在度量后直接改 __charBounds,渲染/光标/选区/装饰线
|
|
789
|
+
// 全部随盒生效,引擎同口径改 boxes。line.width 保持自然行宽(fabric
|
|
790
|
+
// __lineWidths 不被 enlargeSpaces 触碰,布局对拍口径);行末端点(光标/
|
|
791
|
+
// 选区)用 lineEndOffset 的哨兵盒口径,末盒被同步平移/加宽后即落在拉伸末端。
|
|
792
|
+
// 行豁免矩阵(编辑器 Textbox.enlargeSpaces fork;2026-10-14 引擎从「fabric
|
|
793
|
+
// 上游含末行全拉」对齐到产品口径——产品编辑器的纯 justify 从不拉末行):
|
|
794
|
+
// - 纯 'justify':只豁免最后一行(段末行照拉)
|
|
795
|
+
// - 'justify-left/center/right' 变体:跳过段末行+末行,由上面的行偏移收尾
|
|
796
|
+
// - 'disperse'(分散对齐):全部行含末行都拉(fork 无豁免)
|
|
797
|
+
// 分布粒度(纯 justify/disperse 共用,fork 的 cjkRegex 分路;变体恒空格
|
|
798
|
+
// 粒度——fork 变体走 super.enlargeSpaces):行内含 CJK(CJK_LINE_RE)→
|
|
799
|
+
// 逐字分布,slack 均摊进 (n−1) 个字间隙,每字加宽、末字只平移不加宽(首尾
|
|
800
|
+
// 两缘恰好贴盒;fork 按 UTF-16 split('') 计数,引擎按 grapheme 计数,代理
|
|
801
|
+
// 对行的计数更准,属登记偏差);无 CJK → 只加宽空格(fabric 原生,行内
|
|
802
|
+
// 无空格或行宽已达盒宽不拉伸)。竖排不拉伸(编辑器 verticaltext mixin
|
|
803
|
+
// 从不消费对齐拉伸;竖排 left/center/right 行偏移不受影响)。
|
|
804
|
+
const disperse = align === TextAlignValues.DISPERSE;
|
|
805
|
+
if ((isJustifyFamilyAlign(align) || disperse) && !options.vertical) {
|
|
788
806
|
for (let i = 0; i < lines.length; i++) {
|
|
789
807
|
const line = lines[i];
|
|
790
|
-
|
|
808
|
+
const variant = isJustifyVariantAlign(align);
|
|
809
|
+
if (variant && (i === lines.length - 1 || isEndOfWrapping(i)))
|
|
810
|
+
continue;
|
|
811
|
+
if (!variant && !disperse && i === lines.length - 1)
|
|
791
812
|
continue;
|
|
792
813
|
if (line.width >= boxW)
|
|
793
814
|
continue;
|
|
794
|
-
const
|
|
795
|
-
|
|
815
|
+
const charWise = !variant && line.graphemes.some((g) => CJK_LINE_RE.test(g));
|
|
816
|
+
const slots = charWise ? line.graphemes.length - 1 : line.graphemes.reduce((n, g) => (/[ \t\r]/.test(g) ? n + 1 : n), 0);
|
|
817
|
+
if (slots <= 0)
|
|
796
818
|
continue;
|
|
797
|
-
const diffSpace = (boxW - line.width) /
|
|
819
|
+
const diffSpace = (boxW - line.width) / slots;
|
|
798
820
|
let accumulated = 0;
|
|
799
821
|
for (let j = 0; j < line.graphemes.length; j++) {
|
|
800
822
|
const box = line.boxes[j];
|
|
801
|
-
|
|
823
|
+
const stretchThis = charWise ? j < line.graphemes.length - 1 : /[ \t\r]/.test(line.graphemes[j]);
|
|
824
|
+
box.left += accumulated;
|
|
825
|
+
if (stretchThis) {
|
|
802
826
|
box.width += diffSpace;
|
|
803
827
|
box.kernedWidth += diffSpace;
|
|
804
|
-
box.left += accumulated;
|
|
805
828
|
accumulated += diffSpace;
|
|
806
829
|
}
|
|
807
|
-
else {
|
|
808
|
-
box.left += accumulated;
|
|
809
|
-
}
|
|
810
830
|
}
|
|
811
831
|
}
|
|
812
832
|
}
|
|
@@ -13,6 +13,7 @@ import type { Mat } from '../core/mat2d';
|
|
|
13
13
|
import type { RGBA } from '../core/color';
|
|
14
14
|
import type { BatchOrder } from './batchOrder';
|
|
15
15
|
import { type PaintDrawParams } from './gradientRamp';
|
|
16
|
+
import { type StrokeSdfSegments } from './segmentTable';
|
|
16
17
|
/** 延迟 draw 命令(批次 221):deferDraws 下 flush 只记录进 BatchOrder 统一序列,
|
|
17
18
|
* 边界/帧尾合并上传后按序重放 */
|
|
18
19
|
export interface QuadDrawCommand {
|
|
@@ -28,7 +29,7 @@ export declare class QuadBatch {
|
|
|
28
29
|
order: BatchOrder | null;
|
|
29
30
|
/** owner → 已在 GPU 缓冲的实例落位(批次 212 增量上传):同偏移同内容即净段 */
|
|
30
31
|
private gpuRecords;
|
|
31
|
-
/** owner → 上次写入的实例数据块(批次 212):matrix/dims/uv/color/radius/dash 全等即 memcpy */
|
|
32
|
+
/** owner → 上次写入的实例数据块(批次 212):matrix/dims/uv/color/radius/dash/seg(hash) 全等即 memcpy */
|
|
32
33
|
private ownerBlocks;
|
|
33
34
|
/** 自上次 flush 起新入的段(owner 落位记录的消费单元;deferDraws 下跨命令累积) */
|
|
34
35
|
private pendingSegments;
|
|
@@ -49,6 +50,9 @@ export declare class QuadBatch {
|
|
|
49
50
|
private instanceData;
|
|
50
51
|
/** 白色 1x1 纹理:纯色 quad 的采样源 */
|
|
51
52
|
private whiteTexture;
|
|
53
|
+
/** 段表数据纹理(方向三第二刀):行=实例槽位,生命周期与实例块同源(见
|
|
54
|
+
* segmentTable.ts 头注);懒建(首个段表 push 时),失败永久回落 */
|
|
55
|
+
private segmentTable;
|
|
52
56
|
private instanceCount;
|
|
53
57
|
private currentTexture;
|
|
54
58
|
/** 当前 run 的程序化填充参数(null = 纯色/纹理 run;flush 时据此绑 uPaint* uniforms) */
|
|
@@ -77,13 +81,15 @@ export declare class QuadBatch {
|
|
|
77
81
|
* 提交一个 quad。matrix 为场景系 objectOwnMatrix;dim 为 transformedDimensions。
|
|
78
82
|
* texture 传 null 时用白纹理纯色渲染。radius(批次 98 圆角,本地系 [rx, ry],
|
|
79
83
|
* 调用侧已按 fabric 口径钳制/解析)缺省直角。dash(方向三第一刀,本地系
|
|
80
|
-
* [on, cycle, phase])缺省 null=非 dash(槽位写 0,着色器跳过门)。
|
|
84
|
+
* [on, cycle, phase])缺省 null=非 dash(槽位写 0,着色器跳过门)。segments
|
|
85
|
+
* (方向三第二刀)= 段表内容(data/count/hash)——写入 aSeg 槽并把段数据
|
|
86
|
+
* 写入段表纹理行(行号=本实例槽位;同 owner 同 hash 去重,见 segmentTable)。
|
|
81
87
|
*
|
|
82
88
|
* owner(批次 212 增量上传):节点身份键——实例数据全等(matrix/dims/uv/
|
|
83
|
-
* color/radius
|
|
84
|
-
* flush 不再重传净段)。缺省恒走全量写入。
|
|
89
|
+
* color/radius/seg 内容量)且落位不变时 memcpy 复用并标段为净(帧内累积模型下
|
|
90
|
+
* 交错 flush 不再重传净段)。缺省恒走全量写入。
|
|
85
91
|
*/
|
|
86
|
-
pushQuad(matrix: Mat, dimX: number, dimY: number, color: RGBA, texture: WebGLTexture | null, uv?: [number, number, number, number], radius?: readonly [number, number] | null, owner?: object, dash?: readonly [number, number, number] | null): void;
|
|
92
|
+
pushQuad(matrix: Mat, dimX: number, dimY: number, color: RGBA, texture: WebGLTexture | null, uv?: [number, number, number, number], radius?: readonly [number, number] | null, owner?: object, dash?: readonly [number, number, number] | null, segments?: StrokeSdfSegments | null): void;
|
|
87
93
|
/**
|
|
88
94
|
* 程序化填充 quad(P3-3 渐变/图案):独立成段——出清前序 run → 压入本实例 →
|
|
89
95
|
* 立即出清,段内 uniforms(mode/inv/端点或 pattern 尺寸/填充纹理)在 flush
|
|
@@ -132,6 +138,9 @@ export declare class QuadBatch {
|
|
|
132
138
|
* 不重绑会把 mesh 顶点当实例数据读,画面整体消失) */
|
|
133
139
|
drawDeferred(cmd: QuadDrawCommand): void;
|
|
134
140
|
private grow;
|
|
141
|
+
/** 段表健康门(方向三第二刀):懒建段表并保障行容量——失败(RGBA32F 不可
|
|
142
|
+
* 用/OOM)永久 false,strokePainter 对 polygon 族回落烘焙。非段表路径零成本 */
|
|
143
|
+
canPushSegments(): boolean;
|
|
135
144
|
get drawnInstances(): number;
|
|
136
145
|
/** 本帧推入实例总量(批次 223 重落快照用) */
|
|
137
146
|
get instanceTotal(): number;
|