@visactor/vrender 0.21.0-alpha.4 → 0.21.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -3913,6 +3913,7 @@ const DefaultStrokeStyle = Object.assign({
3913
3913
  const DefaultTextStyle = {
3914
3914
  text: "",
3915
3915
  maxLineWidth: 1 / 0,
3916
+ maxWidth: 1 / 0,
3916
3917
  textAlign: "left",
3917
3918
  textBaseline: "alphabetic",
3918
3919
  fontSize: 16,
@@ -3990,7 +3991,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
3990
3991
  globalZIndex: 1,
3991
3992
  globalCompositeOperation: "",
3992
3993
  overflow: "hidden",
3993
- shadowPickMode: "graphic"
3994
+ shadowPickMode: "graphic",
3995
+ keepStrokeScale: !1
3994
3996
  }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
3995
3997
  function addAttributeToPrototype(obj, c, keys) {
3996
3998
  keys.forEach(key => {
@@ -4265,10 +4267,32 @@ let ATextMeasure = class {
4265
4267
  configure(service, env) {
4266
4268
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4267
4269
  }
4268
- measureTextWidth(text, options) {
4269
- if (!this.context) return this.estimate(text, options).width;
4270
+ _measureTextWithoutAlignBaseline(text, options, compatible) {
4270
4271
  this.context.setTextStyleWithoutAlignBaseline(options);
4271
- return this.context.measureText(text).width;
4272
+ const metrics = this.context.measureText(text);
4273
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4274
+ }
4275
+ _measureTextWithAlignBaseline(text, options, compatible) {
4276
+ this.context.setTextStyle(options);
4277
+ const metrics = this.context.measureText(text);
4278
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4279
+ }
4280
+ compatibleMetrics(metrics, options) {
4281
+ if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4282
+ const {
4283
+ ascent: ascent,
4284
+ descent: descent
4285
+ } = this.measureTextBoundADscentEstimate(options);
4286
+ metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4287
+ }
4288
+ if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4289
+ const {
4290
+ left: left,
4291
+ right: right
4292
+ } = this.measureTextBoundLeftRightEstimate(options);
4293
+ metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
4294
+ }
4295
+ return metrics;
4272
4296
  }
4273
4297
  estimate(text, _ref) {
4274
4298
  let {
@@ -4282,19 +4306,85 @@ let ATextMeasure = class {
4282
4306
  height: fontSize
4283
4307
  };
4284
4308
  }
4285
- measureTextPixelHeight(text, options) {
4309
+ measureTextWidth(text, options, textMeasure) {
4310
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4311
+ }
4312
+ measureTextBoundsWidth(text, options, textMeasure) {
4313
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4314
+ }
4315
+ measureTextBoundsLeftRight(text, options, textMeasure) {
4316
+ return this.context ? {
4317
+ left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
4318
+ right: textMeasure.actualBoundingBoxRight
4319
+ } : this.measureTextBoundLeftRightEstimate(options);
4320
+ }
4321
+ measureTextPixelHeight(text, options, textMeasure) {
4286
4322
  var _a;
4287
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4288
- this.context.setTextStyleWithoutAlignBaseline(options);
4289
- const textMeasure = this.context.measureText(text);
4290
- return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
4323
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4291
4324
  }
4292
- measureTextBoundHieght(text, options) {
4325
+ measureTextPixelADscent(text, options, textMeasure) {
4326
+ return this.context ? {
4327
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
4328
+ descent: textMeasure.actualBoundingBoxDescent
4329
+ } : this.measureTextBoundADscentEstimate(options);
4330
+ }
4331
+ measureTextBoundHieght(text, options, textMeasure) {
4293
4332
  var _a;
4294
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4295
- this.context.setTextStyleWithoutAlignBaseline(options);
4296
- const textMeasure = this.context.measureText(text);
4297
- return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
4333
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4334
+ }
4335
+ measureTextBoundADscent(text, options, textMeasure) {
4336
+ return this.context ? {
4337
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
4338
+ descent: textMeasure.fontBoundingBoxDescent
4339
+ } : this.measureTextBoundADscentEstimate(options);
4340
+ }
4341
+ measureTextBoundADscentEstimate(options) {
4342
+ var _a;
4343
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4344
+ {
4345
+ textBaseline: textBaseline
4346
+ } = options;
4347
+ return "bottom" === textBaseline ? {
4348
+ ascent: fontSize,
4349
+ descent: 0
4350
+ } : "middle" === textBaseline ? {
4351
+ ascent: fontSize / 2,
4352
+ descent: fontSize / 2
4353
+ } : "alphabetic" === textBaseline ? {
4354
+ ascent: .79 * fontSize,
4355
+ descent: .21 * fontSize
4356
+ } : {
4357
+ ascent: 0,
4358
+ descent: fontSize
4359
+ };
4360
+ }
4361
+ measureTextBoundLeftRightEstimate(options) {
4362
+ var _a;
4363
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4364
+ {
4365
+ textAlign: textAlign
4366
+ } = options;
4367
+ return "center" === textAlign ? {
4368
+ left: fontSize / 2,
4369
+ right: fontSize / 2
4370
+ } : "right" === textAlign || "end" === textAlign ? {
4371
+ left: fontSize,
4372
+ right: 0
4373
+ } : {
4374
+ left: 0,
4375
+ right: fontSize
4376
+ };
4377
+ }
4378
+ measureTextPixelADscentAndWidth(text, options) {
4379
+ if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4380
+ width: this.estimate(text, options).width
4381
+ });
4382
+ const out = this._measureTextWithoutAlignBaseline(text, options, !0);
4383
+ return {
4384
+ ascent: out.actualBoundingBoxAscent,
4385
+ descent: out.actualBoundingBoxDescent,
4386
+ width: out.width
4387
+ };
4298
4388
  }
4299
4389
  measureText(text, options) {
4300
4390
  return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
@@ -6406,7 +6496,7 @@ class TimeOutTickHandler {
6406
6496
  }
6407
6497
  }
6408
6498
 
6409
- class DefaultTicker {
6499
+ class DefaultTicker extends EventEmitter {
6410
6500
  set mode(m) {
6411
6501
  this._mode !== m && (this._mode = m, this.setupTickHandler());
6412
6502
  }
@@ -6415,17 +6505,17 @@ class DefaultTicker {
6415
6505
  }
6416
6506
  constructor() {
6417
6507
  let timelines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6418
- this.handleTick = (handler, params) => {
6508
+ super(), this.handleTick = (handler, params) => {
6419
6509
  const {
6420
6510
  once = !1
6421
6511
  } = null != params ? params : {};
6422
- this.ifCanStop() ? this.stop() : (this._handlerTick(handler), once || handler.tick(this.interval, this.handleTick));
6423
- }, this._handlerTick = handler => {
6512
+ this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
6513
+ }, this._handlerTick = () => {
6424
6514
  const time = this.tickerHandler.getTime();
6425
6515
  let delta = 0;
6426
6516
  this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
6427
6517
  t.tick(delta);
6428
- }));
6518
+ }), this.emit("afterTick"));
6429
6519
  }, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.timelines = timelines, this.autoStop = !0;
6430
6520
  }
6431
6521
  init() {
@@ -6521,6 +6611,9 @@ class DefaultTicker {
6521
6611
  stop() {
6522
6612
  this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
6523
6613
  }
6614
+ trySyncTickStatus() {
6615
+ this.status === STATUS$1.RUNNING && this._handlerTick();
6616
+ }
6524
6617
  }
6525
6618
 
6526
6619
  class ManualTickHandler {
@@ -7662,7 +7755,7 @@ class TagPointsUpdate extends ACustomAnimate {
7662
7755
  lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
7663
7756
  break;
7664
7757
  }
7665
- "clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
7758
+ "clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], 1 === this.clipRange && (this.shrinkClipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension]), isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
7666
7759
  let prevMatchedPoint = this.toPoints[0];
7667
7760
  this.interpolatePoints = this.toPoints.map((point, index) => {
7668
7761
  const matchedPoint = tagMap.get(point.context);
@@ -7674,11 +7767,19 @@ class TagPointsUpdate extends ACustomAnimate {
7674
7767
  return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
7675
7768
  });
7676
7769
  }
7770
+ onFirstRun() {
7771
+ const lastClipRange = this.target.attribute.clipRange;
7772
+ isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
7773
+ }
7677
7774
  onUpdate(end, ratio, out) {
7678
7775
  if (this.points = this.points.map((point, index) => {
7679
7776
  const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
7680
7777
  return newPoint.context = point.context, newPoint;
7681
- }), this.clipRange && (out.clipRange = this.clipRange + (1 - this.clipRange) * ratio), this.segmentsCache && this.to.segments) {
7778
+ }), this.clipRange) {
7779
+ if (this.shrinkClipRange) return void (end ? (out.points = this.toPoints, out.clipRange = 1) : (out.points = this.fromPoints, out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio));
7780
+ out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
7781
+ }
7782
+ if (this.segmentsCache && this.to.segments) {
7682
7783
  let start = 0;
7683
7784
  out.segments = this.to.segments.map((segment, index) => {
7684
7785
  const end = start + this.segmentsCache[index],
@@ -9094,7 +9195,7 @@ class ResourceLoader {
9094
9195
  }
9095
9196
  static GetFile(url, type) {
9096
9197
  let data = ResourceLoader.cache.get(url);
9097
- return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
9198
+ return data ? "init" === data.loadState || "fail" === data.loadState ? Promise.reject() : "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
9098
9199
  type: type,
9099
9200
  loadState: "init"
9100
9201
  }, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
@@ -12032,7 +12133,8 @@ class DefaultArcRenderContribution {
12032
12133
  x: originX = arcAttribute.x,
12033
12134
  y: originY = arcAttribute.y,
12034
12135
  scaleX = arcAttribute.scaleX,
12035
- scaleY = arcAttribute.scaleY
12136
+ scaleY = arcAttribute.scaleY,
12137
+ keepStrokeScale = arcAttribute.keepStrokeScale
12036
12138
  } = arc.attribute;
12037
12139
  let {
12038
12140
  innerRadius = arcAttribute.innerRadius,
@@ -12044,7 +12146,7 @@ class DefaultArcRenderContribution {
12044
12146
  {
12045
12147
  distance = arcAttribute[key].distance
12046
12148
  } = borderStyle,
12047
- d = getScaledStroke(context, distance, context.dpr),
12149
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12048
12150
  deltaAngle = distance / outerRadius,
12049
12151
  sign = "outerBorder" === key ? 1 : -1;
12050
12152
  if (arc.setAttributes({
@@ -12089,14 +12191,15 @@ class DefaultCircleRenderContribution {
12089
12191
  x: originX = circleAttribute.x,
12090
12192
  y: originY = circleAttribute.y,
12091
12193
  scaleX = circleAttribute.scaleX,
12092
- scaleY = circleAttribute.scaleY
12194
+ scaleY = circleAttribute.scaleY,
12195
+ keepStrokeScale = circleAttribute.keepStrokeScale
12093
12196
  } = circle.attribute,
12094
12197
  renderBorder = (borderStyle, key) => {
12095
12198
  const doStroke = !(!borderStyle || !borderStyle.stroke),
12096
12199
  {
12097
12200
  distance = circleAttribute[key].distance
12098
12201
  } = borderStyle,
12099
- d = getScaledStroke(context, distance, context.dpr),
12202
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12100
12203
  sign = "outerBorder" === key ? 1 : -1;
12101
12204
  if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
12102
12205
  const lastOpacity = circleAttribute[key].opacity;
@@ -12215,7 +12318,8 @@ class DefaultRectRenderContribution {
12215
12318
  scaleX = rectAttribute.scaleX,
12216
12319
  scaleY = rectAttribute.scaleY,
12217
12320
  x1: x1,
12218
- y1: y1
12321
+ y1: y1,
12322
+ keepStrokeScale = rectAttribute.keepStrokeScale
12219
12323
  } = rect.attribute;
12220
12324
  let {
12221
12325
  width: width,
@@ -12228,7 +12332,7 @@ class DefaultRectRenderContribution {
12228
12332
  {
12229
12333
  distance = rectAttribute[key].distance
12230
12334
  } = borderStyle,
12231
- d = getScaledStroke(context, distance, context.dpr),
12335
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12232
12336
  nextX = x + sign * d,
12233
12337
  nextY = y + sign * d,
12234
12338
  dw = 2 * d;
@@ -12358,9 +12462,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
12358
12462
  constructor() {
12359
12463
  super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
12360
12464
  }
12361
- drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
12362
- if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12363
- image.renderFrame(context, x, y);
12465
+ drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
12466
+ return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12364
12467
  }
12365
12468
  }
12366
12469
  const defaultImageRenderContribution = new DefaultImageRenderContribution();
@@ -12386,14 +12489,15 @@ class DefaultSymbolRenderContribution {
12386
12489
  x: originX = symbolAttribute.x,
12387
12490
  y: originY = symbolAttribute.y,
12388
12491
  scaleX = symbolAttribute.scaleX,
12389
- scaleY = symbolAttribute.scaleY
12492
+ scaleY = symbolAttribute.scaleY,
12493
+ keepStrokeScale = symbolAttribute.keepStrokeScale
12390
12494
  } = symbol.attribute,
12391
12495
  renderBorder = (borderStyle, key) => {
12392
12496
  const doStroke = !(!borderStyle || !borderStyle.stroke),
12393
12497
  {
12394
12498
  distance = symbolAttribute[key].distance
12395
12499
  } = borderStyle,
12396
- d = getScaledStroke(context, distance, context.dpr),
12500
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12397
12501
  sign = "outerBorder" === key ? 1 : -1;
12398
12502
  if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
12399
12503
  const lastOpacity = symbolAttribute[key].opacity;
@@ -13671,16 +13775,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
13671
13775
  verticalMode = textAttribute.verticalMode,
13672
13776
  x: originX = textAttribute.x,
13673
13777
  y: originY = textAttribute.y
13674
- } = text.attribute;
13675
- let {
13676
- textAlign = textAttribute.textAlign,
13677
- textBaseline = textAttribute.textBaseline
13678
- } = text.attribute;
13679
- if (!verticalMode && "vertical" === direction) {
13680
- const t = textAlign;
13681
- textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
13682
- }
13683
- const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
13778
+ } = text.attribute,
13779
+ lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
13684
13780
  data = this.valid(text, textAttribute, fillCb, strokeCb);
13685
13781
  if (!data) return;
13686
13782
  const {
@@ -13700,79 +13796,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
13700
13796
  const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
13701
13797
  matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
13702
13798
  }
13703
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
13799
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
13704
13800
  };
13705
- if (text.isMultiLine) {
13706
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13707
- const {
13708
- multilineLayout: multilineLayout
13709
- } = text;
13710
- if (!multilineLayout) return void context.highPerformanceRestore();
13711
- const {
13712
- xOffset: xOffset,
13713
- yOffset: yOffset
13714
- } = multilineLayout.bbox;
13715
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13716
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13717
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13718
- context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
13719
- width: line.width
13720
- });
13721
- })));
13722
- } else {
13723
- text.tryUpdateAABBBounds();
13724
- const cache = text.cache,
13725
- {
13726
- verticalList: verticalList
13727
- } = cache;
13728
- context.textAlign = "left", context.textBaseline = "top";
13729
- const totalHeight = lineHeight * verticalList.length;
13730
- let totalW = 0;
13731
- verticalList.forEach(verticalData => {
13732
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13733
- totalW = max(_w, totalW);
13734
- });
13735
- let offsetY = 0,
13736
- offsetX = 0;
13737
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13738
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13739
- dw = totalW - currentW;
13740
- let currentOffsetY = offsetY;
13741
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13742
- const {
13743
- text: text,
13744
- width: width,
13745
- direction: direction
13746
- } = item;
13747
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13748
- });
13801
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13802
+ const {
13803
+ multilineLayout: multilineLayout
13804
+ } = text;
13805
+ if (!multilineLayout) return void context.highPerformanceRestore();
13806
+ const {
13807
+ xOffset: xOffset,
13808
+ yOffset: yOffset
13809
+ } = multilineLayout.bbox;
13810
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13811
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13812
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13813
+ context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
13814
+ width: line.width
13749
13815
  });
13750
- }
13751
- } else if ("horizontal" === direction) {
13752
- context.setTextStyle(text.attribute, textAttribute, z);
13753
- const t = text.clipedText;
13754
- let dy = 0;
13755
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
13816
+ })));
13756
13817
  } else {
13818
+ let {
13819
+ textAlign = textAttribute.textAlign,
13820
+ textBaseline = textAttribute.textBaseline
13821
+ } = text.attribute;
13822
+ if (!verticalMode) {
13823
+ const t = textAlign;
13824
+ textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
13825
+ }
13757
13826
  text.tryUpdateAABBBounds();
13758
- const cache = text.cache;
13759
- if (cache) {
13760
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
13761
- const {
13827
+ const cache = text.cache,
13828
+ {
13762
13829
  verticalList: verticalList
13763
13830
  } = cache;
13764
- let offsetY = 0;
13765
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
13766
- let offsetX = 0;
13767
- "bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach(item => {
13831
+ context.textAlign = "left", context.textBaseline = "top";
13832
+ const totalHeight = lineHeight * verticalList.length;
13833
+ let totalW = 0;
13834
+ verticalList.forEach(verticalData => {
13835
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13836
+ totalW = max(_w, totalW);
13837
+ });
13838
+ let offsetY = 0,
13839
+ offsetX = 0;
13840
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13841
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13842
+ dw = totalW - currentW;
13843
+ let currentOffsetY = offsetY;
13844
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13768
13845
  const {
13769
13846
  text: text,
13770
13847
  width: width,
13771
13848
  direction: direction
13772
13849
  } = item;
13773
- drawText(text, offsetX, offsetY, direction), offsetY += width;
13850
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13774
13851
  });
13775
- }
13852
+ });
13776
13853
  }
