@visactor/vrender-core 0.21.0-alpha.10 → 0.21.0-alpha.11

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.
@@ -12,6 +12,7 @@ export interface LayoutItemType {
12
12
  width: number;
13
13
  ascent: number;
14
14
  descent: number;
15
+ keepCenterInLine: boolean;
15
16
  }
16
17
  export interface SimplifyLayoutType {
17
18
  lines: LayoutItemType[];
@@ -60,6 +61,7 @@ export type ITextAttribute = {
60
61
  underlineOffset: number;
61
62
  disableAutoClipedPoptip?: boolean;
62
63
  measureMode?: MeasureModeEnum;
64
+ keepCenterInLine?: boolean;
63
65
  };
64
66
  export type ITextCache = {
65
67
  clipedText?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":";;;AAiCA,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,6DAAY,CAAA;IACZ,yEAAkB,CAAA;IAClB,qEAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B","file":"text.js","sourcesContent":["import 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 ascent: number;\n descent: 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 enum MeasureModeEnum {\n estimate = 0,\n actualBounding = 1,\n fontBounding = 2\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n maxWidth: 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' | 'keep-all';\n ignoreBuf: boolean;\n heightLimit: number;\n lineClamp: number;\n wrap: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n suffixPosition: 'start' | 'end' | 'middle';\n underlineDash: number[];\n underlineOffset: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n disableAutoClipedPoptip?: boolean;\n // 测量模式,默认使用actualBounding\n measureMode?: MeasureModeEnum;\n};\nexport type ITextCache = {\n // 单行文本的时候缓存(多行文本没有)\n clipedText?: string;\n clipedWidth?: number;\n // 文本的布局缓存(单行文本也有)\n layoutData?: LayoutType;\n // 垂直布局的列表\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 isMultiLine: boolean;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\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":";;;AAkCA,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,6DAAY,CAAA;IACZ,yEAAkB,CAAA;IAClB,qEAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B","file":"text.js","sourcesContent":["import 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 ascent: number;\n descent: number;\n keepCenterInLine: boolean;\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 enum MeasureModeEnum {\n estimate = 0,\n actualBounding = 1,\n fontBounding = 2\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n maxWidth: 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' | 'keep-all';\n ignoreBuf: boolean;\n heightLimit: number;\n lineClamp: number;\n wrap: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n suffixPosition: 'start' | 'end' | 'middle';\n underlineDash: number[];\n underlineOffset: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n disableAutoClipedPoptip?: boolean;\n // @since 0.21.0\n // 测量模式,默认使用actualBounding\n measureMode?: MeasureModeEnum;\n // @since 0.21.0\n // 保持在行中间的位置\n keepCenterInLine?: boolean;\n};\nexport type ITextCache = {\n // 单行文本的时候缓存(多行文本没有)\n clipedText?: string;\n clipedWidth?: number;\n // 文本的布局缓存(单行文本也有)\n layoutData?: LayoutType;\n // 垂直布局的列表\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 isMultiLine: boolean;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
package/dist/index.es.js CHANGED
@@ -3068,7 +3068,8 @@ const DefaultTextStyle = {
3068
3068
  underlineDash: [],
3069
3069
  underlineOffset: 0,
3070
3070
  disableAutoClipedPoptip: undefined,
3071
- measureMode: MeasureModeEnum.fontBounding
3071
+ measureMode: MeasureModeEnum.fontBounding,
3072
+ keepCenterInLine: false
3072
3073
  };
3073
3074
  const DefaultPickStyle = {
3074
3075
  pickStrokeBuffer: 0
@@ -19177,7 +19178,7 @@ class CanvasTextLayout {
19177
19178
  return bbox;
19178
19179
  }
19179
19180
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight, suffix = '', wordBreak, params) {
19180
- const { lineWidth, suffixPosition = 'end', measureMode = MeasureModeEnum.actualBounding } = params !== null && params !== void 0 ? params : {};
19181
+ const { lineWidth, suffixPosition = 'end', measureMode = MeasureModeEnum.actualBounding, keepCenterInLine = false } = params !== null && params !== void 0 ? params : {};
19181
19182
  lines = lines.map(l => l.toString());
19182
19183
  const linesLayout = [];
19183
19184
  const bboxWH = [0, 0];
@@ -19192,7 +19193,8 @@ class CanvasTextLayout {
19192
19193
  : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
19193
19194
  width,
19194
19195
  ascent: metrics.ascent,
19195
- descent: metrics.descent
19196
+ descent: metrics.descent,
19197
+ keepCenterInLine
19196
19198
  });
19197
19199
  }
19198
19200
  bboxWH[0] = lineWidth;
@@ -19206,7 +19208,7 @@ class CanvasTextLayout {
19206
19208
  const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
19207
19209
  width = metrics.width;
19208
19210
  _lineWidth = Math.max(_lineWidth, width);
19209
- linesLayout.push({ str: text, width, ascent: metrics.ascent, descent: metrics.descent });
19211
+ linesLayout.push({ str: text, width, ascent: metrics.ascent, descent: metrics.descent, keepCenterInLine });
19210
19212
  }
19211
19213
  bboxWH[0] = _lineWidth;
19212
19214
  }
@@ -19256,15 +19258,17 @@ class CanvasTextLayout {
19256
19258
  line.leftOffset = bbox.width - line.width;
19257
19259
  }
19258
19260
  line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];
19259
- const actualHeight = line.ascent + line.descent;
19260
- const buf = 0;
19261
- const actualHeightWithBuf = actualHeight + buf;
19262
- if (actualHeightWithBuf < lineHeight - buf) {
19263
- if (textBaseline === 'bottom') {
19264
- line.topOffset += (lineHeight - actualHeightWithBuf) / 2;
19265
- }
19266
- else if (textBaseline === 'top') {
19267
- line.topOffset -= (lineHeight - actualHeightWithBuf) / 2;
19261
+ if (!line.keepCenterInLine) {
19262
+ const actualHeight = line.ascent + line.descent;
19263
+ const buf = 0;
19264
+ const actualHeightWithBuf = actualHeight + buf;
19265
+ if (actualHeightWithBuf < lineHeight - buf) {
19266
+ if (textBaseline === 'bottom') {
19267
+ line.topOffset += (lineHeight - actualHeightWithBuf) / 2;
19268
+ }
19269
+ else if (textBaseline === 'top') {
19270
+ line.topOffset -= (lineHeight - actualHeightWithBuf) / 2;
19271
+ }
19268
19272
  }
19269
19273
  }
19270
19274
  origin[1] += lineHeight;
@@ -19441,7 +19445,7 @@ class Text extends Graphic {
19441
19445
  var _a;
19442
19446
  const textTheme = this.getGraphicTheme();
19443
19447
  const attribute = this.attribute;
19444
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, wrap = textTheme.wrap, measureMode = textTheme.measureMode, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition, ignoreBuf = textTheme.ignoreBuf } = attribute;
19448
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, wrap = textTheme.wrap, measureMode = textTheme.measureMode, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition, ignoreBuf = textTheme.ignoreBuf, keepCenterInLine = textTheme.keepCenterInLine } = attribute;
19445
19449
  const buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize);
19446
19450
  const lineHeight = this.getLineHeight(attribute, textTheme) + buf;
