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

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 (55) hide show
  1. package/cjs/common/utils.d.ts +1 -0
  2. package/cjs/common/utils.js +10 -1
  3. package/cjs/common/utils.js.map +1 -1
  4. package/cjs/core/stage.d.ts +1 -0
  5. package/cjs/core/stage.js +7 -3
  6. package/cjs/core/stage.js.map +1 -1
  7. package/cjs/graphic/builtin-symbol/index.d.ts +1 -0
  8. package/cjs/graphic/builtin-symbol/index.js +8 -2
  9. package/cjs/graphic/builtin-symbol/index.js.map +1 -1
  10. package/cjs/graphic/config.js +4 -1
  11. package/cjs/graphic/config.js.map +1 -1
  12. package/cjs/graphic/richtext/paragraph.js +12 -11
  13. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  14. package/cjs/graphic/symbol.js +3 -2
  15. package/cjs/graphic/symbol.js.map +1 -1
  16. package/cjs/graphic/text.d.ts +1 -0
  17. package/cjs/graphic/text.js +93 -7
  18. package/cjs/graphic/text.js.map +1 -1
  19. package/cjs/graphic/wrap-text.js +6 -5
  20. package/cjs/graphic/wrap-text.js.map +1 -1
  21. package/cjs/interface/graphic/richText.d.ts +1 -1
  22. package/cjs/interface/graphic/richText.js.map +1 -1
  23. package/cjs/interface/graphic/text.d.ts +4 -1
  24. package/cjs/interface/graphic/text.js.map +1 -1
  25. package/cjs/render/contributions/render/text-render.js +2 -2
  26. package/cjs/render/contributions/render/text-render.js.map +1 -1
  27. package/dist/index.js +176 -18
  28. package/dist/index.min.js +1 -1
  29. package/es/common/utils.d.ts +1 -0
  30. package/es/common/utils.js +8 -1
  31. package/es/common/utils.js.map +1 -1
  32. package/es/core/stage.d.ts +1 -0
  33. package/es/core/stage.js +7 -3
  34. package/es/core/stage.js.map +1 -1
  35. package/es/graphic/builtin-symbol/index.d.ts +1 -0
  36. package/es/graphic/builtin-symbol/index.js +8 -0
  37. package/es/graphic/builtin-symbol/index.js.map +1 -1
  38. package/es/graphic/config.js +4 -1
  39. package/es/graphic/config.js.map +1 -1
  40. package/es/graphic/richtext/paragraph.js +5 -2
  41. package/es/graphic/richtext/paragraph.js.map +1 -1
  42. package/es/graphic/symbol.js +4 -3
  43. package/es/graphic/symbol.js.map +1 -1
  44. package/es/graphic/text.d.ts +1 -0
  45. package/es/graphic/text.js +90 -9
  46. package/es/graphic/text.js.map +1 -1
  47. package/es/graphic/wrap-text.js +6 -4
  48. package/es/graphic/wrap-text.js.map +1 -1
  49. package/es/interface/graphic/richText.d.ts +1 -1
  50. package/es/interface/graphic/richText.js.map +1 -1
  51. package/es/interface/graphic/text.d.ts +4 -1
  52. package/es/interface/graphic/text.js.map +1 -1
  53. package/es/render/contributions/render/text-render.js +3 -1
  54. package/es/render/contributions/render/text-render.js.map +1 -1
  55. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGtB,QAAQ;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO,CAAE,IAAc,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SAClE;QACD,OAAO,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AAC,EAAE;gBAChC,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAES,aAAa,CAAC,GAAW;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,oBAAoB;QAClB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;CACF","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = getTheme(this).text;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n const buf = ignoreBuf ? 0 : 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n wordBreak === 'break-word'\n );\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n protected needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return WrapText.NOWORK_ANIMATE_ATTR;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAM,OAAO,QAAS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AExG,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SACxC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAES,cAAc,CAAC,IAAc;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;gBAChC,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAES,aAAa,CAAC,GAAW;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,oBAAoB;QAClB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;CACF","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\nimport { calculateLineHeight } from '../common/utils';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = getTheme(this).text;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n const lineHeight =\n calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize) ??\n (this.attribute.fontSize || textTheme.fontSize);\n const buf = ignoreBuf ? 0 : 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n wordBreak === 'break-word'\n );\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n protected needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return WrapText.NOWORK_ANIMATE_ATTR;\n }\n}\n"]}
@@ -26,7 +26,7 @@ export type RichTextFontStyle = 'normal' | 'italic' | 'oblique';
26
26
  export type RichTextTextDecoration = 'none' | 'underline' | 'line-through';
27
27
  export type RichTextScript = 'normal' | 'sub' | 'super';
28
28
  export type IRichTextBasicCharacter = {
29
- lineHeight?: number;
29
+ lineHeight?: number | string;
30
30
  textAlign?: CanvasTextAlign;
31
31
  textBaseline?: CanvasTextBaseline;
32
32
  direction?: RichTextLayoutDirectionType;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute> & Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute> & Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number | string;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
@@ -36,7 +36,7 @@ export type ITextAttribute = {
36
36
  ellipsis: boolean | string;
37
37
  fontVariant: string;
38
38
  fontStyle: string;
39
- lineHeight: number;
39
+ lineHeight: number | string;
40
40
  underline: number;
41
41
  lineThrough: number;
42
42
  scaleIn3d: boolean;
@@ -44,6 +44,9 @@ 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;
47
50
  };
48
51
  export type ITextCache = {
49
52
  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;\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"]}
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"]}
@@ -28,6 +28,8 @@ import { matrixAllocate } from "../../../allocator/matrix-allocate";
28
28
 
29
29
  import { max } from "@visactor/vutils";
30
30
 
31
+ import { calculateLineHeight } from "../../../common/utils";
32
+
31
33
  let DefaultCanvasTextRender = class extends BaseRender {
32
34
  constructor(textRenderContribitions) {
33
35
  super(), this.textRenderContribitions = textRenderContribitions, this.numberType = TEXT_NUMBER_TYPE,
@@ -42,7 +44,7 @@ let DefaultCanvasTextRender = class extends BaseRender {
42
44
  textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left",
43
45
  textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
44
46
  }
45
- const lineHeight = null !== (_c = text.attribute.lineHeight) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
47
+ const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
46
48
  if (!data) return;
47
49
  const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, transform3dMatrixToContextMatrix = !keepDirIn3d, z = this.z || 0;
48
50
  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,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAa9D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGhC,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAiB;IAI5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAL5F,eAAU,GAAW,gBAAgB,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,QAAQ,CAAC,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,MAA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,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,MAAM,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,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAwXnC;SAxXY,uBAAuB","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"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAa9D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGrD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,S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AAC,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,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAwXnC;SAxXY,uBAAuB","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-core",
3
- "version": "0.16.14-alpha.6",
3
+ "version": "0.16.14-alpha.8",
4
4
  "description": "",
5
5
  "sideEffects": true,
6
6
  "main": "cjs/index.js",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "color-convert": "2.0.1",
16
- "@visactor/vutils": "~0.16.6"
16
+ "@visactor/vutils": "0.16.8-alpha.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rushstack/eslint-patch": "~1.1.4",
@@ -30,8 +30,8 @@
30
30
  "eslint": "~8.18.0",
31
31
  "vite": "3.2.6",
32
32
  "typescript": "4.9.5",
33
- "@internal/bundler": "0.0.1",
34
33
  "@internal/ts-config": "0.0.1",
34
+ "@internal/bundler": "0.0.1",
35
35
  "@internal/eslint-config": "0.0.1"
36
36
  },
37
37
  "keywords": [