13777
13854
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
13778
13855
  }
@@ -13784,12 +13861,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
13784
13861
  computed3dMatrix = !keepDirIn3d;
13785
13862
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
13786
13863
  }
13787
- drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
13864
+ drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
13788
13865
  if (lineThrough + underline <= 0) return;
13789
13866
  const {
13790
13867
  textAlign = textAttribute.textAlign,
13791
- textBaseline = textAttribute.textBaseline,
13792
- fontSize = textAttribute.fontSize,
13793
13868
  fill = textAttribute.fill,
13794
13869
  opacity = textAttribute.opacity,
13795
13870
  underlineOffset = textAttribute.underlineOffset,
@@ -13799,23 +13874,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
13799
13874
  isMulti = !isNil$1(multiOption),
13800
13875
  w = isMulti ? multiOption.width : text.clipedWidth,
13801
13876
  offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
13802
- offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
13803
13877
  attribute = {
13804
13878
  lineWidth: 0,
13805
13879
  stroke: fill,
13806
13880
  opacity: opacity,
13807
13881
  strokeOpacity: fillOpacity
13808
13882
  };
13809
- let deltaY = isMulti ? -3 : 0;
13810
13883
  if (underline) {
13811
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
13812
- const dy = y + offsetY + fontSize + underlineOffset + deltaY;
13813
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
13884
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
13885
+ const dy = anchorY + offsetUnderLineY + underlineOffset;
13886
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
13814
13887
  }
13815
- if (isMulti && (deltaY = -1), lineThrough) {
13816
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
13817
- const dy = y + offsetY + fontSize / 2 + deltaY;
13818
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
13888
+ if (lineThrough) {
13889
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
13890
+ const dy = anchorY + offsetThroughLineY;
13891
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
13819
13892
  }
13820
13893
  }
13821
13894
  };