19447
19451
  if (whiteSpace === 'normal' || wrap) {
@@ -19460,7 +19464,8 @@ class Text extends Graphic {
19460
19464
  const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, {
19461
19465
  lineWidth: maxLineWidth,
19462
19466
  suffixPosition,
19463
- measureMode
19467
+ measureMode,
19468
+ keepCenterInLine
19464
19469
  });
19465
19470
  const { bbox } = layoutData;
19466
19471
  this.cache.layoutData = layoutData;
@@ -19474,7 +19479,7 @@ class Text extends Graphic {
19474
19479
  updateWrapAABBBounds(text) {
19475
19480
  var _a, _b, _c;
19476
19481
  const textTheme = this.getGraphicTheme();
19477
- 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, measureMode = textTheme.measureMode, suffixPosition = textTheme.suffixPosition, heightLimit = 0, lineClamp } = this.attribute;
19482
+ 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, measureMode = textTheme.measureMode, suffixPosition = textTheme.suffixPosition, heightLimit = 0, lineClamp, keepCenterInLine = textTheme.keepCenterInLine } = this.attribute;
19478
19483
  const buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize);
19479
19484
  const lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
19480
19485
  if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
@@ -19510,7 +19515,8 @@ class Text extends Graphic {
19510
19515
  str: clip.str,
19511
19516
  width: clip.width,
19512
19517
  ascent: matrics.ascent,
19513
- descent: matrics.descent
19518
+ descent: matrics.descent,
19519
+ keepCenterInLine
19514
19520
  });
19515
19521
  break;
19516
19522
  }
@@ -19532,7 +19538,8 @@ class Text extends Graphic {
19532
19538
  str: clip.str,
19533
19539
  width: clip.width,
19534
19540
  ascent: matrics.ascent,
19535
- descent: matrics.descent
19541
+ descent: matrics.descent,
19542
+ keepCenterInLine
19536
19543
  });
19537
19544
  let cutLength = clip.str.length;
19538
19545
  if (clip.wordBreaked && !(str !== '' && clip.str === '')) {
@@ -19564,7 +19571,8 @@ class Text extends Graphic {
19564
19571
  str: clip.str,
19565
19572
  width: clip.width,
19566
19573
  ascent: matrics.ascent,
19567
- descent: matrics.descent
19574
+ descent: matrics.descent,
19575
+ keepCenterInLine
19568
19576
  });
19569
19577
  lineWidth = Math.max(lineWidth, clip.width);
19570
19578
  break;
@@ -19573,7 +19581,7 @@ class Text extends Graphic {
19573
19581
  width = textMeasure.measureTextWidth(text, textOptions);
19574
19582
  lineWidth = Math.max(lineWidth, width);
19575
19583
  const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
19576
- linesLayout.push({ str: text, width, ascent: matrics.ascent, descent: matrics.descent });
19584
+ linesLayout.push({ str: text, width, ascent: matrics.ascent, descent: matrics.descent, keepCenterInLine });
19577
19585
  }
19578
19586
  bboxWH[0] = lineWidth;
19579
19587
  }
@@ -19758,7 +19766,8 @@ class WrapText extends Text {
19758
19766
  str: clip.str,
19759
19767
  width: clip.width,
19760
19768
  ascent: 0,
19761
- descent: 0
19769
+ descent: 0,
19770
+ keepCenterInLine: false
19762
19771
  });
19763
19772
  break;
19764
19773
  }
@@ -19779,7 +19788,8 @@ class WrapText extends Text {
19779
19788
  str: clip.str,
19780
19789
  width: clip.width,
19781
19790
  ascent: 0,
19782
- descent: 0
19791
+ descent: 0,
19792
+ keepCenterInLine: false
19783
19793
  });
19784
19794
  if (clip.str.length === str.length) ;
19785
19795
  else if (needCut) {
@@ -19805,7 +19815,8 @@ class WrapText extends Text {
19805
19815
  str: clip.str,
19806
19816
  width: clip.width,
19807
19817
  ascent: 0,
19808
- descent: 0
19818
+ descent: 0,
19819
+ keepCenterInLine: false
19809
19820
  });
19810
19821
  lineWidth = Math.max(lineWidth, clip.width);
19811
19822
  break;
@@ -19813,7 +19824,7 @@ class WrapText extends Text {
19813
19824
  text = lines[i];
19814
19825
  width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');
19815
19826
  lineWidth = Math.max(lineWidth, width);
19816
- linesLayout.push({ str: text, width, ascent: 0, descent: 0 });
19827
+ linesLayout.push({ str: text, width, ascent: 0, descent: 0, keepCenterInLine: false });
19817
19828
  }
19818
19829
  bboxWH[0] = lineWidth;
19819
19830
  }
@@ -11,6 +11,7 @@ export declare class CanvasTextLayout {
11
11
  lineWidth?: number;
12
12
  suffixPosition?: 'start' | 'end' | 'middle';
13
13
  measureMode?: MeasureModeEnum;
14
+ keepCenterInLine?: boolean;
14
15
  }): LayoutType;
15
16
  layoutWithBBox(bbox: TextLayoutBBox, lines: LayoutItemType[], textAlign: TextAlignType, textBaseline: TextBaselineType, lineHeight: number): LayoutType;
16
17
  private lineOffset;
@@ -20,7 +20,7 @@ export class CanvasTextLayout {
20
20
  return bbox;
21
21
  }
22
22
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight, suffix = "", wordBreak, params) {
23
- const {lineWidth: lineWidth, suffixPosition: suffixPosition = "end", measureMode: measureMode = MeasureModeEnum.actualBounding} = null != params ? params : {};
23
+ const {lineWidth: lineWidth, suffixPosition: suffixPosition = "end", measureMode: measureMode = MeasureModeEnum.actualBounding, keepCenterInLine: keepCenterInLine = !1} = null != params ? params : {};
24
24
  lines = lines.map((l => l.toString()));
25
25
  const linesLayout = [], bboxWH = [ 0, 0 ];
26
26
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
@@ -31,7 +31,8 @@ export class CanvasTextLayout {
31
31
  str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
32
32
  width: width,
33
33
  ascent: metrics.ascent,
34
- descent: metrics.descent
34
+ descent: metrics.descent,
35
+ keepCenterInLine: keepCenterInLine
35
36
  });
36
37
  }
37
38
  bboxWH[0] = lineWidth;
@@ -44,7 +45,8 @@ export class CanvasTextLayout {
44
45
  str: text,
45
46
  width: width,
46
47
  ascent: metrics.ascent,
47
- descent: metrics.descent
48
+ descent: metrics.descent,
49
+ keepCenterInLine: keepCenterInLine
48
50
  });
49
51
  }
50
52
  bboxWH[0] = _lineWidth;
@@ -74,11 +76,13 @@ export class CanvasTextLayout {
74
76
  };
75
77
  }
76
78
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
77
- "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width),
78
- line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];
79
- const actualHeightWithBuf = line.ascent + line.descent + 0;
80
- return actualHeightWithBuf < lineHeight - 0 && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)),
81
- origin[1] += lineHeight, line;
79
+ if ("left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width),
80
+ line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1],
81
+ !line.keepCenterInLine) {
82
+ const buf = 0, actualHeightWithBuf = line.ascent + line.descent + buf;
83
+ actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2));
84
+ }
85
+ return origin[1] += lineHeight, line;
82
86
  }
83
87
  }
