@visactor/vrender-core 0.16.14-alpha.5 → 0.16.14-alpha.6

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.
Files changed (45) hide show
  1. package/cjs/common/utils.d.ts +0 -1
  2. package/cjs/common/utils.js +1 -10
  3. package/cjs/common/utils.js.map +1 -1
  4. package/cjs/core/stage.d.ts +0 -1
  5. package/cjs/core/stage.js +3 -7
  6. package/cjs/core/stage.js.map +1 -1
  7. package/cjs/graphic/config.js +1 -4
  8. package/cjs/graphic/config.js.map +1 -1
  9. package/cjs/graphic/richtext/paragraph.js +11 -12
  10. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  11. package/cjs/graphic/text.d.ts +0 -1
  12. package/cjs/graphic/text.js +7 -93
  13. package/cjs/graphic/text.js.map +1 -1
  14. package/cjs/graphic/wrap-text.js +5 -6
  15. package/cjs/graphic/wrap-text.js.map +1 -1
  16. package/cjs/interface/graphic/richText.d.ts +1 -1
  17. package/cjs/interface/graphic/richText.js.map +1 -1
  18. package/cjs/interface/graphic/text.d.ts +1 -4
  19. package/cjs/interface/graphic/text.js.map +1 -1
  20. package/cjs/render/contributions/render/text-render.js +2 -2
  21. package/cjs/render/contributions/render/text-render.js.map +1 -1
  22. package/dist/index.js +17 -165
  23. package/dist/index.min.js +1 -1
  24. package/es/common/utils.d.ts +0 -1
  25. package/es/common/utils.js +1 -8
  26. package/es/common/utils.js.map +1 -1
  27. package/es/core/stage.d.ts +0 -1
  28. package/es/core/stage.js +3 -7
  29. package/es/core/stage.js.map +1 -1
  30. package/es/graphic/config.js +1 -4
  31. package/es/graphic/config.js.map +1 -1
  32. package/es/graphic/richtext/paragraph.js +2 -5
  33. package/es/graphic/richtext/paragraph.js.map +1 -1
  34. package/es/graphic/text.d.ts +0 -1
  35. package/es/graphic/text.js +9 -90
  36. package/es/graphic/text.js.map +1 -1
  37. package/es/graphic/wrap-text.js +4 -6
  38. package/es/graphic/wrap-text.js.map +1 -1
  39. package/es/interface/graphic/richText.d.ts +1 -1
  40. package/es/interface/graphic/richText.js.map +1 -1
  41. package/es/interface/graphic/text.d.ts +1 -4
  42. package/es/interface/graphic/text.js.map +1 -1
  43. package/es/render/contributions/render/text-render.js +1 -3
  44. package/es/render/contributions/render/text-render.js.map +1 -1
  45. package/package.json +4 -4
@@ -36,7 +36,7 @@ export type ITextAttribute = {
36
36
  ellipsis: boolean | string;
37
37
  fontVariant: string;
38
38
  fontStyle: string;
39
- lineHeight: number | string;
39
+ lineHeight: number;
40
40
  underline: number;
41
41
  lineThrough: number;
42
42
  scaleIn3d: boolean;
@@ -44,9 +44,6 @@ export type ITextAttribute = {
44
44
  verticalMode: number;
45
45
  wordBreak: 'break-word' | 'break-all';
46
46
  ignoreBuf: boolean;
47
- whiteSpace: 'normal' | 'no-wrap';
48
- heightLimit?: number;
49
- lineClamp?: number;
50
47
  };
51
48
  export type ITextCache = {
52
49
  clipedText?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number | string;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all';\n ignoreBuf: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n heightLimit?: number;\n lineClamp?: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all';\n ignoreBuf: boolean;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  value: !0
17
17
  }), exports.DefaultCanvasTextRender = void 0;
18
18
 
19
- const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), constants_1 = require("../../../graphic/constants"), text_1 = require("../../../common/text"), base_render_1 = require("./base-render"), contribution_provider_1 = require("../../../common/contribution-provider"), constants_2 = require("./contributions/constants"), matrix_allocate_1 = require("../../../allocator/matrix-allocate"), vutils_1 = require("@visactor/vutils"), utils_1 = require("../../../common/utils");
19
+ const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), constants_1 = require("../../../graphic/constants"), text_1 = require("../../../common/text"), base_render_1 = require("./base-render"), contribution_provider_1 = require("../../../common/contribution-provider"), constants_2 = require("./contributions/constants"), matrix_allocate_1 = require("../../../allocator/matrix-allocate"), vutils_1 = require("@visactor/vutils");
20
20
 