@@ -14110,12 +14183,10 @@ let DefaultCanvasImageRender = class extends BaseRender {
14110
14183
  const {
14111
14184
  image: url
14112
14185
  } = image.attribute;
14113
- if (!image.isGifImage) {
14114
- if (!url || !image.resources) return;
14115
- const res = image.resources.get(url);
14116
- if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
14117
- if ("success" !== res.state) return;
14118
- }
14186
+ if (!url || !image.resources) return;
14187
+ const res = image.resources.get(url);
14188
+ if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
14189
+ if ("success" !== res.state) return;
14119
14190
  const {
14120
14191
  context: context
14121
14192
  } = renderService.drawParams;
@@ -14507,28 +14578,6 @@ class CanvasTextLayout {
14507
14578
  }
14508
14579
  return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
14509
14580
  }
14510
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
14511
- const linesLayout = [],
14512
- bboxWH = [width, height],
14513
- bboxOffset = [0, 0];
14514
- for (; str.length > 0;) {
14515
- const {
14516
- str: clipText
14517
- } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
14518
- linesLayout.push({
14519
- str: clipText,
14520
- width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
14521
- }), str = str.substring(clipText.length);
14522
- }
14523
- "left" === textAlign || "start" === textAlign || ("center" === textAlign ? bboxOffset[0] = bboxWH[0] / -2 : "right" !== textAlign && "end" !== textAlign || (bboxOffset[0] = -bboxWH[0])), "top" === textBaseline || ("middle" === textBaseline ? bboxOffset[1] = bboxWH[1] / -2 : "bottom" === textBaseline && (bboxOffset[1] = -bboxWH[1]));
14524
- const bbox = {
14525
- xOffset: bboxOffset[0],
14526
- yOffset: bboxOffset[1],
14527
- width: bboxWH[0],
14528
- height: bboxWH[1]
14529
- };
14530
- return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14531
- }
14532
14581
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
14533
14582
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
14534
14583
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
@@ -14539,18 +14588,29 @@ class CanvasTextLayout {
14539
14588
  bboxWH = [0, 0];
14540
14589
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
14541
14590
  let width;
14542
- for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
14543
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14544
- width: width
14545
- });
14591
+ for (let i = 0, len = lines.length; i < len; i++) {
14592
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
14593
+ width = Math.min(metrics.width, lineWidth), linesLayout.push({
14594
+ str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14595
+ width: width,
14596
+ ascent: metrics.ascent,
14597
+ descent: metrics.descent
14598
+ });
14599
+ }
14546
14600
  bboxWH[0] = lineWidth;
14547
14601
  } else {
14548
14602
  let width, text;
14549
14603
  lineWidth = 0;
14550
- for (let i = 0, len = lines.length; i < len; i++) text = lines[i], width = this.textMeasure.measureTextWidth(text, this.textOptions), lineWidth = Math.max(lineWidth, width), linesLayout.push({
14551
- str: text,
14552
- width: width
14553
- });
14604
+ for (let i = 0, len = lines.length; i < len; i++) {
14605
+ text = lines[i];
14606
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
14607
+ width = metrics.width, lineWidth = Math.max(lineWidth, width), linesLayout.push({
14608
+ str: text,
14609
+ width: width,
14610
+ ascent: metrics.ascent,
14611
+ descent: metrics.descent
14612
+ });
14613
+ }
14554
14614
  bboxWH[0] = lineWidth;
14555
14615
  }
14556
14616
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
@@ -14579,11 +14639,11 @@ class CanvasTextLayout {
14579
14639
  };
14580
14640
  }
14581
14641
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
14582
- return "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), line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + .79 * this.textOptions.fontSize + origin[1], origin[1] += lineHeight, line;
14642
+ return "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), line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1], origin[1] += lineHeight, line;
14583
14643
  }
14584
14644
  }
14585
14645
 