84
88
  //# sourceMappingURL=layout.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/contributions/textMeasure/layout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,OAA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C,CAAC,CAAC,IAAI,UAAU,CAAC;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","file":"layout.js","sourcesContent":["import type { vec2 } from '@visactor/vutils';\nimport type { ITextMeasure, TextOptionsType } from '../../../interface/text';\nimport type { TextLayoutBBox, LayoutItemType, LayoutType, TextAlignType, TextBaselineType } from '../../../interface';\nimport { MeasureModeEnum } from '../../../interface';\n\nexport class CanvasTextLayout {\n private fontFamily: string;\n private textOptions: TextOptionsType;\n private textMeasure: ITextMeasure;\n\n constructor(fontFamily: string, options: TextOptionsType, textMeasure: ITextMeasure) {\n this.fontFamily = fontFamily;\n this.textOptions = options;\n this.textMeasure = textMeasure;\n }\n\n /**\n * 布局外部的盒子,盒子的alphabetic属性模拟文字的效果\n * @param bbox\n * @param textAlign\n * @param textBaseline\n * @returns\n */\n LayoutBBox(\n bbox: TextLayoutBBox,\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n linesLayout: LayoutItemType[]\n ): TextLayoutBBox {\n if (textAlign === 'left' || textAlign === 'start') {\n bbox.xOffset = 0;\n } else if (textAlign === 'center') {\n bbox.xOffset = bbox.width / -2;\n } else if (textAlign === 'right' || textAlign === 'end') {\n bbox.xOffset = -bbox.width;\n } else {\n throw new Error('非法的textAlign');\n }\n\n if (textBaseline === 'top') {\n bbox.yOffset = 0;\n } else if (textBaseline === 'middle') {\n bbox.yOffset = bbox.height / -2;\n } else if (textBaseline === 'alphabetic') {\n // 如果仅有一行,要保证和直接使用canvas绘制的textBaseline一致\n let percent = 0.79;\n if (linesLayout.length === 1) {\n const lineInfo = linesLayout[0];\n percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);\n }\n bbox.yOffset = bbox.height * -percent;\n } else {\n bbox.yOffset = -bbox.height;\n }\n\n return bbox;\n }\n\n /**\n * 给定拆分好的每行字符串进行布局,如果传入lineWidth,那么后面的字符就拆分\n * @param lines\n * @param lineWidth\n */\n GetLayoutByLines(\n lines: (string | number)[],\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n lineHeight: number,\n suffix: string = '',\n wordBreak: boolean,\n params?: {\n lineWidth?: number;\n suffixPosition?: 'start' | 'end' | 'middle';\n measureMode?: MeasureModeEnum;\n }\n ): LayoutType {\n const { lineWidth, suffixPosition = 'end', measureMode = MeasureModeEnum.actualBounding } = params ?? {};\n lines = lines.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n // bbox高度可能大于totalHeight\n const bboxWH: vec2 = [0, 0];\n if (typeof lineWidth === 'number' && lineWidth !== Infinity) {\n // 直接使用lineWidth,并拆分字符串\n let width: number;\n for (let i = 0, len = lines.length; i < len; i++) {\n const metrics = this.textMeasure.measureTextPixelADscentAndWidth(\n lines[i] as string,\n this.textOptions,\n measureMode\n );\n width = Math.min(metrics.width, lineWidth);\n linesLayout.push({\n str:\n metrics.width <= lineWidth\n ? lines[i].toString()\n : this.textMeasure.clipTextWithSuffix(\n lines[i] as string,\n this.textOptions,\n width,\n suffix,\n wordBreak,\n suffixPosition\n ).str,\n width,\n ascent: metrics.ascent,\n descent: metrics.descent\n });\n }\n bboxWH[0] = lineWidth;\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 text = lines[i] as string;\n const metrics = this.textMeasure.measureTextPixelADscentAndWidth(\n lines[i] as string,\n this.textOptions,\n measureMode\n );\n width = metrics.width;\n _lineWidth = Math.max(_lineWidth, width);\n linesLayout.push({ str: text, width, ascent: metrics.ascent, descent: metrics.descent });\n }\n bboxWH[0] = _lineWidth;\n }\n bboxWH[1] = linesLayout.length * lineHeight;\n\n bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);\n\n const bbox: TextLayoutBBox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);\n\n return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);\n }\n\n /**\n * 给定了bbox,使用拆分好的每行字符串进行布局\n * @param bbox\n * @param lines\n * @param textAlign\n * @param textBaseline\n * @param lineHeight\n * @returns\n */\n layoutWithBBox(\n bbox: TextLayoutBBox,\n lines: LayoutItemType[],\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n lineHeight: number\n ): LayoutType {\n const origin: vec2 = [0, 0];\n const totalLineHeight = lines.length * lineHeight; // 总高度\n // origin在y方向需要初始化,然后递增即可\n if (textBaseline === 'top') {\n // origin[1] = 0;\n } else if (textBaseline === 'middle') {\n origin[1] = (bbox.height - totalLineHeight) / 2;\n } else if (textBaseline === 'bottom') {\n origin[1] = bbox.height - totalLineHeight;\n }\n\n for (let i = 0; i < lines.length; i++) {\n this.lineOffset(bbox, lines[i], textAlign, textBaseline, lineHeight, origin);\n }\n\n return {\n bbox,\n lines,\n fontFamily: this.fontFamily,\n fontSize: this.textOptions.fontSize,\n fontWeight: this.textOptions.fontWeight,\n lineHeight,\n textAlign,\n textBaseline\n };\n }\n\n /**\n * 计算line在bbox中的位置,需要配合layoutWithBBox使用\n * @param bbox\n * @param line\n * @param textAlign\n * @param textBaseline\n * @param lineHeight\n * @param origin 这个line的左上角位置,会复用并修改\n */\n private lineOffset(\n bbox: TextLayoutBBox,\n line: LayoutItemType,\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n lineHeight: number,\n origin: vec2\n ): LayoutItemType {\n if (textAlign === 'left' || textAlign === 'start') {\n line.leftOffset = 0;\n } else if (textAlign === 'center') {\n line.leftOffset = (bbox.width - line.width) / 2;\n } else if (textAlign === 'right' || textAlign === 'end') {\n line.leftOffset = bbox.width - line.width;\n }\n\n line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];\n\n const actualHeight = line.ascent + line.descent;\n const buf = 0;\n const actualHeightWithBuf = actualHeight + buf;\n if (actualHeightWithBuf < lineHeight - buf) {\n if (textBaseline === 'bottom') {\n line.topOffset += (lineHeight - actualHeightWithBuf) / 2;\n } else if (textBaseline === 'top') {\n line.topOffset -= (lineHeight - actualHeightWithBuf) / 2;\n }\n }\n origin[1] += lineHeight;\n\n return line;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/core/contributions/textMeasure/layout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,OAAO,gBAAgB;IAK3B,YAAY,UAAkB,EAAE,OAAwB,EAAE,WAAyB;QACjF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IASD,UAAU,CACR,IAAoB,EACpB,SAAwB,EACxB,YAA8B,EAC9B,WAA6B;QAE7B,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,OAAO,EAAE;YACjD,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SAClB;aAAM,IAAI,SAAS,KAAK,QAAQ,EAAE;YACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;SAChC;aAAM,IAAI,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,KAAK,EAAE;YACvD,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;SAC5B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SACjC;QAED,IAAI,YAAY,KAAK,KAAK,EAAE;YAC1B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SAClB;aAAM,IAAI,YAAY,KAAK,QAAQ,EAAE;YACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACjC;aAAM,IAAI,YAAY,KAAK,YAAY,EAAE;YAExC,IAAI,OAAO,GAAG,IAAI,CAAC;YACnB,IAAI,WAAW,CAAC,MAAM,KAAK,CAA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AAY,GAAG,GAAG,CAAC;YAC/C,IAAI,mBAAmB,GAAG,UAAU,GAAG,GAAG,EAAE;gBAC1C,IAAI,YAAY,KAAK,QAAQ,EAAE;oBAC7B,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC1D;qBAAM,IAAI,YAAY,KAAK,KAAK,EAAE;oBACjC,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC1D;aACF;SACF;QAED,MAAM,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","file":"layout.js","sourcesContent":["import type { vec2 } from '@visactor/vutils';\nimport type { ITextMeasure, TextOptionsType } from '../../../interface/text';\nimport type { TextLayoutBBox, LayoutItemType, LayoutType, TextAlignType, TextBaselineType } from '../../../interface';\nimport { MeasureModeEnum } from '../../../interface';\n\nexport class CanvasTextLayout {\n private fontFamily: string;\n private textOptions: TextOptionsType;\n private textMeasure: ITextMeasure;\n\n constructor(fontFamily: string, options: TextOptionsType, textMeasure: ITextMeasure) {\n this.fontFamily = fontFamily;\n this.textOptions = options;\n this.textMeasure = textMeasure;\n }\n\n /**\n * 布局外部的盒子,盒子的alphabetic属性模拟文字的效果\n * @param bbox\n * @param textAlign\n * @param textBaseline\n * @returns\n */\n LayoutBBox(\n bbox: TextLayoutBBox,\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n linesLayout: LayoutItemType[]\n ): TextLayoutBBox {\n if (textAlign === 'left' || textAlign === 'start') {\n bbox.xOffset = 0;\n } else if (textAlign === 'center') {\n bbox.xOffset = bbox.width / -2;\n } else if (textAlign === 'right' || textAlign === 'end') {\n bbox.xOffset = -bbox.width;\n } else {\n throw new Error('非法的textAlign');\n }\n\n if (textBaseline === 'top') {\n bbox.yOffset = 0;\n } else if (textBaseline === 'middle') {\n bbox.yOffset = bbox.height / -2;\n } else if (textBaseline === 'alphabetic') {\n // 如果仅有一行,要保证和直接使用canvas绘制的textBaseline一致\n let percent = 0.79;\n if (linesLayout.length === 1) {\n const lineInfo = linesLayout[0];\n percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);\n }\n bbox.yOffset = bbox.height * -percent;\n } else {\n bbox.yOffset = -bbox.height;\n }\n\n return bbox;\n }\n\n /**\n * 给定拆分好的每行字符串进行布局,如果传入lineWidth,那么后面的字符就拆分\n * @param lines\n * @param lineWidth\n */\n GetLayoutByLines(\n lines: (string | number)[],\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n lineHeight: number,\n suffix: string = '',\n wordBreak: boolean,\n params?: {\n lineWidth?: number;\n suffixPosition?: 'start' | 'end' | 'middle';\n measureMode?: MeasureModeEnum;\n keepCenterInLine?: boolean;\n }\n ): LayoutType {\n const {\n lineWidth,\n suffixPosition = 'end',\n measureMode = MeasureModeEnum.actualBounding,\n keepCenterInLine = false\n } = params ?? {};\n lines = lines.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n // bbox高度可能大于totalHeight\n const bboxWH: vec2 = [0, 0];\n if (typeof lineWidth === 'number' && lineWidth !== Infinity) {\n // 直接使用lineWidth,并拆分字符串\n let width: number;\n for (let i = 0, len = lines.length; i < len; i++) {\n const metrics = this.textMeasure.measureTextPixelADscentAndWidth(\n lines[i] as string,\n this.textOptions,\n measureMode\n );\n width = Math.min(metrics.width, lineWidth);\n linesLayout.push({\n str:\n metrics.width <= lineWidth\n ? lines[i].toString()\n : this.textMeasure.clipTextWithSuffix(\n lines[i] as string,\n this.textOptions,\n width,\n suffix,\n wordBreak,\n suffixPosition\n ).str,\n width,\n ascent: metrics.ascent,\n descent: metrics.descent,\n keepCenterInLine\n });\n }\n bboxWH[0] = lineWidth;\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 text = lines[i] as string;\n const metrics = this.textMeasure.measureTextPixelADscentAndWidth(\n lines[i] as string,\n this.textOptions,\n measureMode\n );\n width = metrics.width;\n _lineWidth = Math.max(_lineWidth, width);\n linesLayout.push({ str: text, width, ascent: metrics.ascent, descent: metrics.descent, keepCenterInLine });\n }\n bboxWH[0] = _lineWidth;\n }\n bboxWH[1] = linesLayout.length * lineHeight;\n\n bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);\n\n const bbox: TextLayoutBBox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);\n\n return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);\n }\n\n /**\n * 给定了bbox,使用拆分好的每行字符串进行布局\n * @param bbox\n * @param lines\n * @param textAlign\n * @param textBaseline\n * @param lineHeight\n * @returns\n */\n layoutWithBBox(\n bbox: TextLayoutBBox,\n lines: LayoutItemType[],\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n lineHeight: number\n ): LayoutType {\n const origin: vec2 = [0, 0];\n const totalLineHeight = lines.length * lineHeight; // 总高度\n // origin在y方向需要初始化,然后递增即可\n if (textBaseline === 'top') {\n // origin[1] = 0;\n } else if (textBaseline === 'middle') {\n origin[1] = (bbox.height - totalLineHeight) / 2;\n } else if (textBaseline === 'bottom') {\n origin[1] = bbox.height - totalLineHeight;\n }\n\n for (let i = 0; i < lines.length; i++) {\n this.lineOffset(bbox, lines[i], textAlign, textBaseline, lineHeight, origin);\n }\n\n return {\n bbox,\n lines,\n fontFamily: this.fontFamily,\n fontSize: this.textOptions.fontSize,\n fontWeight: this.textOptions.fontWeight,\n lineHeight,\n textAlign,\n textBaseline\n };\n }\n\n /**\n * 计算line在bbox中的位置,需要配合layoutWithBBox使用\n * @param bbox\n * @param line\n * @param textAlign\n * @param textBaseline\n * @param lineHeight\n * @param origin 这个line的左上角位置,会复用并修改\n */\n private lineOffset(\n bbox: TextLayoutBBox,\n line: LayoutItemType,\n textAlign: TextAlignType,\n textBaseline: TextBaselineType,\n lineHeight: number,\n origin: vec2\n ): LayoutItemType {\n if (textAlign === 'left' || textAlign === 'start') {\n line.leftOffset = 0;\n } else if (textAlign === 'center') {\n line.leftOffset = (bbox.width - line.width) / 2;\n } else if (textAlign === 'right' || textAlign === 'end') {\n line.leftOffset = bbox.width - line.width;\n }\n\n line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];\n\n if (!line.keepCenterInLine) {\n const actualHeight = line.ascent + line.descent;\n const buf = 0;\n const actualHeightWithBuf = actualHeight + buf;\n if (actualHeightWithBuf < lineHeight - buf) {\n if (textBaseline === 'bottom') {\n line.topOffset += (lineHeight - actualHeightWithBuf) / 2;\n } else if (textBaseline === 'top') {\n line.topOffset -= (lineHeight - actualHeightWithBuf) / 2;\n }\n }\n }\n\n origin[1] += lineHeight;\n\n return line;\n }\n}\n"]}