21
21
  let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
22
22
  constructor(textRenderContribitions) {
@@ -32,7 +32,7 @@ let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
32
32
  textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left",
33
33
  textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
34
34
  }
35
- const lineHeight = null !== (_c = (0, utils_1.calculateLineHeight)(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
35
+ const lineHeight = null !== (_c = text.attribute.lineHeight) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
36
36
  if (!data) return;
37
37
  const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, transform3dMatrixToContextMatrix = !keepDirIn3d, z = this.z || 0;
38
38
  context.beginPath(), context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAC3E,kDAAkD;AAClD,0DAA8D;AAa9D,+CAA0E;AAE1E,+CAA2C;AAC3C,iFAA6E;AAC7E,yDAAmE;AACnE,wEAAoE;AACpE,6CAAuC;AACvC,iDAA4D;AAGrD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,wBAAiB;IAI5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAL5F,eAAU,GAAW,4BAAgB,CAAC;QAQpC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACrC,CAAC;IAED,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAEZ,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,MAAM,EACJ,IAAI,EAAE,GAAG,EACT,IAAI,GAAG,aAAa,CAAC,IAAI,EACzB,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,WAAW,GAAG,aAAa,CAAC,WAAW,EACvC,aAAa,GAAG,aAAa,CAAC,aAAa,EAC3C,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,SAAS,GAAG,aAAa,CAAC,SAAS,EACnC,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,SAAS,GAAG,aAAa,CAAC,SAAS,EACnC,WAAW,GAAG,aAAa,CAAC,WAAW,EACvC,WAAW,GAAG,aAAa,CAAC,WAAW,EACvC,SAAS,GAAG,aAAa,CAAC,SAAS,EAEnC,QAAQ,GAAG,aAAa,CA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,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;QACD,MAAM,GAAG,CAAC,CAAC,CAAC;QACZ,IAAI,WAAW,EAAE;YACf,SAAS,CAAC,SAAS,GAAG,WAAW,CAAC;YAClC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;YAC7D,OAAO,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC;YAC/C,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;IACH,CAAC;CACF,CAAA;AAxXY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,kCAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAwXnC;AAxXY,0DAAuB","file":"text-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { TEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n ITextRenderContribution,\n IContributionProvider\n} from '../../../interface';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../../../common/text';\nimport type { IText, ITextGraphicAttribute } from '../../../interface/graphic/text';\nimport { BaseRender } from './base-render';\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { TextRenderContribution } from './contributions/constants';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { max } from '@visactor/vutils';\nimport { calculateLineHeight } from '../../../common/utils';\n\n@injectable()\nexport class DefaultCanvasTextRender extends BaseRender<IText> implements IGraphicRender {\n type: 'text';\n numberType: number = TEXT_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(TextRenderContribution)\n protected readonly textRenderContribitions: IContributionProvider<ITextRenderContribution>\n ) {\n super();\n this.init(textRenderContribitions);\n }\n\n drawShape(\n text: IText,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const textAttribute = getTheme(text, params?.theme).text;\n const {\n text: str,\n fill = textAttribute.fill,\n stroke = textAttribute.stroke,\n fillOpacity = textAttribute.fillOpacity,\n strokeOpacity = textAttribute.strokeOpacity,\n opacity = textAttribute.opacity,\n lineWidth = textAttribute.lineWidth,\n visible = textAttribute.visible,\n underline = textAttribute.underline,\n lineThrough = textAttribute.lineThrough,\n keepDirIn3d = textAttribute.keepDirIn3d,\n direction = textAttribute.direction,\n // lineHeight = textAttribute.lineHeight,\n fontSize = textAttribute.fontSize,\n verticalMode = textAttribute.verticalMode,\n x: originX = textAttribute.x,\n y: originY = textAttribute.y\n } = text.attribute;\n\n let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;\n if (!verticalMode && direction === 'vertical') {\n const t = textAlign;\n textAlign = text.getBaselineMapAlign()[textBaseline] ?? ('left' as any);\n textBaseline = text.getAlignMapBaseline()[t] ?? ('top' as any);\n }\n const lineHeight = calculateLineHeight(text.attribute.lineHeight, fontSize) ?? fontSize;\n\n const data = this.valid(text, textAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 文字如果需要变换,那就需要将3dmatrix转成context的2dmatrix\n const transform3dMatrixToContextMatrix = !keepDirIn3d;\n\n const z = this.z || 0;\n\n context.beginPath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute);\n\n this.beforeRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);\n\n const drawText = (t: string, offsetX: number, offsetY: number, direction: number) => {\n let _x = x + offsetX;\n const _y = y + offsetY;\n if (direction) {\n context.highPerformanceSave();\n _x += fontSize;\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // matrix.translate(fontSize, 0);\n matrix.rotateByCenter(Math.PI / 2, _x, _y);\n context.transformFromMatrix(matrix, true);\n matrixAllocate.free(matrix);\n }\n\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.strokeText(t, _x, _y, z);\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.fillText(t, _x, _y, z);\n this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context);\n }\n }\n\n if (direction) {\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n }\n };\n if (Array.isArray(str)) {\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n if (direction === 'horizontal') {\n const { multilineLayout } = text;\n if (!multilineLayout) {\n context.highPerformanceRestore();\n return;\n } // 如果不存在的话,需要render层自行布局\n const { xOffset, yOffset } = multilineLayout.bbox;\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.strokeText(\n line.str,\n (line.leftOffset || 0) + xOffset + x,\n (line.topOffset || 0) + yOffset + y,\n z\n );\n });\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n this.drawMultiUnderLine(\n underline,\n lineThrough,\n text,\n (line.leftOffset || 0) + x, // 中下划线都是从文字左侧开始,因此不需要+xOffset\n (line.topOffset || 0) + yOffset + y,\n z,\n line.width,\n textAttribute,\n context\n );\n });\n }\n }\n } else {\n const cache = text.cache;\n const { verticalList } = cache;\n context.textAlign = 'left';\n context.textBaseline = 'top';\n const totalHeight = lineHeight * verticalList.length;\n let totalW = 0;\n verticalList.forEach(verticalData => {\n const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n totalW = max(_w, totalW);\n });\n let offsetY = 0;\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -totalHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -totalHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n verticalList.forEach((verticalData, i) => {\n const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n const dw = totalW - currentW;\n let currentOffsetY = offsetY;\n if (textAlign === 'center') {\n currentOffsetY += dw / 2;\n } else if (textAlign === 'right') {\n currentOffsetY += dw;\n }\n verticalData.forEach(item => {\n const { text, width, direction } = item;\n drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);\n currentOffsetY += width;\n });\n });\n }\n } else {\n const cache = text.cache;\n if (direction === 'horizontal') {\n context.setTextStyle(text.attribute, textAttribute, z);\n const t = text.clipedText as string;\n let dy = 0;\n if (lineHeight !== fontSize) {\n if (textBaseline === 'top') {\n dy = (lineHeight - fontSize) / 2;\n } else if (textBaseline === 'middle') {\n // middle do nothing\n } else if (textBaseline === 'bottom') {\n dy = -(lineHeight - fontSize) / 2;\n } else {\n // alphabetic do nothing\n // dy = (lineHeight - fontSize) / 2 - fontSize * 0.79;\n }\n }\n drawText(t, 0, dy, 0);\n } else if (cache) {\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n const { verticalList } = cache;\n let offsetY = 0;\n const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -lineHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -lineHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n context.textAlign = 'left';\n context.textBaseline = 'top';\n verticalList[0].forEach(item => {\n const { text, width, direction } = item;\n drawText(text, offsetX, offsetY, direction);\n offsetY += width;\n });\n }\n }\n transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);\n\n this.afterRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const textAttribute = getTheme(text, params?.theme).text;\n const { keepDirIn3d = textAttribute.keepDirIn3d } = text.attribute;\n // 文字如果需要变换,那就一定要计算3d矩阵\n const computed3dMatrix = !keepDirIn3d;\n this._draw(text, textAttribute, computed3dMatrix, drawContext, params);\n }\n\n drawUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n x: number,\n y: number,\n z: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n textBaseline = textAttribute.textBaseline,\n fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n const w = text.clipedWidth;\n const offsetX = textDrawOffsetX(textAlign, w);\n const offsetY = textLayoutOffsetY(textBaseline, fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize / 2;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n }\n\n drawMultiUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n x: number,\n y: number,\n z: number,\n w: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n\n const offsetX = textDrawOffsetX(textAlign, w);\n const offsetY = textLayoutOffsetY('alphabetic', fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n let deltaY = -3;\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n deltaY = -1;\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize / 2 + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAC3E,kDAAkD;AAClD,0DAA8D;AAa9D,+CAA0E;AAG1E,+CAA2C;AAC3C,iFAA6E;AAC7E,yDAAmE;AAEnE,wEAAoE;AACpE,6CAAuC;AAGhC,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,wBAAiB;IAI5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAL5F,eAAU,GAAW,4BAAgB,CAAC;QAQpC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACrC,CAAC;IAED,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAEZ,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,MAAM,EACJ,IAAI,EAAE,GAAG,EACT,IAAI,GAAG,aAAa,CAAC,IAAI,EACzB,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,WAAW,GAAG,aAAa,CAAC,WAAW,EACvC,aAAa,GAAG,aAAa,CAAC,aAAa,EAC3C,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,SAAS,GAAG,aAAa,CAAC,SAAS,EACnC,OAAO,GAAG,aAAa,CAAC,OAAO,EAC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CAAC;YAC3C,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;QACD,MAAM,GAAG,CAAC,CAAC,CAAC;QACZ,IAAI,WAAW,EAAE;YACf,SAAS,CAAC,SAAS,GAAG,WAAW,CAAC;YAClC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;YAC7D,OAAO,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC;YAC/C,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;IACH,CAAC;CACF,CAAA;AAxXY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,kCAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAwXnC;AAxXY,0DAAuB","file":"text-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { TEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n ITextRenderContribution,\n IContributionProvider\n} from '../../../interface';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../../../common/text';\nimport type { IText, ITextGraphicAttribute } from '../../../interface/graphic/text';\nimport { fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRender } from './base-render';\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { TextRenderContribution } from './contributions/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { max } from '@visactor/vutils';\n\n@injectable()\nexport class DefaultCanvasTextRender extends BaseRender<IText> implements IGraphicRender {\n type: 'text';\n numberType: number = TEXT_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(TextRenderContribution)\n protected readonly textRenderContribitions: IContributionProvider<ITextRenderContribution>\n ) {\n super();\n this.init(textRenderContribitions);\n }\n\n drawShape(\n text: IText,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const textAttribute = getTheme(text, params?.theme).text;\n const {\n text: str,\n fill = textAttribute.fill,\n stroke = textAttribute.stroke,\n fillOpacity = textAttribute.fillOpacity,\n strokeOpacity = textAttribute.strokeOpacity,\n opacity = textAttribute.opacity,\n lineWidth = textAttribute.lineWidth,\n visible = textAttribute.visible,\n underline = textAttribute.underline,\n lineThrough = textAttribute.lineThrough,\n keepDirIn3d = textAttribute.keepDirIn3d,\n direction = textAttribute.direction,\n // lineHeight = textAttribute.lineHeight,\n fontSize = textAttribute.fontSize,\n verticalMode = textAttribute.verticalMode,\n x: originX = textAttribute.x,\n y: originY = textAttribute.y\n } = text.attribute;\n\n let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;\n if (!verticalMode && direction === 'vertical') {\n const t = textAlign;\n textAlign = text.getBaselineMapAlign()[textBaseline] ?? ('left' as any);\n textBaseline = text.getAlignMapBaseline()[t] ?? ('top' as any);\n }\n const lineHeight = text.attribute.lineHeight ?? fontSize;\n\n const data = this.valid(text, textAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 文字如果需要变换,那就需要将3dmatrix转成context的2dmatrix\n const transform3dMatrixToContextMatrix = !keepDirIn3d;\n\n const z = this.z || 0;\n\n context.beginPath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute);\n\n this.beforeRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);\n\n const drawText = (t: string, offsetX: number, offsetY: number, direction: number) => {\n let _x = x + offsetX;\n const _y = y + offsetY;\n if (direction) {\n context.highPerformanceSave();\n _x += fontSize;\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // matrix.translate(fontSize, 0);\n matrix.rotateByCenter(Math.PI / 2, _x, _y);\n context.transformFromMatrix(matrix, true);\n matrixAllocate.free(matrix);\n }\n\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.strokeText(t, _x, _y, z);\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.fillText(t, _x, _y, z);\n this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context);\n }\n }\n\n if (direction) {\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n }\n };\n if (Array.isArray(str)) {\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n if (direction === 'horizontal') {\n const { multilineLayout } = text;\n if (!multilineLayout) {\n context.highPerformanceRestore();\n return;\n } // 如果不存在的话,需要render层自行布局\n const { xOffset, yOffset } = multilineLayout.bbox;\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.strokeText(\n line.str,\n (line.leftOffset || 0) + xOffset + x,\n (line.topOffset || 0) + yOffset + y,\n z\n );\n });\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n this.drawMultiUnderLine(\n underline,\n lineThrough,\n text,\n (line.leftOffset || 0) + x, // 中下划线都是从文字左侧开始,因此不需要+xOffset\n (line.topOffset || 0) + yOffset + y,\n z,\n line.width,\n textAttribute,\n context\n );\n });\n }\n }\n } else {\n const cache = text.cache;\n const { verticalList } = cache;\n context.textAlign = 'left';\n context.textBaseline = 'top';\n const totalHeight = lineHeight * verticalList.length;\n let totalW = 0;\n verticalList.forEach(verticalData => {\n const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n totalW = max(_w, totalW);\n });\n let offsetY = 0;\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -totalHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -totalHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n verticalList.forEach((verticalData, i) => {\n const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n const dw = totalW - currentW;\n let currentOffsetY = offsetY;\n if (textAlign === 'center') {\n currentOffsetY += dw / 2;\n } else if (textAlign === 'right') {\n currentOffsetY += dw;\n }\n verticalData.forEach(item => {\n const { text, width, direction } = item;\n drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);\n currentOffsetY += width;\n });\n });\n }\n } else {\n const cache = text.cache;\n if (direction === 'horizontal') {\n context.setTextStyle(text.attribute, textAttribute, z);\n const t = text.clipedText as string;\n let dy = 0;\n if (lineHeight !== fontSize) {\n if (textBaseline === 'top') {\n dy = (lineHeight - fontSize) / 2;\n } else if (textBaseline === 'middle') {\n // middle do nothing\n } else if (textBaseline === 'bottom') {\n dy = -(lineHeight - fontSize) / 2;\n } else {\n // alphabetic do nothing\n // dy = (lineHeight - fontSize) / 2 - fontSize * 0.79;\n }\n }\n drawText(t, 0, dy, 0);\n } else if (cache) {\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n const { verticalList } = cache;\n let offsetY = 0;\n const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -lineHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -lineHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n context.textAlign = 'left';\n context.textBaseline = 'top';\n verticalList[0].forEach(item => {\n const { text, width, direction } = item;\n drawText(text, offsetX, offsetY, direction);\n offsetY += width;\n });\n }\n }\n transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);\n\n this.afterRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const textAttribute = getTheme(text, params?.theme).text;\n const { keepDirIn3d = textAttribute.keepDirIn3d } = text.attribute;\n // 文字如果需要变换,那就一定要计算3d矩阵\n const computed3dMatrix = !keepDirIn3d;\n this._draw(text, textAttribute, computed3dMatrix, drawContext, params);\n }\n\n drawUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n x: number,\n y: number,\n z: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n textBaseline = textAttribute.textBaseline,\n fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n const w = text.clipedWidth;\n const offsetX = textDrawOffsetX(textAlign, w);\n const offsetY = textLayoutOffsetY(textBaseline, fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize / 2;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n }\n\n drawMultiUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n x: number,\n y: number,\n z: number,\n w: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n\n const offsetX = textDrawOffsetX(textAlign, w);\n const offsetY = textLayoutOffsetY('alphabetic', fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n let deltaY = -3;\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n deltaY = -1;\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize / 2 + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -4294,10 +4294,7 @@
4294
4294
  direction: 'horizontal',
4295
4295
  wordBreak: 'break-all',
4296
4296
  ignoreBuf: false,
4297
- verticalMode: 0,
4298
- whiteSpace: 'no-wrap',
4299
- heightLimit: Infinity,
4300
- lineClamp: Infinity
4297
+ verticalMode: 0
4301
4298
  };
4302
4299
  const DefaultStyle = Object.assign(Object.assign(Object.assign({ opacity: 1, background: null, texture: null, textureColor: 'black', textureSize: 10, texturePadding: 2, backgroundMode: 0, blur: 0, cursor: null, html: null }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout);
4303
4300
  const DefaultConnectAttribute = {
@@ -9016,13 +9013,6 @@
9016
9013
  }
9017
9014
  RafBasedSTO.TimeOut = 1000 / 60;
9018
9015
  const rafBasedSto = new RafBasedSTO();
9019
- const calculateLineHeight = (lineHeight, fontSize) => {
9020
- if (vutils.isString(lineHeight) && lineHeight[lineHeight.length - 1] === '%') {
9021
- const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
9022
- return fontSize * scale;
9023
- }
9024
- return lineHeight;
9025
- };
9026
9016
 
9027
9017
  class IncreaseCount extends ACustomAnimate {
9028
9018
  constructor(from, to, duration, easing, params) {
@@ -14324,8 +14314,6 @@
14324
14314
  const TEXT_UPDATE_TAG_KEY = [
14325
14315
  'text',
14326
14316
  'maxLineWidth',
14327
- 'heightLimit',
14328
- 'lineClamp',
14329
14317
  'fontSize',
14330
14318
  'fontFamily',
14331
14319
  'fontWeight',
@@ -14410,113 +14398,6 @@
14410
14398
  this.clearUpdateBoundTag();
14411
14399
  return bounds;
14412
14400
  }
14413
- updateWrapAABBBounds(text) {
14414
- var _a, _b, _c, _d;
14415
- const textTheme = getTheme(this).text;
14416
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
14417
- const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
14418
- const buf = ignoreBuf ? 0 : 2;
14419
- if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
14420
- const bbox = this.cache.layoutData.bbox;
14421
- this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
14422
- if (stroke) {
14423
- this._AABBBounds.expand(lineWidth / 2);
14424
- }
14425
- return this._AABBBounds;
14426
- }
14427
- const textMeasure = application.graphicUtil.textMeasure;
14428
- const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
14429
- const lines = vutils.isArray(text) ? text.map(l => l.toString()) : [text.toString()];
14430
- const linesLayout = [];
14431
- const bboxWH = [0, 0];
14432
- let lineCountLimit = Infinity;
14433
- if (heightLimit > 0) {
14434
- lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);
14435
- }
14436
- if (lineClamp) {
14437
- lineCountLimit = Math.min(lineCountLimit, lineClamp);
14438
- }
14439
- if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {
14440
- if (maxLineWidth > 0) {
14441
- for (let i = 0; i < lines.length; i++) {
14442
- const str = lines[i];
14443
- let needCut = true;
14444
- if (i === lineCountLimit - 1) {
14445
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
14446
- linesLayout.push({
14447
- str: clip.str,
14448
- width: clip.width
14449
- });
14450
- break;
14451
- }
14452
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, wordBreak === 'break-word');
14453
- if (str !== '' && clip.str === '') {
14454
- if (ellipsis) {
14455
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
14456
- clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
14457
- clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
14458
- }
14459
- else {
14460
- clip.str = '';
14461
- clip.width = 0;
14462
- }
14463
- needCut = false;
14464
- }
14465
- linesLayout.push({
14466
- str: clip.str,
14467
- width: clip.width
14468
- });
14469
- if (clip.str.length === str.length) ;
14470
- else if (needCut) {
14471
- const newStr = str.substring(clip.str.length);
14472
- lines.splice(i + 1, 0, newStr);
14473
- }
14474
- }
14475
- }
14476
- let maxWidth = 0;
14477
- linesLayout.forEach(layout => {
14478
- maxWidth = Math.max(maxWidth, layout.width);
14479
- });
14480
- bboxWH[0] = maxWidth;
14481
- }
14482
- else {
14483
- let lineWidth = 0;
14484
- let width;
14485
- let text;
14486
- for (let i = 0, len = lines.length; i < len; i++) {
14487
- if (i === lineCountLimit - 1) {
14488
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, false);
14489
- linesLayout.push({
14490
- str: clip.str,
14491
- width: clip.width
14492
- });
14493
- lineWidth = Math.max(lineWidth, clip.width);
14494
- break;
14495
- }
14496
- text = lines[i];
14497
- width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');
14498
- lineWidth = Math.max(lineWidth, width);
14499
- linesLayout.push({ str: text, width });
14500
- }
14501
- bboxWH[0] = lineWidth;
14502
- }
14503
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
14504
- const bbox = {
14505
- xOffset: 0,
14506
- yOffset: 0,
14507
- width: bboxWH[0],
14508
- height: bboxWH[1]
14509
- };
14510
- layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
14511
- const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14512
- this.cache.layoutData = layoutData;
14513
- this.clearUpdateShapeTag();
14514
- this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
14515
- if (stroke) {
14516
- this._AABBBounds.expand(lineWidth / 2);
14517
- }
14518
- return this._AABBBounds;
14519
- }
14520
14401
  updateSingallineAABBBounds(text) {
14521
14402
  const textTheme = getTheme(this).text;
14522
14403
  const { direction = textTheme.direction } = this.attribute;
@@ -14538,13 +14419,9 @@
14538
14419
  let width;
14539
14420
  let str;
14540
14421
  const attribute = this.attribute;
14541
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, ignoreBuf = textTheme.ignoreBuf, whiteSpace = textTheme.whiteSpace } = attribute;
14542
- if (whiteSpace === 'normal') {
14543
- return this.updateWrapAABBBounds(text);
14544
- }
14422
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, ignoreBuf = textTheme.ignoreBuf } = attribute;
14545
14423
  const buf = ignoreBuf ? 0 : Math.max(2, fontSize * 0.075);