14586
- const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
14646
+ const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
14587
14647
  class Text extends Graphic {
14588
14648
  get font() {
14589
14649
  const textTheme = this.getGraphicTheme();
@@ -14592,26 +14652,22 @@ class Text extends Graphic {
14592
14652
  get clipedText() {
14593
14653
  var _a;
14594
14654
  const attribute = this.attribute,
14595
- textTheme = this.getGraphicTheme();
14596
- if (!this.isSimplify()) return;
14597
- const {
14598
- maxLineWidth = textTheme.maxLineWidth
14599
- } = attribute;
14600
- return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14655
+ textTheme = this.getGraphicTheme(),
14656
+ maxWidth = this.getMaxWidth(textTheme);
14657
+ return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14601
14658
  }
14602
14659
  get clipedWidth() {
14603
- if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14660
+ return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14604
14661
  }
14605
14662
  get cliped() {
14606
14663
  var _a, _b;
14607
14664
  const textTheme = this.getGraphicTheme(),
14608
14665
  attribute = this.attribute,
14609
- {
14610
- maxLineWidth = textTheme.maxLineWidth,
14611
- text: text,
14612
- whiteSpace = textTheme.whiteSpace
14613
- } = attribute;
14614
- if (!Number.isFinite(maxLineWidth)) return !1;
14666
+ maxWidth = this.getMaxWidth(textTheme);
14667
+ if (!Number.isFinite(maxWidth)) return !1;
14668
+ const {
14669
+ text: text
14670
+ } = this.attribute;
14615
14671
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
14616
14672
  let mergedText = "";
14617
14673
  this.cache.layoutData.lines.forEach(item => {
@@ -14622,10 +14678,7 @@ class Text extends Graphic {
14622
14678
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
14623
14679
  }
14624
14680
  get multilineLayout() {
14625
- if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
14626
- }
14627
- isSimplify() {
14628
- return !this.isMultiLine && "vertical" !== this.attribute.direction;
14681
+ return this.tryUpdateAABBBounds(), this.cache.layoutData;
14629
14682
  }
14630
14683
  get isMultiLine() {
14631
14684
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -14698,8 +14751,62 @@ class Text extends Graphic {
14698
14751
  }
14699
14752
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
14700
14753
  }
14754
+ updateSingallineAABBBounds(text) {
14755
+ this.updateMultilineAABBBounds([text]);
14756
+ const layoutData = this.cache.layoutData;
14757
+ if (layoutData) {
14758
+ const line = layoutData.lines[0];
14759
+ this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
14760
+ }
14761
+ return this._AABBBounds;
14762
+ }
14763
+ updateMultilineAABBBounds(text) {
14764
+ const textTheme = this.getGraphicTheme(),
14765
+ {
14766
+ direction = textTheme.direction,
14767
+ underlineOffset = textTheme.underlineOffset
14768
+ } = this.attribute,
14769
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14770
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14771
+ }
14772
+ updateHorizontalMultilineAABBBounds(text) {
14773
+ var _a;
14774
+ const textTheme = this.getGraphicTheme(),
14775
+ attribute = this.attribute,
14776
+ {
14777
+ fontFamily = textTheme.fontFamily,
14778
+ textAlign = textTheme.textAlign,
14779
+ textBaseline = textTheme.textBaseline,
14780
+ fontSize = textTheme.fontSize,
14781
+ fontWeight = textTheme.fontWeight,
14782
+ ellipsis = textTheme.ellipsis,
14783
+ maxLineWidth: maxLineWidth,
14784
+ stroke = textTheme.stroke,
14785
+ wrap = textTheme.wrap,
14786
+ ignoreBuf = textTheme.ignoreBuf,
14787
+ lineWidth = textTheme.lineWidth,
14788
+ whiteSpace = textTheme.whiteSpace,
14789
+ suffixPosition = textTheme.suffixPosition
14790
+ } = attribute,
14791
+ lineHeight = this.getLineHeight(attribute, textTheme);
14792
+ if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
14793
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14794
+ const bbox = this.cache.layoutData.bbox;
14795
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14796
+ }
14797
+ const textMeasure = application.graphicUtil.textMeasure,
14798
+ layoutData = new CanvasTextLayout(fontFamily, {
14799
+ fontSize: fontSize,
14800
+ fontWeight: fontWeight,
14801
+ fontFamily: fontFamily
14802
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14803
+ {
14804
+ bbox: bbox
14805
+ } = layoutData;
14806
+ return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14807
+ }
14701
14808
  updateWrapAABBBounds(text) {
14702
- var _a, _b, _c, _d;
14809
+ var _a, _b, _c;
14703
14810
  const textTheme = this.getGraphicTheme(),
14704
14811
  {
14705
14812
  fontFamily = textTheme.fontFamily,
@@ -14717,18 +14824,18 @@ class Text extends Graphic {
14717
14824
  heightLimit = 0,
14718
14825
  lineClamp: lineClamp
14719
14826
  } = this.attribute,
14720
- lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
14721
- buf = ignoreBuf ? 0 : 2;
14722
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14827
+ lineHeight = this.getLineHeight(this.attribute, textTheme);
14828
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14723
14829
  const bbox = this.cache.layoutData.bbox;
14724
14830
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14725
14831
  }
14726
14832
  const textMeasure = application.graphicUtil.textMeasure,
14727
- layoutObj = new CanvasTextLayout(fontFamily, {
14833
+ textOptions = {
14728
14834
  fontSize: fontSize,
14729
14835
  fontWeight: fontWeight,
14730
14836
  fontFamily: fontFamily
14731
- }, textMeasure),
14837
+ },
14838
+ layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
14732
14839
  lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
14733
14840
  linesLayout = [],
14734
14841
  bboxWH = [0, 0];
@@ -14738,29 +14845,35 @@ class Text extends Graphic {
14738
14845
  const str = lines[i];
14739
14846
  let needCut = !0;
14740
14847
  if (i === lineCountLimit - 1) {
14741
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
14848
+ const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
14849
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14742
14850
  linesLayout.push({
14743
14851
  str: clip.str,
14744
- width: clip.width
14852
+ width: clip.width,
14853
+ ascent: matrics.ascent,
14854
+ descent: matrics.descent
14745
14855
  });
14746
14856
  break;
14747
14857
  }
14748
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14858
+ const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14749
14859
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
14750
14860
  if (ellipsis) {
14751
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14752
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
14861
+ const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14862
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
14753
14863
  } else clip.str = "", clip.width = 0;
14754
14864
  needCut = !1;
14755
14865
  }
14866
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14756
14867
  linesLayout.push({
14757
14868
  str: clip.str,
14758
- width: clip.width
14869
+ width: clip.width,
14870
+ ascent: matrics.ascent,
14871
+ descent: matrics.descent
14759
14872
  });
14760
14873
  let cutLength = clip.str.length;
14761
14874
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
14762
- let newStr = str.substring(cutLength);
14763
- "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
14875
+ const newStr = str.substring(cutLength);
14876
+ lines.splice(i + 1, 0, newStr);
14764
14877
  }
14765
14878
  }
14766
14879
  let maxWidth = 0;
@@ -14773,21 +14886,28 @@ class Text extends Graphic {
14773
14886
  lineWidth = 0;
14774
14887
  for (let i = 0, len = lines.length; i < len; i++) {
14775
14888
  if (i === lineCountLimit - 1) {
14776
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14889
+ const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
14890
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14777
14891
  linesLayout.push({
14778
14892
  str: clip.str,
14779
- width: clip.width
14893
+ width: clip.width,
14894
+ ascent: matrics.ascent,
14895
+ descent: matrics.descent
14780
14896
  }), lineWidth = Math.max(lineWidth, clip.width);
14781
14897
  break;
14782
14898
  }
14783
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
14899
+ text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
14900
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
14901
+ linesLayout.push({
14784
14902
  str: text,
14785
- width: width
14903
+ width: width,
14904
+ ascent: matrics.ascent,
14905
+ descent: matrics.descent
14786
14906
  });
14787
14907
  }
14788
14908
  bboxWH[0] = lineWidth;
14789
14909
  }
14790
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
14910
+ bboxWH[1] = linesLayout.length * lineHeight;
14791
14911
  const bbox = {
14792
14912
  xOffset: 0,
14793
14913
  yOffset: 0,
@@ -14798,210 +14918,12 @@ class Text extends Graphic {
14798
14918
  const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14799
14919
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14800
14920
  }
14801
- updateSingallineAABBBounds(text) {
14802
- const textTheme = this.getGraphicTheme(),
14803
- {
14804
- direction = textTheme.direction,
14805
- underlineOffset = textTheme.underlineOffset
14806
- } = this.attribute,
14807
- b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
14808
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14809
- }
14810
- updateMultilineAABBBounds(text) {
14811
- const textTheme = this.getGraphicTheme(),
14812
- {
14813
- direction = textTheme.direction,
14814
- underlineOffset = textTheme.underlineOffset
14815
- } = this.attribute,
14816
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14817
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14818
- }
14819
- updateHorizontalSinglelineAABBBounds(text) {
14820
- var _a, _b;
14821
- const textTheme = this.getGraphicTheme(),
14822
- {
14823
- wrap = textTheme.wrap
14824
- } = this.attribute;
14825
- if (wrap) return this.updateWrapAABBBounds([text]);
14826
- const textMeasure = application.graphicUtil.textMeasure;
14827
- let width, str;
14828
- const attribute = this.attribute,
14829
- {
14830
- maxLineWidth = textTheme.maxLineWidth,
14831
- ellipsis = textTheme.ellipsis,
14832
- textAlign = textTheme.textAlign,
14833
- textBaseline = textTheme.textBaseline,
14834
- fontFamily = textTheme.fontFamily,
14835
- fontSize = textTheme.fontSize,
14836
- fontWeight = textTheme.fontWeight,
14837
- stroke = textTheme.stroke,
14838
- lineWidth = textTheme.lineWidth,
14839
- ignoreBuf = textTheme.ignoreBuf,
14840
- whiteSpace = textTheme.whiteSpace,
14841
- suffixPosition = textTheme.suffixPosition
14842
- } = attribute;
14843
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14844
- const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
14845
- textFontSize = attribute.fontSize || textTheme.fontSize,
14846
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
14847
- if (!this.shouldUpdateShape() && this.cache) {
14848
- width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
14849
- const dx = textDrawOffsetX(textAlign, width),
14850
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14851
- return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14852
- }
14853
- if (Number.isFinite(maxLineWidth)) {
14854
- if (ellipsis) {
14855
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14856
- data = textMeasure.clipTextWithSuffix(text.toString(), {
14857
- fontSize: fontSize,
14858
- fontWeight: fontWeight,
14859
- fontFamily: fontFamily
14860
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14861
- str = data.str, width = data.width;
14862
- } else {
14863
- const data = textMeasure.clipText(text.toString(), {
14864
- fontSize: fontSize,
14865
- fontWeight: fontWeight,
14866
- fontFamily: fontFamily
14867
- }, maxLineWidth, !1);
14868
- str = data.str, width = data.width;
14869
- }
14870
- this.cache.clipedText = str, this.cache.clipedWidth = width;
14871
- } else width = textMeasure.measureTextWidth(text.toString(), {
14872
- fontSize: fontSize,
14873
- fontWeight: fontWeight,
14874
- fontFamily: fontFamily
14875
- }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
14876
- this.clearUpdateShapeTag();
14877
- const dx = textDrawOffsetX(textAlign, width);
14878
- let lh = lineHeight;
14879
- application.global && application.global.isSafari() && (lh += .2 * fontSize);
14880
- const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
14881
- return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14882
- }
14883
- getBaselineMapAlign() {
14884
- return Text.baselineMapAlign;
14885
- }
14886
- getAlignMapBaseline() {
14887
- return Text.alignMapBaseline;
14888
- }
14889
- updateVerticalSinglelineAABBBounds(text) {
14890
- var _a, _b, _c;
14891
- const textTheme = this.getGraphicTheme(),
14892
- textMeasure = application.graphicUtil.textMeasure;
14893
- let width;
14894
- const attribute = this.attribute,
14895
- {
14896
- ignoreBuf = textTheme.ignoreBuf
14897
- } = attribute,
14898
- buf = ignoreBuf ? 0 : 2,
14899
- {
14900
- maxLineWidth = textTheme.maxLineWidth,
14901
- ellipsis = textTheme.ellipsis,
14902
- fontSize = textTheme.fontSize,
14903
- fontWeight = textTheme.fontWeight,
14904
- fontFamily = textTheme.fontFamily,
14905
- stroke = textTheme.stroke,
14906
- lineWidth = textTheme.lineWidth,
14907
- verticalMode = textTheme.verticalMode,
14908
- suffixPosition = textTheme.suffixPosition
14909
- } = attribute,
14910
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14911
- let {
14912
- textAlign = textTheme.textAlign,
14913
- textBaseline = textTheme.textBaseline
14914
- } = attribute;
14915
- if (!verticalMode) {
14916
- const t = textAlign;
14917
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14918
- }
14919
- if (!this.shouldUpdateShape() && this.cache) {
14920
- width = this.cache.clipedWidth;
14921
- const dx = textDrawOffsetX(textAlign, width),
14922
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14923
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14924
- }
14925
- let verticalList = [verticalLayout(text.toString())];
14926
- if (Number.isFinite(maxLineWidth)) {
14927
- if (ellipsis) {
14928
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14929
- data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
14930
- fontSize: fontSize,
14931
- fontWeight: fontWeight,
14932
- fontFamily: fontFamily
14933
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14934
- verticalList = [data.verticalList], width = data.width;
14935
- } else {
14936
- const data = textMeasure.clipTextVertical(verticalList[0], {
14937
- fontSize: fontSize,
14938
- fontWeight: fontWeight,
14939
- fontFamily: fontFamily
14940
- }, maxLineWidth, !1);
14941
- verticalList = [data.verticalList], width = data.width;
14942
- }
14943
- this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14944
- } else width = 0, verticalList[0].forEach(t => {
14945
- const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
14946
- fontSize: fontSize,
14947
- fontWeight: fontWeight,
14948
- fontFamily: fontFamily
14949
- });
14950
- width += w, t.width = w;
14951
- }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14952
- this.clearUpdateShapeTag();
14953
- const dx = textDrawOffsetX(textAlign, width),
14954
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14955
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14956
- }
14957
- updateHorizontalMultilineAABBBounds(text) {
14958
- var _a, _b;
14959
- const textTheme = this.getGraphicTheme(),
14960
- {
14961
- wrap = textTheme.wrap
14962
- } = this.attribute;
14963
- if (wrap) return this.updateWrapAABBBounds(text);
14964
- const attribute = this.attribute,
14965
- {
14966
- fontFamily = textTheme.fontFamily,
14967
- textAlign = textTheme.textAlign,
14968
- textBaseline = textTheme.textBaseline,
14969
- fontSize = textTheme.fontSize,
14970
- fontWeight = textTheme.fontWeight,
14971
- ellipsis = textTheme.ellipsis,
14972
- maxLineWidth: maxLineWidth,
14973
- stroke = textTheme.stroke,
14974
- lineWidth = textTheme.lineWidth,
14975
- whiteSpace = textTheme.whiteSpace,
14976
- suffixPosition = textTheme.suffixPosition
14977
- } = attribute,
14978
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
14979
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14980
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14981
- const bbox = this.cache.layoutData.bbox;
14982
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14983
- }
14984
- const textMeasure = application.graphicUtil.textMeasure,
14985
- layoutData = new CanvasTextLayout(fontFamily, {
14986
- fontSize: fontSize,
14987
- fontWeight: fontWeight,
14988
- fontFamily: fontFamily
14989
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14990
- {
14991
- bbox: bbox
14992
- } = layoutData;
14993
- return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14994
- }
14995
14921
  updateVerticalMultilineAABBBounds(text) {
14996
- var _a, _b, _c;
14922
+ var _a, _b;
14997
14923
  const textTheme = this.getGraphicTheme(),
14998
14924
  textMeasure = application.graphicUtil.textMeasure;
14999
14925
  let width;
15000
14926
  const attribute = this.attribute,
15001
- {
15002
- ignoreBuf = textTheme.ignoreBuf
15003
- } = attribute,
15004
- buf = ignoreBuf ? 0 : 2,
15005
14927
  {
15006
14928
  maxLineWidth = textTheme.maxLineWidth,
15007
14929
  ellipsis = textTheme.ellipsis,
@@ -15013,14 +14935,14 @@ class Text extends Graphic {
15013
14935
  verticalMode = textTheme.verticalMode,
15014
14936
  suffixPosition = textTheme.suffixPosition
15015
14937
  } = attribute,
15016
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14938
+ lineHeight = this.getLineHeight(attribute, textTheme);
15017
14939
  let {
15018
14940
  textAlign = textTheme.textAlign,
15019
14941
  textBaseline = textTheme.textBaseline
15020
14942
  } = attribute;
15021
14943
  if (!verticalMode) {
15022
14944
  const t = textAlign;
15023
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14945
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
15024
14946
  }
15025
14947
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
15026
14948
  this.cache.verticalList.forEach(item => {
@@ -15068,6 +14990,15 @@ class Text extends Graphic {
15068
14990
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
15069
14991
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15070
14992
  }
14993
+ getMaxWidth(theme) {
14994
+ var _a, _b;
14995
+ const attribute = this.attribute;
14996
+ return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
14997
+ }
14998
+ getLineHeight(attribute, textTheme) {
14999
+ var _a;
15000
+ return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
15001
+ }
15071
15002
  needUpdateTags(keys) {
15072
15003
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
15073
15004
  return super.needUpdateTags(keys, k);
@@ -15082,6 +15013,12 @@ class Text extends Graphic {
15082
15013
  getNoWorkAnimateAttr() {
15083
15014
  return Text.NOWORK_ANIMATE_ATTR;
15084
15015
  }
15016
+ getBaselineMapAlign() {
15017
+ return Text.baselineMapAlign;
15018
+ }
15019
+ getAlignMapBaseline() {
15020
+ return Text.alignMapBaseline;
15021
+ }
15085
15022
  }
15086
15023
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
15087
15024
  ellipsis: 1,
@@ -15160,7 +15097,9 @@ class WrapText extends Text {
15160
15097
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15161
15098
  linesLayout.push({
15162
15099
  str: clip.str,
15163
- width: clip.width
15100
+ width: clip.width,
15101
+ ascent: 0,
15102
+ descent: 0
15164
15103
  });
15165
15104
  break;
15166
15105
  }
@@ -15174,7 +15113,9 @@ class WrapText extends Text {
15174
15113
  }
15175
15114
  if (linesLayout.push({
15176
15115
  str: clip.str,
15177
- width: clip.width
15116
+ width: clip.width,
15117
+ ascent: 0,
15118
+ descent: 0
15178
15119
  }), clip.str.length === str.length) ;else if (needCut) {
15179
15120
  const newStr = str.substring(clip.str.length);
15180
15121
  lines.splice(i + 1, 0, newStr);
@@ -15193,13 +15134,17 @@ class WrapText extends Text {
15193
15134
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15194
15135
  linesLayout.push({
15195
15136
  str: clip.str,
15196
- width: clip.width
15137
+ width: clip.width,
15138
+ ascent: 0,
15139
+ descent: 0
15197
15140
  }), lineWidth = Math.max(lineWidth, clip.width);
15198
15141
  break;
15199
15142
  }
15200
15143
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
15201
15144
  str: text,
15202
- width: width
15145
+ width: width,
15146
+ ascent: 0,
15147
+ descent: 0
15203
15148
  });
15204
15149
  }
15205
15150
  bboxWH[0] = lineWidth;
@@ -15243,6 +15188,9 @@ class BaseSymbol {
15243
15188
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
15244
15189
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
15245
15190
  }
15191
+ parseSize(size) {
15192
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15193
+ }
15246
15194
  }
15247
15195
 
15248
15196
  function circle(ctx, r, x, y, z) {
@@ -15253,13 +15201,13 @@ class CircleSymbol extends BaseSymbol {
15253
15201
  super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
15254
15202
  }
15255
15203
  draw(ctx, size, x, y, z) {
15256
- return circle(ctx, size / 2, x, y, z);
15204
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
15257
15205
  }
15258
15206
  drawOffset(ctx, size, x, y, offset, z) {
15259
- return circle(ctx, size / 2 + offset, x, y, z);
15207
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15260
15208
  }
15261
15209
  drawToSvgPath(size, x, y, z) {
15262
- const r = size / 2;
15210
+ const r = this.parseSize(size) / 2;
15263
15211
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
15264
15212
  }
15265
15213
  }
@@ -15276,10 +15224,10 @@ class CrossSymbol extends BaseSymbol {
15276
15224
  super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
15277
15225
  }
15278
15226
  draw(ctx, size, x, y, z) {
15279
- return cross(ctx, size / 6, x, y, z);
15227
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
15280
15228
  }
15281
15229
  drawOffset(ctx, size, x, y, offset, z) {
15282
- return crossOffset(ctx, size / 6, x, y, offset, z);
15230
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
15283
15231
  }
15284
15232
  }
15285
15233
  var cross$1 = new CrossSymbol();
@@ -15292,13 +15240,13 @@ class DiamondSymbol extends BaseSymbol {
15292
15240
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
15293
15241
  }
15294
15242
  draw(ctx, size, x, y, z) {
15295
- return diamond(ctx, size / 2, x, y, z);
15243
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15296
15244
  }
15297
15245
  drawFitDir(ctx, size, x, y, z) {
15298
- return diamond(ctx, size / 2, x, y, z);
15246
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15299
15247
  }
15300
15248
  drawOffset(ctx, size, x, y, offset, z) {
15301
- return diamond(ctx, size / 2 + offset, x, y, z);
15249
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15302
15250
  }
15303
15251
  }
15304
15252
  var diamond$1 = new DiamondSymbol();
@@ -15312,10 +15260,10 @@ class SquareSymbol extends BaseSymbol {
15312
15260
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
15313
15261
  }
15314
15262
  draw(ctx, size, x, y) {
15315
- return square(ctx, size / 2, x, y);
15263
+ return square(ctx, this.parseSize(size) / 2, x, y);
15316
15264
  }
15317
15265
  drawOffset(ctx, size, x, y, offset) {
15318
- return square(ctx, size / 2 + offset, x, y);
15266
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
15319
15267
  }
15320
15268
  }
15321
15269
  var square$1 = new SquareSymbol();
@@ -15329,10 +15277,10 @@ class TriangleUpSymbol extends BaseSymbol {
15329
15277
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
15330
15278
  }
15331
15279
  draw(ctx, size, x, y) {
15332
- return trianglUpOffset(ctx, size / 2, x, y);
15280
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
15333
15281
  }
15334
15282
  drawOffset(ctx, size, x, y, offset) {
15335
- return trianglUpOffset(ctx, size / 2, x, y, offset);
15283
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15336
15284
  }
15337
15285
  }
15338
15286
  var triangleUp = new TriangleUpSymbol();
@@ -15364,10 +15312,10 @@ class StarSymbol extends BaseSymbol {
15364
15312
  super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
15365
15313
  }
15366
15314
  draw(ctx, size, transX, transY) {
15367
- return star(ctx, size / 2, transX, transY);
15315
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
15368
15316
  }
15369
15317
  drawOffset(ctx, size, transX, transY, offset) {
15370
- return star(ctx, size / 2 + offset, transX, transY);
15318
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15371
15319
  }
15372
15320
  }
15373
15321
  var star$1 = new StarSymbol();
@@ -15385,10 +15333,10 @@ class ArrowSymbol extends BaseSymbol {
15385
15333
  super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
15386
15334
  }
15387
15335
  draw(ctx, size, transX, transY) {
15388
- return arrow(ctx, size / 2, transX, transY);
15336
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
15389
15337
  }
15390
15338
  drawOffset(ctx, size, transX, transY, offset) {
15391
- return arrow(ctx, size / 2 + offset, transX, transY);
15339
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15392
15340
  }
15393
15341
  }
15394
15342
  var arrow$1 = new ArrowSymbol();
@@ -15402,10 +15350,10 @@ class WedgeSymbol extends BaseSymbol {
15402
15350
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
15403
15351
  }
15404
15352
  draw(ctx, size, transX, transY) {
15405
- return wedge(ctx, size / 2, transX, transY);
15353
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
15406
15354
  }
15407
15355
  drawOffset(ctx, size, transX, transY, offset) {
15408
- return wedge(ctx, size / 2 + offset, transX, transY);
15356
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15409
15357
  }
15410
15358
  }
15411
15359
  var wedge$1 = new WedgeSymbol();
@@ -15418,10 +15366,10 @@ class StrokeSymbol extends BaseSymbol {
15418
15366
  super(...arguments), this.type = "stroke", this.pathStr = "";
15419
15367
  }
15420
15368
  draw(ctx, size, transX, transY) {
15421
- return stroke(ctx, size / 2, transX, transY);
15369
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
15422
15370
  }
15423
15371
  drawOffset(ctx, size, transX, transY, offset) {
15424
- return stroke(ctx, size / 2 + offset, transX, transY);
15372
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15425
15373
  }
15426
15374
  }
15427
15375
  var stroke$1 = new StrokeSymbol();
@@ -15443,10 +15391,10 @@ class WyeSymbol extends BaseSymbol {
15443
15391
  super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
15444
15392
  }
15445
15393
  draw(ctx, size, transX, transY) {
15446
- return wye(ctx, size / 2, transX, transY);
15394
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
15447
15395
  }
15448
15396
  drawOffset(ctx, size, transX, transY, offset) {
15449
- return wye(ctx, size / 2 + offset, transX, transY);
15397
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15450
15398
  }
15451
15399
  }
15452
15400
  var wye$1 = new WyeSymbol();
@@ -15459,10 +15407,10 @@ class TriangleLeftSymbol extends BaseSymbol {
15459
15407
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
15460
15408
  }
15461
15409
  draw(ctx, size, x, y) {
15462
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
15410
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
15463
15411
  }
15464
15412
  drawOffset(ctx, size, x, y, offset) {
15465
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
15413
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15466
15414
  }
15467
15415
  }
15468
15416
  var triangleLeft = new TriangleLeftSymbol();
@@ -15476,10 +15424,10 @@ class TriangleRightSymbol extends BaseSymbol {
15476
15424
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
15477
15425
  }
15478
15426
  draw(ctx, size, x, y) {
15479
- return trianglRightOffset(ctx, size / 2, x, y);
15427
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
15480
15428
  }
15481
15429
  drawOffset(ctx, size, x, y, offset) {
15482
- return trianglRightOffset(ctx, size / 2, x, y, offset);
15430
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15483
15431
  }
15484
15432
  }
15485
15433
  var triangleRight = new TriangleRightSymbol();
@@ -15493,10 +15441,10 @@ class TriangleDownSymbol extends BaseSymbol {
15493
15441
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
15494
15442
  }
15495
15443
  draw(ctx, size, x, y) {
15496
- return trianglDownOffset(ctx, size / 2, x, y);
15444
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
15497
15445
  }
15498
15446
  drawOffset(ctx, size, x, y, offset) {
15499
- return trianglDownOffset(ctx, size / 2, x, y, offset);
15447
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15500
15448
  }
15501
15449
  }