@@ -87,7 +87,8 @@ export const DefaultTextStyle = {
87
87
  underlineDash: [],
88
88
  underlineOffset: 0,
89
89
  disableAutoClipedPoptip: void 0,
90
- measureMode: MeasureModeEnum.fontBounding
90
+ measureMode: MeasureModeEnum.fontBounding,
91
+ keepCenterInLine: !1
91
92
  };
92
93
 
93
94
  export const DefaultPickStyle = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EA8BL,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,EAAE,EAAE,CA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EACV,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,IAAI,EACd,SAAS,EAAE,YAAiC,EAC5C,iBAAiB,EAAE,KAAkC,EACrD,SAAS,EAAE,MAAiC,EAC5C,YAAY,EAAE,KAAmC,EACjD,eAAe,EAAE,YAAY,EAC7B,UAAU,EAAE,EAAE,EACd,mBAAmB,EAAE,KAAK,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,KAAK,GAClB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,iCAChC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,EAAE,EACT,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,IACN,gBAAgB,KACnB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,GAChB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,mCACpC,qBAAqB,KACxB,kBAAkB,EAAE,OAAO,EAC3B,eAAe,EAAE,CAAC,EAClB,gBAAgB,EAAE,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,QAAQ,EACtB,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,EAAE,EAEN,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,cAAc,EAAE,0BAA0B,EAC1C,qBAAqB,EAAE,CAAC,EACxB,gBAAgB,EAAE,KAAK,EACvB,uBAAuB,EAAE,CAAC,EAC1B,gBAAgB,EAAE,CAAC,EACnB,OAAO,EAAE,CAAC,GACX,CAAC","file":"config.js","sourcesContent":["// 存放公共属性\nimport { Logger, Matrix, pi2 } from '@visactor/vutils';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport {\n type IArcGraphicAttribute,\n type IAreaGraphicAttribute,\n type IGraphicAttribute,\n type ICircleGraphicAttribute,\n type IFillStyle,\n type IGlyphGraphicAttribute,\n type IGroupGraphicAttribute,\n type IImageGraphicAttribute,\n type ILineGraphicAttribute,\n type IPathGraphicAttribute,\n type IPolygonGraphicAttribute,\n type IRect3dGraphicAttribute,\n type IRectGraphicAttribute,\n type IStrokeStyle,\n type IGraphicStyle,\n type ISymbolGraphicAttribute,\n type ITextAttribute,\n type ITextGraphicAttribute,\n type IRichTextGraphicAttribute,\n type ITransform,\n type RichTextWordBreak,\n type RichTextVerticalDirection,\n type RichTextGlobalAlignType,\n type RichTextGlobalBaselineType,\n type IRichTextIconGraphicAttribute,\n type IConnectedStyle,\n type ILayout,\n type IDebugType,\n type IPickStyle,\n MeasureModeEnum\n} from '../interface';\n\nexport const DefaultLayout: ILayout = {\n alignSelf: 'auto'\n};\n\nexport const DefaultTransform: ITransform = {\n x: 0,\n y: 0,\n z: 0,\n dx: 0,\n dy: 0,\n dz: 0,\n scrollX: 0,\n scrollY: 0,\n scaleX: 1,\n scaleY: 1,\n scaleZ: 1,\n angle: 0,\n alpha: 0,\n beta: 0,\n scaleCenter: [0, 0],\n anchor: [0, 0],\n anchor3d: [0, 0],\n postMatrix: new Matrix()\n};\n\nexport const DefaultFillStyle: IFillStyle = {\n fillOpacity: 1,\n fill: false,\n shadowBlur: 0,\n shadowColor: 'black',\n shadowOffsetX: 0,\n shadowOffsetY: 0\n};\n\nconst commonStroke: Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> = {\n strokeOpacity: 1,\n lineDash: [],\n lineDashOffset: 0,\n lineWidth: 1,\n lineCap: 'butt',\n lineJoin: 'miter',\n miterLimit: 10,\n strokeBoundsBuffer: 2,\n stroke: false\n};\n\nexport const DefaultStrokeStyle: IStrokeStyle = {\n outerBorder: { ...commonStroke, distance: 0 },\n innerBorder: { ...commonStroke, distance: 0 },\n ...commonStroke\n};\n\nexport const DefaultTextStyle: Required<ITextAttribute> = {\n text: '',\n maxLineWidth: Infinity,\n maxWidth: Infinity,\n textAlign: 'left',\n textBaseline: 'alphabetic',\n fontSize: 16,\n // @ts-ignore\n fontFamily: `PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,\n Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol`,\n fontWeight: '',\n ellipsis: '…',\n fontVariant: '',\n fontStyle: '',\n lineHeight: undefined,\n underline: 0,\n lineThrough: 0,\n scaleIn3d: false,\n direction: 'horizontal',\n wordBreak: 'break-all',\n ignoreBuf: false,\n verticalMode: 0,\n wrap: false,\n whiteSpace: 'no-wrap',\n heightLimit: Infinity,\n lineClamp: Infinity,\n suffixPosition: 'end',\n underlineDash: [],\n underlineOffset: 0,\n disableAutoClipedPoptip: undefined,\n measureMode: MeasureModeEnum.fontBounding\n};\n\nexport const DefaultPickStyle: IPickStyle = {\n pickStrokeBuffer: 0\n};\n\nexport const DefaultStyle: IGraphicStyle = {\n forceBoundsWidth: undefined,\n forceBoundsHeight: undefined,\n opacity: 1,\n background: null,\n backgroundOpacity: 1,\n backgroundCornerRadius: 0,\n texture: null,\n textureColor: 'black',\n textureSize: 10,\n texturePadding: 2,\n backgroundMode: 'no-repeat',\n backgroundFit: true,\n blur: 0,\n cursor: null,\n html: null,\n react: null,\n ...DefaultFillStyle,\n ...DefaultStrokeStyle,\n ...DefaultLayout,\n ...DefaultPickStyle\n};\n\nexport const DefaultConnectAttribute: Required<IConnectedStyle> = {\n connectedType: 'none',\n // connectedStyle: {\n // stroke: DefaultStrokeStyle.stroke,\n // strokeOpacity: DefaultStrokeStyle.strokeOpacity,\n // lineDash: DefaultStrokeStyle.lineDash,\n // lineDashOffset: DefaultStrokeStyle.lineDashOffset,\n // lineCap: DefaultStrokeStyle.lineCap,\n // lineJoin: DefaultStrokeStyle.lineJoin,\n // lineWidth: DefaultStrokeStyle.lineWidth,\n // fill: DefaultFillStyle.fill,\n // fillOpacity: DefaultFillStyle.fillOpacity\n // },\n connectedStyle: {}, // 默认全都继承父属性\n connectedX: NaN,\n connectedY: NaN\n} as IConnectedStyle;\n\nexport const DefaultDebugAttribute: Required<IDebugType> = {\n _debug_bounds: false\n};\n\nexport const DefaultAttribute: Required<IGraphicAttribute> = {\n strokeSeg: null,\n renderable: true,\n pickable: true,\n shadowGraphic: undefined,\n childrenPickable: true,\n fillPickable: true,\n strokePickable: true,\n visible: true,\n zIndex: 0,\n layout: null,\n boundsPadding: 0,\n fillStrokeOrder: 0,\n renderStyle: 'default',\n pickMode: 'accurate',\n customPickShape: null,\n boundsMode: 'accurate',\n keepDirIn3d: true,\n shadowRootIdx: 1,\n globalZIndex: 1,\n globalCompositeOperation: '',\n overflow: 'hidden',\n shadowPickMode: 'graphic',\n keepStrokeScale: false,\n ...DefaultDebugAttribute,\n ...DefaultStyle,\n ...DefaultTransform\n};\n\nexport function addAttributeToPrototype(obj: Record<string, any>, c: any, keys: string[]) {\n keys.forEach(key => {\n c.prototype[key] = obj[key];\n });\n}\nexport function rewriteProto(obj: Record<string, any>, c: Record<string, any>) {\n Object.setPrototypeOf(obj, c);\n}\n\nexport const DefaultArcAttribute: Required<IArcGraphicAttribute> = {\n ...DefaultAttribute,\n startAngle: 0,\n endAngle: pi2,\n innerRadius: 0,\n outerRadius: 1,\n innerPadding: 0,\n outerPadding: 0,\n cornerRadius: 0,\n padRadius: 0,\n padAngle: 0,\n cap: false,\n forceShowCap: false\n};\n\nexport const DefaultAreaAttribute: Required<IAreaGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultConnectAttribute,\n points: [],\n segments: [],\n curveType: 'linear',\n clipRange: 1,\n closePath: false,\n curveTension: 1\n};\n\nexport const DefaultCircleAttribute: Required<ICircleGraphicAttribute> = {\n ...DefaultAttribute,\n radius: 1,\n startAngle: 0,\n endAngle: pi2\n};\n\nexport const DefaultGroupAttribute: Required<IGroupGraphicAttribute> = {\n ...DefaultAttribute,\n width: 0,\n height: 0,\n cornerRadius: 0,\n path: [],\n clip: false,\n visibleAll: true,\n display: 'relative',\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n alignContent: 'flex-start',\n baseOpacity: 1\n};\n\nexport const DefaultGlyphAttribute: Required<IGlyphGraphicAttribute> = {\n ...DefaultAttribute,\n path: '',\n width: 0,\n height: 0,\n cornerRadius: 0,\n clip: false\n};\n\nexport const DefaultLineAttribute: Required<ILineGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultConnectAttribute,\n points: [],\n segments: [],\n curveType: 'linear',\n clipRange: 1,\n clipRangeByDimension: 'default',\n closePath: false,\n curveTension: 1\n};\n\nexport const DefaultPathAttribute: Required<IPathGraphicAttribute> = {\n ...DefaultAttribute,\n path: new CustomPath2D(),\n fillStrokeOrder: 1,\n customPath: () => {\n Logger.getInstance().warn('空函数');\n }\n};\n\nexport const DefaultPolygonAttribute: Required<IPolygonGraphicAttribute> = {\n ...DefaultAttribute,\n points: [],\n cornerRadius: 0,\n closePath: true\n};\n\nexport const DefaultRectAttribute: Required<IRectGraphicAttribute> = {\n ...DefaultAttribute,\n width: 0,\n height: 0,\n x1: 0,\n y1: 0,\n strokeBoundsBuffer: 0,\n cornerRadius: 0\n};\n\nexport const DefaultRect3dAttribute: Required<IRect3dGraphicAttribute> = {\n ...DefaultAttribute,\n width: 0,\n height: 0,\n x1: 0,\n y1: 0,\n cornerRadius: 0,\n length: 0\n};\n\nexport const DefaultSymbolAttribute: Required<ISymbolGraphicAttribute> = {\n ...DefaultAttribute,\n symbolType: 'circle',\n size: 10, // 外接**正方形**的边长\n keepDirIn3d: true\n};\n\nexport const DefaultTextAttribute: Required<ITextGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultTextStyle,\n strokeBoundsBuffer: 0,\n keepDirIn3d: true\n};\n\nexport const DefaultRichTextAttribute: Required<IRichTextGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultTextStyle,\n editable: false,\n width: 300,\n height: 300,\n ellipsis: true,\n wordBreak: 'break-word' as RichTextWordBreak,\n verticalDirection: 'top' as RichTextVerticalDirection,\n textAlign: 'left' as RichTextGlobalAlignType,\n textBaseline: 'top' as RichTextGlobalBaselineType,\n layoutDirection: 'horizontal',\n textConfig: [],\n disableAutoWrapLine: false,\n maxHeight: undefined,\n maxWidth: undefined,\n singleLine: false\n};\n\nexport const DefaultImageAttribute: Required<IImageGraphicAttribute> = {\n repeatX: 'no-repeat',\n repeatY: 'no-repeat',\n image: '',\n width: 0,\n height: 0,\n ...DefaultAttribute,\n fill: true,\n cornerRadius: 0\n};\n\nexport const DefaultRichTextIconAttribute: Required<IRichTextIconGraphicAttribute> = {\n ...DefaultImageAttribute,\n backgroundShowMode: 'never',\n backgroundWidth: 0,\n backgroundHeight: 0,\n textAlign: 'left',\n textBaseline: 'middle',\n direction: 'horizontal',\n margin: 0,\n id: '',\n\n width: 20,\n height: 20,\n backgroundFill: 'rgba(101, 117, 168, 0.1)',\n backgroundFillOpacity: 1,\n backgroundStroke: false,\n backgroundStrokeOpacity: 1,\n backgroundRadius: 4,\n opacity: 1\n};\n"]}