14546
- const textFontSize = attribute.fontSize || textTheme.fontSize;
14547
- const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) !== null && _a !== void 0 ? _a : textFontSize + buf;
14424
+ const { lineHeight = (_a = attribute.lineHeight) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf } = attribute;
14548
14425
  if (!this.shouldUpdateShape() && this.cache) {
14549
14426
  width = (_b = this.cache.clipedWidth) !== null && _b !== void 0 ? _b : 0;
14550
14427
  const dx = textDrawOffsetX(textAlign, width);
@@ -14602,8 +14479,7 @@
14602
14479
  const attribute = this.attribute;
14603
14480
  const { ignoreBuf = textTheme.ignoreBuf } = attribute;
14604
14481
  const buf = ignoreBuf ? 0 : 2;
14605
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
14606
- const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14482
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke, lineHeight = (_a = attribute.lineHeight) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
14607
14483
  let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
14608
14484
  if (!verticalMode) {
14609
14485
  const t = textAlign;
@@ -14660,15 +14536,11 @@
14660
14536
  return this._AABBBounds;
14661
14537
  }
14662
14538
  updateHorizontalMultilineAABBBounds(text) {
14663
- var _a, _b;
14539
+ var _a;
14664
14540
  const textTheme = getTheme(this).text;
14665
14541
  const attribute = this.attribute;
14666
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace } = attribute;
14667
- const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize);
14668
- if (whiteSpace === 'normal') {
14669
- return this.updateWrapAABBBounds(text);
14670
- }
14671
- if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
14542
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, lineHeight = attribute.lineHeight || attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak } = attribute;
14543
+ if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
14672
14544
  const bbox = this.cache.layoutData.bbox;