15502
15450
  var triangleDown = new TriangleDownSymbol();
@@ -15511,10 +15459,10 @@ class ThinTriangleSymbol extends BaseSymbol {
15511
15459
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
15512
15460
  }
15513
15461
  draw(ctx, size, x, y) {
15514
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
15462
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
15515
15463
  }
15516
15464
  drawOffset(ctx, size, x, y, offset) {
15517
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
15465
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
15518
15466
  }
15519
15467
  }
15520
15468
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -15528,10 +15476,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
15528
15476
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
15529
15477
  }
15530
15478
  draw(ctx, size, transX, transY) {
15531
- return arrow2Left(ctx, size / 4, transX, transY);
15479
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
15532
15480
  }
15533
15481
  drawOffset(ctx, size, transX, transY, offset) {
15534
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
15482
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15535
15483
  }
15536
15484
  }
15537
15485
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -15545,10 +15493,10 @@ class Arrow2RightSymbol extends BaseSymbol {
15545
15493
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
15546
15494
  }
15547
15495
  draw(ctx, size, transX, transY) {
15548
- return arrow2Right(ctx, size / 4, transX, transY);
15496
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
15549
15497
  }
15550
15498
  drawOffset(ctx, size, transX, transY, offset) {
15551
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
15499
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15552
15500
  }