1
+ {"version":3,"sources":["../src/graphic/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EA8BL,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,WAAW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AE,KAAK,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,KAAK,GAClB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,iCAChC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,EAAE,EACT,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,IACN,gBAAgB,KACnB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,GAChB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,mCACpC,qBAAqB,KACxB,kBAAkB,EAAE,OAAO,EAC3B,eAAe,EAAE,CAAC,EAClB,gBAAgB,EAAE,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,QAAQ,EACtB,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,EAAE,EAEN,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,cAAc,EAAE,0BAA0B,EAC1C,qBAAqB,EAAE,CAAC,EACxB,gBAAgB,EAAE,KAAK,EACvB,uBAAuB,EAAE,CAAC,EAC1B,gBAAgB,EAAE,CAAC,EACnB,OAAO,EAAE,CAAC,GACX,CAAC","file":"config.js","sourcesContent":["// 存放公共属性\nimport { Logger, Matrix, pi2 } from '@visactor/vutils';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport {\n type IArcGraphicAttribute,\n type IAreaGraphicAttribute,\n type IGraphicAttribute,\n type ICircleGraphicAttribute,\n type IFillStyle,\n type IGlyphGraphicAttribute,\n type IGroupGraphicAttribute,\n type IImageGraphicAttribute,\n type ILineGraphicAttribute,\n type IPathGraphicAttribute,\n type IPolygonGraphicAttribute,\n type IRect3dGraphicAttribute,\n type IRectGraphicAttribute,\n type IStrokeStyle,\n type IGraphicStyle,\n type ISymbolGraphicAttribute,\n type ITextAttribute,\n type ITextGraphicAttribute,\n type IRichTextGraphicAttribute,\n type ITransform,\n type RichTextWordBreak,\n type RichTextVerticalDirection,\n type RichTextGlobalAlignType,\n type RichTextGlobalBaselineType,\n type IRichTextIconGraphicAttribute,\n type IConnectedStyle,\n type ILayout,\n type IDebugType,\n type IPickStyle,\n MeasureModeEnum\n} from '../interface';\n\nexport const DefaultLayout: ILayout = {\n alignSelf: 'auto'\n};\n\nexport const DefaultTransform: ITransform = {\n x: 0,\n y: 0,\n z: 0,\n dx: 0,\n dy: 0,\n dz: 0,\n scrollX: 0,\n scrollY: 0,\n scaleX: 1,\n scaleY: 1,\n scaleZ: 1,\n angle: 0,\n alpha: 0,\n beta: 0,\n scaleCenter: [0, 0],\n anchor: [0, 0],\n anchor3d: [0, 0],\n postMatrix: new Matrix()\n};\n\nexport const DefaultFillStyle: IFillStyle = {\n fillOpacity: 1,\n fill: false,\n shadowBlur: 0,\n shadowColor: 'black',\n shadowOffsetX: 0,\n shadowOffsetY: 0\n};\n\nconst commonStroke: Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> = {\n strokeOpacity: 1,\n lineDash: [],\n lineDashOffset: 0,\n lineWidth: 1,\n lineCap: 'butt',\n lineJoin: 'miter',\n miterLimit: 10,\n strokeBoundsBuffer: 2,\n stroke: false\n};\n\nexport const DefaultStrokeStyle: IStrokeStyle = {\n outerBorder: { ...commonStroke, distance: 0 },\n innerBorder: { ...commonStroke, distance: 0 },\n ...commonStroke\n};\n\nexport const DefaultTextStyle: Required<ITextAttribute> = {\n text: '',\n maxLineWidth: Infinity,\n maxWidth: Infinity,\n textAlign: 'left',\n textBaseline: 'alphabetic',\n fontSize: 16,\n // @ts-ignore\n fontFamily: `PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,\n Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol`,\n fontWeight: '',\n ellipsis: '…',\n fontVariant: '',\n fontStyle: '',\n lineHeight: undefined,\n underline: 0,\n lineThrough: 0,\n scaleIn3d: false,\n direction: 'horizontal',\n wordBreak: 'break-all',\n ignoreBuf: false,\n verticalMode: 0,\n wrap: false,\n whiteSpace: 'no-wrap',\n heightLimit: Infinity,\n lineClamp: Infinity,\n suffixPosition: 'end',\n underlineDash: [],\n underlineOffset: 0,\n disableAutoClipedPoptip: undefined,\n measureMode: MeasureModeEnum.fontBounding,\n keepCenterInLine: false\n};\n\nexport const DefaultPickStyle: IPickStyle = {\n pickStrokeBuffer: 0\n};\n\nexport const DefaultStyle: IGraphicStyle = {\n forceBoundsWidth: undefined,\n forceBoundsHeight: undefined,\n opacity: 1,\n background: null,\n backgroundOpacity: 1,\n backgroundCornerRadius: 0,\n texture: null,\n textureColor: 'black',\n textureSize: 10,\n texturePadding: 2,\n backgroundMode: 'no-repeat',\n backgroundFit: true,\n blur: 0,\n cursor: null,\n html: null,\n react: null,\n ...DefaultFillStyle,\n ...DefaultStrokeStyle,\n ...DefaultLayout,\n ...DefaultPickStyle\n};\n\nexport const DefaultConnectAttribute: Required<IConnectedStyle> = {\n connectedType: 'none',\n // connectedStyle: {\n // stroke: DefaultStrokeStyle.stroke,\n // strokeOpacity: DefaultStrokeStyle.strokeOpacity,\n // lineDash: DefaultStrokeStyle.lineDash,\n // lineDashOffset: DefaultStrokeStyle.lineDashOffset,\n // lineCap: DefaultStrokeStyle.lineCap,\n // lineJoin: DefaultStrokeStyle.lineJoin,\n // lineWidth: DefaultStrokeStyle.lineWidth,\n // fill: DefaultFillStyle.fill,\n // fillOpacity: DefaultFillStyle.fillOpacity\n // },\n connectedStyle: {}, // 默认全都继承父属性\n connectedX: NaN,\n connectedY: NaN\n} as IConnectedStyle;\n\nexport const DefaultDebugAttribute: Required<IDebugType> = {\n _debug_bounds: false\n};\n\nexport const DefaultAttribute: Required<IGraphicAttribute> = {\n strokeSeg: null,\n renderable: true,\n pickable: true,\n shadowGraphic: undefined,\n childrenPickable: true,\n fillPickable: true,\n strokePickable: true,\n visible: true,\n zIndex: 0,\n layout: null,\n boundsPadding: 0,\n fillStrokeOrder: 0,\n renderStyle: 'default',\n pickMode: 'accurate',\n customPickShape: null,\n boundsMode: 'accurate',\n keepDirIn3d: true,\n shadowRootIdx: 1,\n globalZIndex: 1,\n globalCompositeOperation: '',\n overflow: 'hidden',\n shadowPickMode: 'graphic',\n keepStrokeScale: false,\n ...DefaultDebugAttribute,\n ...DefaultStyle,\n ...DefaultTransform\n};\n\nexport function addAttributeToPrototype(obj: Record<string, any>, c: any, keys: string[]) {\n keys.forEach(key => {\n c.prototype[key] = obj[key];\n });\n}\nexport function rewriteProto(obj: Record<string, any>, c: Record<string, any>) {\n Object.setPrototypeOf(obj, c);\n}\n\nexport const DefaultArcAttribute: Required<IArcGraphicAttribute> = {\n ...DefaultAttribute,\n startAngle: 0,\n endAngle: pi2,\n innerRadius: 0,\n outerRadius: 1,\n innerPadding: 0,\n outerPadding: 0,\n cornerRadius: 0,\n padRadius: 0,\n padAngle: 0,\n cap: false,\n forceShowCap: false\n};\n\nexport const DefaultAreaAttribute: Required<IAreaGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultConnectAttribute,\n points: [],\n segments: [],\n curveType: 'linear',\n clipRange: 1,\n closePath: false,\n curveTension: 1\n};\n\nexport const DefaultCircleAttribute: Required<ICircleGraphicAttribute> = {\n ...DefaultAttribute,\n radius: 1,\n startAngle: 0,\n endAngle: pi2\n};\n\nexport const DefaultGroupAttribute: Required<IGroupGraphicAttribute> = {\n ...DefaultAttribute,\n width: 0,\n height: 0,\n cornerRadius: 0,\n path: [],\n clip: false,\n visibleAll: true,\n display: 'relative',\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n alignContent: 'flex-start',\n baseOpacity: 1\n};\n\nexport const DefaultGlyphAttribute: Required<IGlyphGraphicAttribute> = {\n ...DefaultAttribute,\n path: '',\n width: 0,\n height: 0,\n cornerRadius: 0,\n clip: false\n};\n\nexport const DefaultLineAttribute: Required<ILineGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultConnectAttribute,\n points: [],\n segments: [],\n curveType: 'linear',\n clipRange: 1,\n clipRangeByDimension: 'default',\n closePath: false,\n curveTension: 1\n};\n\nexport const DefaultPathAttribute: Required<IPathGraphicAttribute> = {\n ...DefaultAttribute,\n path: new CustomPath2D(),\n fillStrokeOrder: 1,\n customPath: () => {\n Logger.getInstance().warn('空函数');\n }\n};\n\nexport const DefaultPolygonAttribute: Required<IPolygonGraphicAttribute> = {\n ...DefaultAttribute,\n points: [],\n cornerRadius: 0,\n closePath: true\n};\n\nexport const DefaultRectAttribute: Required<IRectGraphicAttribute> = {\n ...DefaultAttribute,\n width: 0,\n height: 0,\n x1: 0,\n y1: 0,\n strokeBoundsBuffer: 0,\n cornerRadius: 0\n};\n\nexport const DefaultRect3dAttribute: Required<IRect3dGraphicAttribute> = {\n ...DefaultAttribute,\n width: 0,\n height: 0,\n x1: 0,\n y1: 0,\n cornerRadius: 0,\n length: 0\n};\n\nexport const DefaultSymbolAttribute: Required<ISymbolGraphicAttribute> = {\n ...DefaultAttribute,\n symbolType: 'circle',\n size: 10, // 外接**正方形**的边长\n keepDirIn3d: true\n};\n\nexport const DefaultTextAttribute: Required<ITextGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultTextStyle,\n strokeBoundsBuffer: 0,\n keepDirIn3d: true\n};\n\nexport const DefaultRichTextAttribute: Required<IRichTextGraphicAttribute> = {\n ...DefaultAttribute,\n ...DefaultTextStyle,\n editable: false,\n width: 300,\n height: 300,\n ellipsis: true,\n wordBreak: 'break-word' as RichTextWordBreak,\n verticalDirection: 'top' as RichTextVerticalDirection,\n textAlign: 'left' as RichTextGlobalAlignType,\n textBaseline: 'top' as RichTextGlobalBaselineType,\n layoutDirection: 'horizontal',\n textConfig: [],\n disableAutoWrapLine: false,\n maxHeight: undefined,\n maxWidth: undefined,\n singleLine: false\n};\n\nexport const DefaultImageAttribute: Required<IImageGraphicAttribute> = {\n repeatX: 'no-repeat',\n repeatY: 'no-repeat',\n image: '',\n width: 0,\n height: 0,\n ...DefaultAttribute,\n fill: true,\n cornerRadius: 0\n};\n\nexport const DefaultRichTextIconAttribute: Required<IRichTextIconGraphicAttribute> = {\n ...DefaultImageAttribute,\n backgroundShowMode: 'never',\n backgroundWidth: 0,\n backgroundHeight: 0,\n textAlign: 'left',\n textBaseline: 'middle',\n direction: 'horizontal',\n margin: 0,\n id: '',\n\n width: 20,\n height: 20,\n backgroundFill: 'rgba(101, 117, 168, 0.1)',\n backgroundFillOpacity: 1,\n backgroundStroke: false,\n backgroundStrokeOpacity: 1,\n backgroundRadius: 4,\n opacity: 1\n};\n"]}
@@ -118,7 +118,7 @@ export class Text extends Graphic {
118
118
  }
119
119
  updateHorizontalMultilineAABBBounds(text) {
120
120
  var _a;
121
- const textTheme = this.getGraphicTheme(), attribute = this.attribute, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, fontWeight: fontWeight = textTheme.fontWeight, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, wrap: wrap = textTheme.wrap, measureMode: measureMode = textTheme.measureMode, lineWidth: lineWidth = textTheme.lineWidth, whiteSpace: whiteSpace = textTheme.whiteSpace, suffixPosition: suffixPosition = textTheme.suffixPosition, ignoreBuf: ignoreBuf = textTheme.ignoreBuf} = attribute, buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize), lineHeight = this.getLineHeight(attribute, textTheme) + buf;
121
+ const textTheme = this.getGraphicTheme(), attribute = this.attribute, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, fontWeight: fontWeight = textTheme.fontWeight, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, wrap: wrap = textTheme.wrap, measureMode: measureMode = textTheme.measureMode, lineWidth: lineWidth = textTheme.lineWidth, whiteSpace: whiteSpace = textTheme.whiteSpace, suffixPosition: suffixPosition = textTheme.suffixPosition, ignoreBuf: ignoreBuf = textTheme.ignoreBuf, keepCenterInLine: keepCenterInLine = textTheme.keepCenterInLine} = attribute, buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize), lineHeight = this.getLineHeight(attribute, textTheme) + buf;
122
122
  if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