14673
14545
  this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
14674
14546
  if (stroke) {
@@ -14696,8 +14568,7 @@
14696
14568
  const attribute = this.attribute;
14697
14569
  const { ignoreBuf = textTheme.ignoreBuf } = attribute;
14698
14570
  const buf = ignoreBuf ? 0 : 2;
14699
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
14700
- const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14571
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = (_a = attribute.lineHeight) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
14701
14572
  let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
14702
14573
  if (!verticalMode) {
14703
14574
  const t = textAlign;
@@ -14804,12 +14675,11 @@
14804
14675
  return text != null && text !== '';
14805
14676
  }
14806
14677
  updateMultilineAABBBounds(text) {
14807
- var _a, _b, _c, _d;
14678
+ var _a, _b, _c;
14808
14679
  const textTheme = getTheme(this).text;
14809
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
14810
- const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
14680
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
14811
14681
  const buf = ignoreBuf ? 0 : 2;
14812
- if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
14682
+ if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
14813
14683
  const bbox = this.cache.layoutData.bbox;
14814
14684
  this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
14815
14685
  if (stroke) {
@@ -14846,8 +14716,8 @@
14846
14716
  if (str !== '' && clip.str === '') {
14847
14717
  if (ellipsis) {
14848
14718
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
14849
- clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
14850
- clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
14719
+ clip.str = (_b = clipEllipsis.str) !== null && _b !== void 0 ? _b : '';
14720
+ clip.width = (_c = clipEllipsis.width) !== null && _c !== void 0 ? _c : 0;
14851
14721
  }
14852
14722
  else {
14853
14723
  clip.str = '';
@@ -16473,9 +16343,8 @@
16473
16343
  constructor(text, newLine, character) {
16474
16344
  this.fontSize = character.fontSize || 16;
16475
16345
  this.textBaseline = character.textBaseline || 'alphabetic';
16476
- const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
16477
- if (typeof lineHeight === 'number') {
16478
- this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;
16346
+ if (typeof character.lineHeight === 'number') {
16347
+ this.lineHeight = character.lineHeight > this.fontSize ? character.lineHeight : this.fontSize;
16479
16348
  }
16480
16349
  else {
16481
16350
  this.lineHeight = Math.floor(1.2 * this.fontSize);
@@ -20992,7 +20861,7 @@
20992
20861
  textAlign = (_a = text.getBaselineMapAlign()[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
20993
20862
  textBaseline = (_b = text.getAlignMapBaseline()[t]) !== null && _b !== void 0 ? _b : 'top';
20994
20863
  }
20995
- const lineHeight = (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) !== null && _c !== void 0 ? _c : fontSize;
20864
+ const lineHeight = (_c = text.attribute.lineHeight) !== null && _c !== void 0 ? _c : fontSize;
20996
20865
  const data = this.valid(text, textAttribute, fillCb, strokeCb);
20997
20866
  if (!data) {
20998
20867
  return;
@@ -26255,19 +26124,6 @@
26255
26124
  this.setAttributes({ background: this._background });
26256
26125
  }
26257
26126
  }
26258
- preventRender(prevent) {
26259
- if (prevent) {
26260
- this._skipRender = -Infinity;
26261
- }
26262
- else {
26263
- if (this.params && this.params.optimize && this.params.optimize.skipRenderWithOutRange !== false) {
26264
- this._skipRender = this.window.isVisible() ? 0 : 1;
26265
- }
26266
- else {
26267
- this._skipRender = 0;
26268
- }
26269
- }
26270
- }
26271
26127
  optmize(params) {
26272
26128
  this.optmizeRender(params === null || params === void 0 ? void 0 : params.skipRenderWithOutRange);
26273
26129
  }
@@ -26275,11 +26131,8 @@
26275
26131
  if (!skipRenderWithOutRange) {
26276
26132
  return;
26277
26133
  }
26278
- this._skipRender = this._skipRender < 0 ? this._skipRender : this.window.isVisible() ? 0 : 1;
26134
+ this._skipRender = this.window.isVisible() ? 0 : 1;
26279
26135
  this.window.onVisibleChange(visible => {
26280
- if (this._skipRender < 0) {
26281
- return;
26282
- }
26283
26136
  if (visible) {
26284
26137
  if (this.dirtyBounds) {
26285
26138
  this.dirtyBounds.setValue(0, 0, this._viewBox.width(), this._viewBox.height());
@@ -27647,7 +27500,6 @@
27647
27500
  exports.builtinSymbols = builtinSymbols;
27648
27501
  exports.builtinSymbolsMap = builtinSymbolsMap;
27649
27502
  exports.calcLineCache = calcLineCache$1;
27650
- exports.calculateLineHeight = calculateLineHeight;
27651
27503
  exports.centroidOfSubpath = centroidOfSubpath;
27652
27504
  exports.circleBounds = circleBounds;
27653
27505
  exports.clock = clock;