15553
15501
  }
15554
15502
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -15562,10 +15510,10 @@ class Arrow2UpSymbol extends BaseSymbol {
15562
15510
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
15563
15511
  }
15564
15512
  draw(ctx, size, transX, transY) {
15565
- return arrow2Up(ctx, size / 4, transX, transY);
15513
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
15566
15514
  }
15567
15515
  drawOffset(ctx, size, transX, transY, offset) {
15568
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
15516
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15569
15517
  }
15570
15518
  }
15571
15519
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -15579,10 +15527,10 @@ class Arrow2DownSymbol extends BaseSymbol {
15579
15527
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
15580
15528
  }
15581
15529
  draw(ctx, size, transX, transY) {
15582
- return arrow2Down(ctx, size / 4, transX, transY);
15530
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
15583
15531
  }
15584
15532
  drawOffset(ctx, size, transX, transY, offset) {
15585
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
15533
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15586
15534
  }
15587
15535
  }
15588
15536
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -15595,13 +15543,13 @@ class LineVSymbol extends BaseSymbol {
15595
15543
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
15596
15544
  }
15597
15545
  draw(ctx, size, x, y, z) {
15598
- return lineV(ctx, size / 2, x, y);
15546
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
15599
15547
  }
15600
15548
  drawOffset(ctx, size, x, y, offset, z) {
15601
- return lineV(ctx, size / 2 + offset, x, y);
15549
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
15602
15550
  }