123
123
  if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
124
124
  const bbox = this.cache.layoutData.bbox;
@@ -133,14 +133,15 @@ export class Text extends Graphic {
133
133
  }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
134
134
  lineWidth: maxLineWidth,
135
135
  suffixPosition: suffixPosition,
136
- measureMode: measureMode
136
+ measureMode: measureMode,
137
+ keepCenterInLine: keepCenterInLine
137
138
  }), {bbox: bbox} = layoutData;
138
139
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
139
140
  stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
140
141
  }
141
142
  updateWrapAABBBounds(text) {
142
143
  var _a, _b, _c;
143
- const textTheme = this.getGraphicTheme(), {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, wordBreak: wordBreak = textTheme.wordBreak, fontWeight: fontWeight = textTheme.fontWeight, ignoreBuf: ignoreBuf = textTheme.ignoreBuf, measureMode: measureMode = textTheme.measureMode, suffixPosition: suffixPosition = textTheme.suffixPosition, heightLimit: heightLimit = 0, lineClamp: lineClamp} = this.attribute, buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize), lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
144
+ const textTheme = this.getGraphicTheme(), {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, wordBreak: wordBreak = textTheme.wordBreak, fontWeight: fontWeight = textTheme.fontWeight, ignoreBuf: ignoreBuf = textTheme.ignoreBuf, measureMode: measureMode = textTheme.measureMode, suffixPosition: suffixPosition = textTheme.suffixPosition, heightLimit: heightLimit = 0, lineClamp: lineClamp, keepCenterInLine: keepCenterInLine = textTheme.keepCenterInLine} = this.attribute, buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize), lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
144
145
  if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
145
146
  const bbox = this.cache.layoutData.bbox;
146
147
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
@@ -164,7 +165,8 @@ export class Text extends Graphic {
164
165
  str: clip.str,
165
166
  width: clip.width,
166
167
  ascent: matrics.ascent,
167
- descent: matrics.descent
168
+ descent: matrics.descent,
169
+ keepCenterInLine: keepCenterInLine
168
170
  });
169
171
  break;
170
172
  }
@@ -181,7 +183,8 @@ export class Text extends Graphic {
181
183
  str: clip.str,
182
184
  width: clip.width,
183
185
  ascent: matrics.ascent,
184
- descent: matrics.descent
186
+ descent: matrics.descent,
187
+ keepCenterInLine: keepCenterInLine
185
188
  });
186
189
  let cutLength = clip.str.length;
187
190
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked),
@@ -203,7 +206,8 @@ export class Text extends Graphic {
203
206
  str: clip.str,
204
207
  width: clip.width,
205
208
  ascent: matrics.ascent,
206
- descent: matrics.descent
209
+ descent: matrics.descent,
210
+ keepCenterInLine: keepCenterInLine
207
211
  }), lineWidth = Math.max(lineWidth, clip.width);
208
212
  break;
209
213
  }
@@ -213,7 +217,8 @@ export class Text extends Graphic {
213
217
  str: text,
214
218
  width: width,
215
219
  ascent: matrics.ascent,
216
- descent: matrics.descent
220
+ descent: matrics.descent,
221
+ keepCenterInLine: keepCenterInLine
217
222
  });
218
223
  }
219
224
  bboxWH[0] = lineWidth;