15603
15551
  drawToSvgPath(size, x, y, z) {
15604
- const r = size / 2;
15552
+ const r = this.parseSize(size) / 2;
15605
15553
  return `M ${x}, ${y - r} L ${x},${y + r}`;
15606
15554
  }
15607
15555
  }
@@ -15615,13 +15563,13 @@ class LineHSymbol extends BaseSymbol {
15615
15563
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
15616
15564
  }
15617
15565
  draw(ctx, size, x, y, z) {
15618
- return lineH(ctx, size / 2, x, y);
15566
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
15619
15567
  }
15620
15568
  drawOffset(ctx, size, x, y, offset, z) {
15621
- return lineH(ctx, size / 2 + offset, x, y);
15569
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
15622
15570
  }
15623
15571
  drawToSvgPath(size, x, y, z) {
15624
- const r = size / 2;
15572
+ const r = this.parseSize(size) / 2;
15625
15573
  return `M ${x - r}, ${y} L ${x + r},${y}`;
15626
15574
  }
15627
15575
  }
@@ -15635,13 +15583,13 @@ class CloseSymbol extends BaseSymbol {
15635
15583
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
15636
15584
  }
15637
15585
  draw(ctx, size, x, y, z) {
15638
- return close(ctx, size / 2, x, y);
15586
+ return close(ctx, this.parseSize(size) / 2, x, y);
15639
15587
  }
15640
15588
  drawOffset(ctx, size, x, y, offset, z) {
15641
- return close(ctx, size / 2 + offset, x, y);
15589
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
15642
15590
  }
15643
15591
  drawToSvgPath(size, x, y, z) {
15644
- const r = size / 2;
15592
+ const r = this.parseSize(size) / 2;
15645
15593
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
15646
15594
  }
15647
15595
  }
@@ -15675,15 +15623,18 @@ class CustomSymbolClass {
15675
15623
  this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
15676
15624
  }
15677
15625
  drawOffset(ctx, size, x, y, offset, z, cb) {
15678
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15626
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15679
15627
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
15680
15628
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
15681
15629
  }
15682
15630
  draw(ctx, size, x, y, z, cb) {
15683
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
15631
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
15632
+ }
15633
+ parseSize(size) {
15634
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15684
15635
  }
15685
15636
  bounds(size, bounds) {
15686
- if (this.isSvg) {
15637
+ if (size = this.parseSize(size), this.isSvg) {
15687
15638
  if (!this.svgCache) return;
15688
15639
  return bounds.clear(), void this.svgCache.forEach(_ref => {
15689
15640
  let {
@@ -16366,7 +16317,11 @@ class Paragraph {
16366
16317
  case "sub":
16367
16318
  baseline += this.descent / 2;
16368
16319
  }
16369
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
16320
+ "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
16321
+ const {
16322
+ lineWidth = 1
16323
+ } = this.character;
16324
+ this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
16370
16325
  }
16371
16326
  getWidthWithEllips(direction) {
16372
16327
  let text = this.text;
@@ -18583,7 +18538,7 @@ class Stage extends Group {
18583
18538
  constructor() {
18584
18539
  let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18585
18540
  var _a;
18586
- super({}), this._onVisibleChange = visible => {
18541
+ super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
18587
18542
  if (!(this._skipRender < 0)) if (visible) {
18588
18543
  if (this.dirtyBounds) {
18589
18544
  const b = this.window.getViewBox();
@@ -18594,7 +18549,10 @@ class Stage extends Group {
18594
18549
  }, this.beforeRender = stage => {
18595
18550
  this._beforeRender && this._beforeRender(stage);
18596
18551
  }, this.afterRender = stage => {
18597
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
18552
+ this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
18553
+ }, this.afterTickCb = () => {
18554
+ var _a;
18555
+ this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
18598
18556
  }, this.params = params, this.theme = new Theme(), this.hooks = {
18599
18557
  beforeRender: new SyncHook(["stage"]),
18600
18558
  afterRender: new SyncHook(["stage"])
@@ -18611,7 +18569,7 @@ class Stage extends Group {
18611
18569
  main: !0
18612
18570
  })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this.ticker = params.ticker || defaultTicker, this.supportInteractiveLayer = !1 !== params.interactiveLayer, this.timeline = new DefaultTimeline(), this.ticker.addTimeline(this.timeline), this.timeline.pause(), params.optimize || (params.optimize = {}), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
18613
18571
  background: this._background
18614
- });
18572
+ }), this.ticker.on("afterTick", this.afterTickCb);
18615
18573
  }
18616
18574
  pauseRender() {
18617
18575
  let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
@@ -18840,7 +18798,7 @@ class Stage extends Group {
18840
18798
  if ("released" === this.releaseStatus) return;
18841
18799
  this.ticker.start(), this.timeline.resume();
18842
18800
  const state = this.state;
18843
- this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
18801
+ this.state = "rendering", this.tickedBeforeRender || this.ticker.trySyncTickStatus(), this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
18844
18802
  }
18845
18803
  combineLayersToWindow() {
18846
18804
  if ("harmony" === this.global.env) {
@@ -18946,7 +18904,7 @@ class Stage extends Group {
18946
18904
  layer.release();
18947
18905
  }), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
18948
18906
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
18949
- }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
18907
+ }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
18950
18908
  }
18951
18909
  setStage(stage) {}
18952
18910
  dirty(b, matrix) {
@@ -23646,11 +23604,9 @@ function jsx(type, config) {
23646
23604
  name: name,
23647
23605
  id: id,
23648
23606
  attribute: attribute,
23649
- stateProxy: stateProxy,
23650
- animation: animation,
23651
- timeline: timeline
23607
+ stateProxy: stateProxy
23652
23608
  } = _a,
23653
- props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy", "animation", "timeline"]);
23609
+ props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy"]);
23654
23610
  let c = type;
23655
23611
  isString$1(type) && (c = graphicCreator[type]);
23656
23612
  const childrenList = [];
@@ -23659,13 +23615,7 @@ function jsx(type, config) {
23659
23615
  }
23660
23616
  children.length && flatten(1 === children.length ? children[0] : children, childrenList);
23661
23617
  const g = "Group" === c.name ? new c(attribute) : c(config);
23662
- if (parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), name && (g.name = name), isArray$1(animation)) {
23663
- const animate = g.animate();
23664
- timeline && animate.setTimeline(timeline), animation.forEach(item => {
23665
- animate[item[0]](...item.slice(1));
23666
- });
23667
- }
23668
- return g;
23618
+ return parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), g;
23669
23619
  }
23670
23620
  function parseToGraphic$1(g, childrenList, props) {
23671
23621
  let out,
@@ -23933,7 +23883,7 @@ class Gesture extends EventEmitter {
23933
23883
  startTime: startTime,
23934
23884
  startPoints: startPoints
23935
23885
  } = this;
23936
- if (eventType) return eventType;
23886
+ if ("press" === eventType) return eventType;
23937
23887
  let type;
23938
23888
  return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
23939
23889
  }
@@ -24465,9 +24415,10 @@ let BrowserContext2d = class {
24465
24415
  lineJoin = defaultParams.lineJoin,
24466
24416
  lineDash = defaultParams.lineDash,
24467
24417
  lineCap = defaultParams.lineCap,
24468
- miterLimit = defaultParams.miterLimit
24418
+ miterLimit = defaultParams.miterLimit,
24419
+ keepStrokeScale = defaultParams.keepStrokeScale
24469
24420
  } = attribute;
24470
- _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
24421
+ _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
24471
24422
  }
24472
24423
  }
24473
24424
  setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
@@ -25367,8 +25318,9 @@ class PickerBase {
25367
25318
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
25368
25319
  if (picked) return !0;
25369
25320
  const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
25370
- pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25371
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25321
+ pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25322
+ keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25323
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25372
25324
  }), pickContext.highPerformanceRestore(), picked;
25373
25325
  }
25374
25326
  }
@@ -25641,8 +25593,9 @@ class RectPickerBase {
25641
25593
  if (!onlyTranslate || rect.shadowRoot || isNumber$1(cornerRadius, !0) && 0 !== cornerRadius || isArray$1(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
25642
25594
  if (picked) return !0;
25643
25595
  const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
25644
- pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25645
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25596
+ pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25597
+ keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25598
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25646
25599
  });else {
25647
25600
  const {
25648
25601
  fill = rectAttribute.fill,
@@ -25956,9 +25909,10 @@ let LynxContext2d = class extends BrowserContext2d {
25956
25909
  lineJoin = defaultParams.lineJoin,
25957
25910
  lineDash = defaultParams.lineDash,
25958
25911
  lineCap = defaultParams.lineCap,
25959
- miterLimit = defaultParams.miterLimit
25912
+ miterLimit = defaultParams.miterLimit,
25913
+ keepStrokeScale = defaultParams.keepStrokeScale
25960
25914
  } = attribute;
25961
- _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
25915
+ _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
25962
25916
  }
25963
25917
  }
25964
25918
  measureText(text) {
@@ -26586,9 +26540,10 @@ let TaroContext2d = class extends BrowserContext2d {
26586
26540
  lineJoin = defaultParams.lineJoin,
26587
26541
  lineDash = defaultParams.lineDash,
26588
26542
  lineCap = defaultParams.lineCap,
26589
- miterLimit = defaultParams.miterLimit
26543
+ miterLimit = defaultParams.miterLimit,
26544
+ keepStrokeScale = defaultParams.keepStrokeScale
26590
26545
  } = attribute;
26591
- _context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
26546
+ _context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
26592
26547
  }
26593
26548
  }
26594
26549
  setTextStyleWithoutAlignBaseline(params, defaultParams) {
@@ -27628,9 +27583,10 @@ let HarmonyContext2d = class extends BrowserContext2d {
27628
27583
  lineJoin = defaultParams.lineJoin,
27629
27584
  lineDash = defaultParams.lineDash,
27630
27585
  lineCap = defaultParams.lineCap,
27631
- miterLimit = defaultParams.miterLimit
27586
+ miterLimit = defaultParams.miterLimit,
27587
+ keepStrokeScale = defaultParams.keepStrokeScale
27632
27588
  } = attribute;
27633
- _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
27589
+ _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
27634
27590
  }
27635
27591
  }
27636
27592
  measureText(text) {
@@ -28037,8 +27993,9 @@ class BaseLinePicker extends BaseRender {
28037
27993
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
28038
27994
  if (picked) return !0;
28039
27995
  const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
28040
- pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28041
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
27996
+ pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
27997
+ keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
27998
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28042
27999
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28043
28000
  }
28044
28001
  }
@@ -28173,8 +28130,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
28173
28130
  return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
28174
28131
  if (picked) return !0;
28175
28132
  const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
28176
- pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28177
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28133
+ pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28134
+ keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28135
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28178
28136
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28179
28137
  }
28180
28138
  };
@@ -28611,7 +28569,7 @@ const registerWrapText = _registerWrapText;
28611
28569
 
28612
28570
  const roughModule = _roughModule;
28613
28571
 
28614
- const version = "0.21.0-alpha.4";
28572
+ const version = "0.21.0-alpha.5";
28615
28573
  preLoadAllModule();
28616
28574
  if (isBrowserEnv()) {
28617
28575
  loadBrowserEnv(container);