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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -748,6 +748,13 @@
748
748
  };
749
749
  exports.DefaultGlobal = __decorate$1H([injectable(), __param$T(0, inject(ContributionProvider)), __param$T(0, named(EnvContribution)), __metadata$1h("design:paramtypes", [Object])], exports.DefaultGlobal);
750
750
 
751
+ exports.MeasureModeEnum = void 0;
752
+ !function (MeasureModeEnum) {
753
+ MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
754
+ }(exports.MeasureModeEnum || (exports.MeasureModeEnum = {}));
755
+
756
+ const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
757
+
751
758
  function getDefaultExportFromCjs (x) {
752
759
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
753
760
  }
@@ -3919,6 +3926,7 @@
3919
3926
  const DefaultTextStyle = {
3920
3927
  text: "",
3921
3928
  maxLineWidth: 1 / 0,
3929
+ maxWidth: 1 / 0,
3922
3930
  textAlign: "left",
3923
3931
  textBaseline: "alphabetic",
3924
3932
  fontSize: 16,
@@ -3942,7 +3950,8 @@
3942
3950
  suffixPosition: "end",
3943
3951
  underlineDash: [],
3944
3952
  underlineOffset: 0,
3945
- disableAutoClipedPoptip: void 0
3953
+ disableAutoClipedPoptip: void 0,
3954
+ measureMode: exports.MeasureModeEnum.fontBounding
3946
3955
  };
3947
3956
  const DefaultPickStyle = {
3948
3957
  pickStrokeBuffer: 0
@@ -3996,7 +4005,8 @@
3996
4005
  globalZIndex: 1,
3997
4006
  globalCompositeOperation: "",
3998
4007
  overflow: "hidden",
3999
- shadowPickMode: "graphic"
4008
+ shadowPickMode: "graphic",
4009
+ keepStrokeScale: !1
4000
4010
  }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
4001
4011
  function addAttributeToPrototype(obj, c, keys) {
4002
4012
  keys.forEach(key => {
@@ -4271,10 +4281,32 @@
4271
4281
  configure(service, env) {
4272
4282
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4273
4283
  }
4274
- measureTextWidth(text, options) {
4275
- if (!this.context) return this.estimate(text, options).width;
4284
+ _measureTextWithoutAlignBaseline(text, options, compatible) {
4276
4285
  this.context.setTextStyleWithoutAlignBaseline(options);
4277
- return this.context.measureText(text).width;
4286
+ const metrics = this.context.measureText(text);
4287
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4288
+ }
4289
+ _measureTextWithAlignBaseline(text, options, compatible) {
4290
+ this.context.setTextStyle(options);
4291
+ const metrics = this.context.measureText(text);
4292
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4293
+ }
4294
+ compatibleMetrics(metrics, options) {
4295
+ if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4296
+ const {
4297
+ ascent: ascent,
4298
+ descent: descent
4299
+ } = this.measureTextBoundADscentEstimate(options);
4300
+ metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4301
+ }
4302
+ if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4303
+ const {
4304
+ left: left,
4305
+ right: right
4306
+ } = this.measureTextBoundLeftRightEstimate(options);
4307
+ metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
4308
+ }
4309
+ return metrics;
4278
4310
  }
4279
4311
  estimate(text, _ref) {
4280
4312
  let {
@@ -4288,19 +4320,104 @@
4288
4320
  height: fontSize
4289
4321
  };
4290
4322
  }
4291
- measureTextPixelHeight(text, options) {
4323
+ measureTextWidth(text, options, textMeasure) {
4324
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4325
+ }
4326
+ measureTextBoundsWidth(text, options, textMeasure) {
4327
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4328
+ }
4329
+ measureTextBoundsLeftRight(text, options, textMeasure) {
4330
+ return this.context ? {
4331
+ left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
4332
+ right: textMeasure.actualBoundingBoxRight
4333
+ } : this.measureTextBoundLeftRightEstimate(options);
4334
+ }
4335
+ measureTextPixelHeight(text, options, textMeasure) {
4292
4336
  var _a;
4293
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4294
- this.context.setTextStyleWithoutAlignBaseline(options);
4295
- const textMeasure = this.context.measureText(text);
4296
- return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
4337
+ 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;
4338
+ }
4339
+ measureTextPixelADscent(text, options, textMeasure) {
4340
+ return this.context ? {
4341
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
4342
+ descent: textMeasure.actualBoundingBoxDescent
4343
+ } : this.measureTextBoundADscentEstimate(options);
4297
4344
  }
4298
- measureTextBoundHieght(text, options) {
4345
+ measureTextBoundHieght(text, options, textMeasure) {
4299
4346
  var _a;
4300
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4301
- this.context.setTextStyleWithoutAlignBaseline(options);
4302
- const textMeasure = this.context.measureText(text);
4303
- return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
4347
+ 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;
4348
+ }
4349
+ measureTextBoundADscent(text, options, textMeasure) {
4350
+ return this.context ? {
4351
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
4352
+ descent: textMeasure.fontBoundingBoxDescent
4353
+ } : this.measureTextBoundADscentEstimate(options);
4354
+ }
4355
+ measureTextBoundADscentEstimate(options) {
4356
+ var _a;
4357
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4358
+ return {
4359
+ ascent: .79 * fontSize,
4360
+ descent: .21 * fontSize
4361
+ };
4362
+ }
4363
+ measureTextBoundLeftRightEstimate(options) {
4364
+ var _a;
4365
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4366
+ {
4367
+ textAlign: textAlign
4368
+ } = options;
4369
+ return "center" === textAlign ? {
4370
+ left: fontSize / 2,
4371
+ right: fontSize / 2
4372
+ } : "right" === textAlign || "end" === textAlign ? {
4373
+ left: fontSize,
4374
+ right: 0
4375
+ } : {
4376
+ left: 0,
4377
+ right: fontSize
4378
+ };
4379
+ }
4380
+ measureTextPixelADscentAndWidth(text, options, mode) {
4381
+ if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4382
+ width: this.estimate(text, options).width
4383
+ });
4384
+ const out = this._measureTextWithoutAlignBaseline(text, options, !0);
4385
+ if (mode === exports.MeasureModeEnum.actualBounding) return {
4386
+ ascent: out.actualBoundingBoxAscent,
4387
+ descent: out.actualBoundingBoxDescent,
4388
+ width: out.width
4389
+ };
4390
+ if (mode === exports.MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4391
+ width: out.width
4392
+ });
4393
+ if (mode === exports.MeasureModeEnum.fontBounding) {
4394
+ const {
4395
+ lineHeight = options.fontSize
4396
+ } = options;
4397
+ let ratio = 1;
4398
+ if (lineHeight) {
4399
+ ratio = lineHeight / (out.fontBoundingBoxAscent + out.fontBoundingBoxDescent);
4400
+ }
4401
+ let ascent = out.fontBoundingBoxAscent * ratio,
4402
+ descent = out.fontBoundingBoxDescent * ratio;
4403
+ if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
4404
+ const delta = out.actualBoundingBoxDescent - descent;
4405
+ descent += delta, ascent -= delta;
4406
+ } else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
4407
+ const delta = out.actualBoundingBoxAscent - ascent;
4408
+ ascent += delta, descent -= delta;
4409
+ }
4410
+ return {
4411
+ ascent: ascent,
4412
+ descent: descent,
4413
+ width: out.width
4414
+ };
4415
+ }
4416
+ return {
4417
+ ascent: out.actualBoundingBoxAscent,
4418
+ descent: out.actualBoundingBoxDescent,
4419
+ width: out.width
4420
+ };
4304
4421
  }
4305
4422
  measureText(text, options) {
4306
4423
  return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
@@ -6412,7 +6529,7 @@
6412
6529
  }
6413
6530
  }
6414
6531
 
6415
- class DefaultTicker {
6532
+ class DefaultTicker extends EventEmitter {
6416
6533
  set mode(m) {
6417
6534
  this._mode !== m && (this._mode = m, this.setupTickHandler());
6418
6535
  }
@@ -6421,17 +6538,17 @@
6421
6538
  }
6422
6539
  constructor() {
6423
6540
  let timelines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6424
- this.handleTick = (handler, params) => {
6541
+ super(), this.handleTick = (handler, params) => {
6425
6542
  const {
6426
6543
  once = !1
6427
6544
  } = null != params ? params : {};
6428
- this.ifCanStop() ? this.stop() : (this._handlerTick(handler), once || handler.tick(this.interval, this.handleTick));
6429
- }, this._handlerTick = handler => {
6545
+ this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
6546
+ }, this._handlerTick = () => {
6430
6547
  const time = this.tickerHandler.getTime();
6431
6548
  let delta = 0;
6432
6549
  this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
6433
6550
  t.tick(delta);
6434
- }));
6551
+ }), this.emit("afterTick"));
6435
6552
  }, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.timelines = timelines, this.autoStop = !0;
6436
6553
  }
6437
6554
  init() {
@@ -6527,6 +6644,9 @@
6527
6644
  stop() {
6528
6645
  this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
6529
6646
  }
6647
+ trySyncTickStatus() {
6648
+ this.status === STATUS$1.RUNNING && this._handlerTick();
6649
+ }
6530
6650
  }
6531
6651
 
6532
6652
  class ManualTickHandler {
@@ -7668,7 +7788,7 @@
7668
7788
  lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
7669
7789
  break;
7670
7790
  }
7671
- "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);
7791
+ "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);
7672
7792
  let prevMatchedPoint = this.toPoints[0];
7673
7793
  this.interpolatePoints = this.toPoints.map((point, index) => {
7674
7794
  const matchedPoint = tagMap.get(point.context);
@@ -7680,11 +7800,19 @@
7680
7800
  return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
7681
7801
  });
7682
7802
  }
7803
+ onFirstRun() {
7804
+ const lastClipRange = this.target.attribute.clipRange;
7805
+ isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
7806
+ }
7683
7807
  onUpdate(end, ratio, out) {
7684
7808
  if (this.points = this.points.map((point, index) => {
7685
7809
  const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
7686
7810
  return newPoint.context = point.context, newPoint;
7687
- }), this.clipRange && (out.clipRange = this.clipRange + (1 - this.clipRange) * ratio), this.segmentsCache && this.to.segments) {
7811
+ }), this.clipRange) {
7812
+ 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));
7813
+ out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
7814
+ }
7815
+ if (this.segmentsCache && this.to.segments) {
7688
7816
  let start = 0;
7689
7817
  out.segments = this.to.segments.map((segment, index) => {
7690
7818
  const end = start + this.segmentsCache[index],
@@ -9100,7 +9228,7 @@
9100
9228
  }
9101
9229
  static GetFile(url, type) {
9102
9230
  let data = ResourceLoader.cache.get(url);
9103
- return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
9231
+ return data ? "init" === data.loadState || "fail" === data.loadState ? Promise.reject() : "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
9104
9232
  type: type,
9105
9233
  loadState: "init"
9106
9234
  }, 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));
@@ -12038,7 +12166,8 @@
12038
12166
  x: originX = arcAttribute.x,
12039
12167
  y: originY = arcAttribute.y,
12040
12168
  scaleX = arcAttribute.scaleX,
12041
- scaleY = arcAttribute.scaleY
12169
+ scaleY = arcAttribute.scaleY,
12170
+ keepStrokeScale = arcAttribute.keepStrokeScale
12042
12171
  } = arc.attribute;
12043
12172
  let {
12044
12173
  innerRadius = arcAttribute.innerRadius,
@@ -12050,7 +12179,7 @@
12050
12179
  {
12051
12180
  distance = arcAttribute[key].distance
12052
12181
  } = borderStyle,
12053
- d = getScaledStroke(context, distance, context.dpr),
12182
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12054
12183
  deltaAngle = distance / outerRadius,
12055
12184
  sign = "outerBorder" === key ? 1 : -1;
12056
12185
  if (arc.setAttributes({
@@ -12095,14 +12224,15 @@
12095
12224
  x: originX = circleAttribute.x,
12096
12225
  y: originY = circleAttribute.y,
12097
12226
  scaleX = circleAttribute.scaleX,
12098
- scaleY = circleAttribute.scaleY
12227
+ scaleY = circleAttribute.scaleY,
12228
+ keepStrokeScale = circleAttribute.keepStrokeScale
12099
12229
  } = circle.attribute,
12100
12230
  renderBorder = (borderStyle, key) => {
12101
12231
  const doStroke = !(!borderStyle || !borderStyle.stroke),
12102
12232
  {
12103
12233
  distance = circleAttribute[key].distance
12104
12234
  } = borderStyle,
12105
- d = getScaledStroke(context, distance, context.dpr),
12235
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12106
12236
  sign = "outerBorder" === key ? 1 : -1;
12107
12237
  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) {
12108
12238
  const lastOpacity = circleAttribute[key].opacity;
@@ -12221,7 +12351,8 @@
12221
12351
  scaleX = rectAttribute.scaleX,
12222
12352
  scaleY = rectAttribute.scaleY,
12223
12353
  x1: x1,
12224
- y1: y1
12354
+ y1: y1,
12355
+ keepStrokeScale = rectAttribute.keepStrokeScale
12225
12356
  } = rect.attribute;
12226
12357
  let {
12227
12358
  width: width,
@@ -12234,7 +12365,7 @@
12234
12365
  {
12235
12366
  distance = rectAttribute[key].distance
12236
12367
  } = borderStyle,
12237
- d = getScaledStroke(context, distance, context.dpr),
12368
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12238
12369
  nextX = x + sign * d,
12239
12370
  nextY = y + sign * d,
12240
12371
  dw = 2 * d;
@@ -12364,9 +12495,8 @@
12364
12495
  constructor() {
12365
12496
  super(...arguments), this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
12366
12497
  }
12367
- drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
12368
- if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12369
- image.renderFrame(context, x, y);
12498
+ drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
12499
+ return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12370
12500
  }
12371
12501
  }
12372
12502
  const defaultImageRenderContribution = new DefaultImageRenderContribution();
@@ -12392,14 +12522,15 @@
12392
12522
  x: originX = symbolAttribute.x,
12393
12523
  y: originY = symbolAttribute.y,
12394
12524
  scaleX = symbolAttribute.scaleX,
12395
- scaleY = symbolAttribute.scaleY
12525
+ scaleY = symbolAttribute.scaleY,
12526
+ keepStrokeScale = symbolAttribute.keepStrokeScale
12396
12527
  } = symbol.attribute,
12397
12528
  renderBorder = (borderStyle, key) => {
12398
12529
  const doStroke = !(!borderStyle || !borderStyle.stroke),
12399
12530
  {
12400
12531
  distance = symbolAttribute[key].distance
12401
12532
  } = borderStyle,
12402
- d = getScaledStroke(context, distance, context.dpr),
12533
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12403
12534
  sign = "outerBorder" === key ? 1 : -1;
12404
12535
  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) {
12405
12536
  const lastOpacity = symbolAttribute[key].opacity;
@@ -13677,16 +13808,8 @@
13677
13808
  verticalMode = textAttribute.verticalMode,
13678
13809
  x: originX = textAttribute.x,
13679
13810
  y: originY = textAttribute.y
13680
- } = text.attribute;
13681
- let {
13682
- textAlign = textAttribute.textAlign,
13683
- textBaseline = textAttribute.textBaseline
13684
- } = text.attribute;
13685
- if (!verticalMode && "vertical" === direction) {
13686
- const t = textAlign;
13687
- textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
13688
- }
13689
- const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
13811
+ } = text.attribute,
13812
+ lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
13690
13813
  data = this.valid(text, textAttribute, fillCb, strokeCb);
13691
13814
  if (!data) return;
13692
13815
  const {
@@ -13706,79 +13829,60 @@
13706
13829
  const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
13707
13830
  matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
13708
13831
  }
13709
- 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());
13832
+ 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());
13710
13833
  };
13711
- if (text.isMultiLine) {
13712
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13713
- const {
13714
- multilineLayout: multilineLayout
13715
- } = text;
13716
- if (!multilineLayout) return void context.highPerformanceRestore();
13717
- const {
13718
- xOffset: xOffset,
13719
- yOffset: yOffset
13720
- } = multilineLayout.bbox;
13721
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13722
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13723
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13724
- 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, {
13725
- width: line.width
13726
- });
13727
- })));
13728
- } else {
13729
- text.tryUpdateAABBBounds();
13730
- const cache = text.cache,
13731
- {
13732
- verticalList: verticalList
13733
- } = cache;
13734
- context.textAlign = "left", context.textBaseline = "top";
13735
- const totalHeight = lineHeight * verticalList.length;
13736
- let totalW = 0;
13737
- verticalList.forEach(verticalData => {
13738
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13739
- totalW = max(_w, totalW);
13740
- });
13741
- let offsetY = 0,
13742
- offsetX = 0;
13743
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13744
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13745
- dw = totalW - currentW;
13746
- let currentOffsetY = offsetY;
13747
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13748
- const {
13749
- text: text,
13750
- width: width,
13751
- direction: direction
13752
- } = item;
13753
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13754
- });
13834
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13835
+ const {
13836
+ multilineLayout: multilineLayout
13837
+ } = text;
13838
+ if (!multilineLayout) return void context.highPerformanceRestore();
13839
+ const {
13840
+ xOffset: xOffset,
13841
+ yOffset: yOffset
13842
+ } = multilineLayout.bbox;
13843
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13844
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13845
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13846
+ 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, {
13847
+ width: line.width
13755
13848
  });
13756
- }
13757
- } else if ("horizontal" === direction) {
13758
- context.setTextStyle(text.attribute, textAttribute, z);
13759
- const t = text.clipedText;
13760
- let dy = 0;
13761
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
13849
+ })));
13762
13850
  } else {
13851
+ let {
13852
+ textAlign = textAttribute.textAlign,
13853
+ textBaseline = textAttribute.textBaseline
13854
+ } = text.attribute;
13855
+ if (!verticalMode) {
13856
+ const t = textAlign;
13857
+ textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
13858
+ }
13763
13859
  text.tryUpdateAABBBounds();
13764
- const cache = text.cache;
13765
- if (cache) {
13766
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
13767
- const {
13860
+ const cache = text.cache,
13861
+ {
13768
13862
  verticalList: verticalList
13769
13863
  } = cache;
13770
- let offsetY = 0;
13771
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
13772
- let offsetX = 0;
13773
- "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 => {
13864
+ context.textAlign = "left", context.textBaseline = "top";
13865
+ const totalHeight = lineHeight * verticalList.length;
13866
+ let totalW = 0;
13867
+ verticalList.forEach(verticalData => {
13868
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13869
+ totalW = max(_w, totalW);
13870
+ });
13871
+ let offsetY = 0,
13872
+ offsetX = 0;
13873
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13874
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13875
+ dw = totalW - currentW;
13876
+ let currentOffsetY = offsetY;
13877
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13774
13878
  const {
13775
13879
  text: text,
13776
13880
  width: width,
13777
13881
  direction: direction
13778
13882
  } = item;
13779
- drawText(text, offsetX, offsetY, direction), offsetY += width;
13883
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13780
13884
  });
13781
- }
13885
+ });
13782
13886
  }
13783
13887
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
13784
13888
  }
@@ -13790,12 +13894,10 @@
13790
13894
  computed3dMatrix = !keepDirIn3d;
13791
13895
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
13792
13896
  }
13793
- drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
13897
+ drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
13794
13898
  if (lineThrough + underline <= 0) return;
13795
13899
  const {
13796
13900
  textAlign = textAttribute.textAlign,
13797
- textBaseline = textAttribute.textBaseline,
13798
- fontSize = textAttribute.fontSize,
13799
13901
  fill = textAttribute.fill,
13800
13902
  opacity = textAttribute.opacity,
13801
13903
  underlineOffset = textAttribute.underlineOffset,
@@ -13805,23 +13907,21 @@
13805
13907
  isMulti = !isNil$1(multiOption),
13806
13908
  w = isMulti ? multiOption.width : text.clipedWidth,
13807
13909
  offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
13808
- offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
13809
13910
  attribute = {
13810
13911
  lineWidth: 0,
13811
13912
  stroke: fill,
13812
13913
  opacity: opacity,
13813
13914
  strokeOpacity: fillOpacity
13814
13915
  };
13815
- let deltaY = isMulti ? -3 : 0;
13816
13916
  if (underline) {
13817
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
13818
- const dy = y + offsetY + fontSize + underlineOffset + deltaY;
13819
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
13917
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
13918
+ const dy = anchorY + offsetUnderLineY + underlineOffset;
13919
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
13820
13920
  }
13821
- if (isMulti && (deltaY = -1), lineThrough) {
13822
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
13823
- const dy = y + offsetY + fontSize / 2 + deltaY;
13824
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
13921
+ if (lineThrough) {
13922
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
13923
+ const dy = anchorY + offsetThroughLineY;
13924
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
13825
13925
  }
13826
13926
  }
13827
13927
  };
@@ -14116,12 +14216,10 @@
14116
14216
  const {
14117
14217
  image: url
14118
14218
  } = image.attribute;
14119
- if (!image.isGifImage) {
14120
- if (!url || !image.resources) return;
14121
- const res = image.resources.get(url);
14122
- if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
14123
- if ("success" !== res.state) return;
14124
- }
14219
+ if (!url || !image.resources) return;
14220
+ const res = image.resources.get(url);
14221
+ if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
14222
+ if ("success" !== res.state) return;
14125
14223
  const {
14126
14224
  context: context
14127
14225
  } = renderService.drawParams;
@@ -14513,51 +14611,45 @@
14513
14611
  }
14514
14612
  return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
14515
14613
  }
14516
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
14517
- const linesLayout = [],
14518
- bboxWH = [width, height],
14519
- bboxOffset = [0, 0];
14520
- for (; str.length > 0;) {
14521
- const {
14522
- str: clipText
14523
- } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
14524
- linesLayout.push({
14525
- str: clipText,
14526
- width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
14527
- }), str = str.substring(clipText.length);
14528
- }
14529
- "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]));
14530
- const bbox = {
14531
- xOffset: bboxOffset[0],
14532
- yOffset: bboxOffset[1],
14533
- width: bboxWH[0],
14534
- height: bboxWH[1]
14535
- };
14536
- return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14537
- }
14538
14614
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
14539
14615
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
14540
14616
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
14541
- let lineWidth = arguments.length > 6 ? arguments[6] : undefined;
14542
- let suffixPosition = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "end";
14617
+ let params = arguments.length > 6 ? arguments[6] : undefined;
14618
+ const {
14619
+ lineWidth: lineWidth,
14620
+ suffixPosition = "end",
14621
+ measureMode = exports.MeasureModeEnum.actualBounding
14622
+ } = null != params ? params : {};
14543
14623
  lines = lines.map(l => l.toString());
14544
14624
  const linesLayout = [],
14545
14625
  bboxWH = [0, 0];
14546
14626
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
14547
14627
  let width;
14548
- for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
14549
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14550
- width: width
14551
- });
14628
+ for (let i = 0, len = lines.length; i < len; i++) {
14629
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
14630
+ width = Math.min(metrics.width, lineWidth), linesLayout.push({
14631
+ str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14632
+ width: width,
14633
+ ascent: metrics.ascent,
14634
+ descent: metrics.descent
14635
+ });
14636
+ }
14552
14637
  bboxWH[0] = lineWidth;
14553
14638
  } else {
14554
- let width, text;
14555
- lineWidth = 0;
14556
- 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({
14557
- str: text,
14558
- width: width
14559
- });
14560
- bboxWH[0] = lineWidth;
14639
+ let width,
14640
+ text,
14641
+ _lineWidth = 0;
14642
+ for (let i = 0, len = lines.length; i < len; i++) {
14643
+ text = lines[i];
14644
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
14645
+ width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
14646
+ str: text,
14647
+ width: width,
14648
+ ascent: metrics.ascent,
14649
+ descent: metrics.descent
14650
+ });
14651
+ }
14652
+ bboxWH[0] = _lineWidth;
14561
14653
  }
14562
14654
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
14563
14655
  const bbox = {
@@ -14585,11 +14677,11 @@
14585
14677
  };
14586
14678
  }
14587
14679
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
14588
- 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;
14680
+ 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;
14589
14681
  }
14590
14682
  }
14591
14683
 
14592
- const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
14684
+ 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];
14593
14685
  class Text extends Graphic {
14594
14686
  get font() {
14595
14687
  const textTheme = this.getGraphicTheme();
@@ -14598,26 +14690,22 @@
14598
14690
  get clipedText() {
14599
14691
  var _a;
14600
14692
  const attribute = this.attribute,
14601
- textTheme = this.getGraphicTheme();
14602
- if (!this.isSimplify()) return;
14603
- const {
14604
- maxLineWidth = textTheme.maxLineWidth
14605
- } = attribute;
14606
- return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14693
+ textTheme = this.getGraphicTheme(),
14694
+ maxWidth = this.getMaxWidth(textTheme);
14695
+ return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14607
14696
  }
14608
14697
  get clipedWidth() {
14609
- if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14698
+ return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14610
14699
  }
14611
14700
  get cliped() {
14612
14701
  var _a, _b;
14613
14702
  const textTheme = this.getGraphicTheme(),
14614
14703
  attribute = this.attribute,
14615
- {
14616
- maxLineWidth = textTheme.maxLineWidth,
14617
- text: text,
14618
- whiteSpace = textTheme.whiteSpace
14619
- } = attribute;
14620
- if (!Number.isFinite(maxLineWidth)) return !1;
14704
+ maxWidth = this.getMaxWidth(textTheme);
14705
+ if (!Number.isFinite(maxWidth)) return !1;
14706
+ const {
14707
+ text: text
14708
+ } = this.attribute;
14621
14709
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
14622
14710
  let mergedText = "";
14623
14711
  this.cache.layoutData.lines.forEach(item => {
@@ -14628,10 +14716,7 @@
14628
14716
  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();
14629
14717
  }
14630
14718
  get multilineLayout() {
14631
- if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
14632
- }
14633
- isSimplify() {
14634
- return !this.isMultiLine && "vertical" !== this.attribute.direction;
14719
+ return this.tryUpdateAABBBounds(), this.cache.layoutData;
14635
14720
  }
14636
14721
  get isMultiLine() {
14637
14722
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -14704,8 +14789,72 @@
14704
14789
  }
14705
14790
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
14706
14791
  }
14792
+ updateSingallineAABBBounds(text) {
14793
+ this.updateMultilineAABBBounds([text]);
14794
+ const layoutData = this.cache.layoutData;
14795
+ if (layoutData) {
14796
+ const line = layoutData.lines[0];
14797
+ this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
14798
+ }
14799
+ return this._AABBBounds;
14800
+ }
14801
+ updateMultilineAABBBounds(text) {
14802
+ const textTheme = this.getGraphicTheme(),
14803
+ {
14804
+ direction = textTheme.direction,
14805
+ underlineOffset = textTheme.underlineOffset
14806
+ } = this.attribute,
14807
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14808
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14809
+ }
14810
+ guessLineHeightBuf(fontSize) {
14811
+ return fontSize ? .1 * fontSize : 0;
14812
+ }
14813
+ updateHorizontalMultilineAABBBounds(text) {
14814
+ var _a;
14815
+ const textTheme = this.getGraphicTheme(),
14816
+ attribute = this.attribute,
14817
+ {
14818
+ fontFamily = textTheme.fontFamily,
14819
+ textAlign = textTheme.textAlign,
14820
+ textBaseline = textTheme.textBaseline,
14821
+ fontSize = textTheme.fontSize,
14822
+ fontWeight = textTheme.fontWeight,
14823
+ ellipsis = textTheme.ellipsis,
14824
+ maxLineWidth: maxLineWidth,
14825
+ stroke = textTheme.stroke,
14826
+ wrap = textTheme.wrap,
14827
+ measureMode = textTheme.measureMode,
14828
+ lineWidth = textTheme.lineWidth,
14829
+ whiteSpace = textTheme.whiteSpace,
14830
+ suffixPosition = textTheme.suffixPosition,
14831
+ ignoreBuf = textTheme.ignoreBuf
14832
+ } = attribute,
14833
+ buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
14834
+ lineHeight = this.getLineHeight(attribute, textTheme) + buf;
14835
+ if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
14836
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14837
+ const bbox = this.cache.layoutData.bbox;
14838
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14839
+ }
14840
+ const textMeasure = application.graphicUtil.textMeasure,
14841
+ layoutData = new CanvasTextLayout(fontFamily, {
14842
+ fontSize: fontSize,
14843
+ fontWeight: fontWeight,
14844
+ fontFamily: fontFamily,
14845
+ lineHeight: lineHeight
14846
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
14847
+ lineWidth: maxLineWidth,
14848
+ suffixPosition: suffixPosition,
14849
+ measureMode: measureMode
14850
+ }),
14851
+ {
14852
+ bbox: bbox
14853
+ } = layoutData;
14854
+ 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;
14855
+ }
14707
14856
  updateWrapAABBBounds(text) {
14708
- var _a, _b, _c, _d;
14857
+ var _a, _b, _c;
14709
14858
  const textTheme = this.getGraphicTheme(),
14710
14859
  {
14711
14860
  fontFamily = textTheme.fontFamily,
@@ -14719,22 +14868,25 @@
14719
14868
  wordBreak = textTheme.wordBreak,
14720
14869
  fontWeight = textTheme.fontWeight,
14721
14870
  ignoreBuf = textTheme.ignoreBuf,
14871
+ measureMode = textTheme.measureMode,
14722
14872
  suffixPosition = textTheme.suffixPosition,
14723
14873
  heightLimit = 0,
14724
14874
  lineClamp: lineClamp
14725
14875
  } = this.attribute,
14726
- lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
14727
- buf = ignoreBuf ? 0 : 2;
14728
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14876
+ buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
14877
+ lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
14878
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14729
14879
  const bbox = this.cache.layoutData.bbox;
14730
14880
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14731
14881
  }
14732
14882
  const textMeasure = application.graphicUtil.textMeasure,
14733
- layoutObj = new CanvasTextLayout(fontFamily, {
14883
+ textOptions = {
14734
14884
  fontSize: fontSize,
14735
14885
  fontWeight: fontWeight,
14736
- fontFamily: fontFamily
14737
- }, textMeasure),
14886
+ fontFamily: fontFamily,
14887
+ lineHeight: lineHeight
14888
+ },
14889
+ layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
14738
14890
  lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
14739
14891
  linesLayout = [],
14740
14892
  bboxWH = [0, 0];
@@ -14744,29 +14896,35 @@
14744
14896
  const str = lines[i];
14745
14897
  let needCut = !0;
14746
14898
  if (i === lineCountLimit - 1) {
14747
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
14899
+ const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
14900
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
14748
14901
  linesLayout.push({
14749
14902
  str: clip.str,
14750
- width: clip.width
14903
+ width: clip.width,
14904
+ ascent: matrics.ascent,
14905
+ descent: matrics.descent
14751
14906
  });
14752
14907
  break;
14753
14908
  }
14754
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14909
+ const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14755
14910
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
14756
14911
  if (ellipsis) {
14757
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14758
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
14912
+ const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14913
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
14759
14914
  } else clip.str = "", clip.width = 0;
14760
14915
  needCut = !1;
14761
14916
  }
14917
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
14762
14918
  linesLayout.push({
14763
14919
  str: clip.str,
14764
- width: clip.width
14920
+ width: clip.width,
14921
+ ascent: matrics.ascent,
14922
+ descent: matrics.descent
14765
14923
  });
14766
14924
  let cutLength = clip.str.length;
14767
14925
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
14768
- let newStr = str.substring(cutLength);
14769
- "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
14926
+ const newStr = str.substring(cutLength);
14927
+ lines.splice(i + 1, 0, newStr);
14770
14928
  }
14771
14929
  }
14772
14930
  let maxWidth = 0;
@@ -14779,21 +14937,28 @@
14779
14937
  lineWidth = 0;
14780
14938
  for (let i = 0, len = lines.length; i < len; i++) {
14781
14939
  if (i === lineCountLimit - 1) {
14782
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14940
+ const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
14941
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
14783
14942
  linesLayout.push({
14784
14943
  str: clip.str,
14785
- width: clip.width
14944
+ width: clip.width,
14945
+ ascent: matrics.ascent,
14946
+ descent: matrics.descent
14786
14947
  }), lineWidth = Math.max(lineWidth, clip.width);
14787
14948
  break;
14788
14949
  }
14789
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
14950
+ text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
14951
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
14952
+ linesLayout.push({
14790
14953
  str: text,
14791
- width: width
14954
+ width: width,
14955
+ ascent: matrics.ascent,
14956
+ descent: matrics.descent
14792
14957
  });
14793
14958
  }
14794
14959
  bboxWH[0] = lineWidth;
14795
14960
  }
14796
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
14961
+ bboxWH[1] = linesLayout.length * lineHeight;
14797
14962
  const bbox = {
14798
14963
  xOffset: 0,
14799
14964
  yOffset: 0,
@@ -14804,210 +14969,12 @@
14804
14969
  const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14805
14970
  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;
14806
14971
  }
14807
- updateSingallineAABBBounds(text) {
14808
- const textTheme = this.getGraphicTheme(),
14809
- {
14810
- direction = textTheme.direction,
14811
- underlineOffset = textTheme.underlineOffset
14812
- } = this.attribute,
14813
- b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
14814
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14815
- }
14816
- updateMultilineAABBBounds(text) {
14817
- const textTheme = this.getGraphicTheme(),
14818
- {
14819
- direction = textTheme.direction,
14820
- underlineOffset = textTheme.underlineOffset
14821
- } = this.attribute,
14822
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14823
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14824
- }
14825
- updateHorizontalSinglelineAABBBounds(text) {
14826
- var _a, _b;
14827
- const textTheme = this.getGraphicTheme(),
14828
- {
14829
- wrap = textTheme.wrap
14830
- } = this.attribute;
14831
- if (wrap) return this.updateWrapAABBBounds([text]);
14832
- const textMeasure = application.graphicUtil.textMeasure;
14833
- let width, str;
14834
- const attribute = this.attribute,
14835
- {
14836
- maxLineWidth = textTheme.maxLineWidth,
14837
- ellipsis = textTheme.ellipsis,
14838
- textAlign = textTheme.textAlign,
14839
- textBaseline = textTheme.textBaseline,
14840
- fontFamily = textTheme.fontFamily,
14841
- fontSize = textTheme.fontSize,
14842
- fontWeight = textTheme.fontWeight,
14843
- stroke = textTheme.stroke,
14844
- lineWidth = textTheme.lineWidth,
14845
- ignoreBuf = textTheme.ignoreBuf,
14846
- whiteSpace = textTheme.whiteSpace,
14847
- suffixPosition = textTheme.suffixPosition
14848
- } = attribute;
14849
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14850
- const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
14851
- textFontSize = attribute.fontSize || textTheme.fontSize,
14852
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
14853
- if (!this.shouldUpdateShape() && this.cache) {
14854
- width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
14855
- const dx = textDrawOffsetX(textAlign, width),
14856
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14857
- return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14858
- }
14859
- if (Number.isFinite(maxLineWidth)) {
14860
- if (ellipsis) {
14861
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14862
- data = textMeasure.clipTextWithSuffix(text.toString(), {
14863
- fontSize: fontSize,
14864
- fontWeight: fontWeight,
14865
- fontFamily: fontFamily
14866
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14867
- str = data.str, width = data.width;
14868
- } else {
14869
- const data = textMeasure.clipText(text.toString(), {
14870
- fontSize: fontSize,
14871
- fontWeight: fontWeight,
14872
- fontFamily: fontFamily
14873
- }, maxLineWidth, !1);
14874
- str = data.str, width = data.width;
14875
- }
14876
- this.cache.clipedText = str, this.cache.clipedWidth = width;
14877
- } else width = textMeasure.measureTextWidth(text.toString(), {
14878
- fontSize: fontSize,
14879
- fontWeight: fontWeight,
14880
- fontFamily: fontFamily
14881
- }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
14882
- this.clearUpdateShapeTag();
14883
- const dx = textDrawOffsetX(textAlign, width);
14884
- let lh = lineHeight;
14885
- application.global && application.global.isSafari() && (lh += .2 * fontSize);
14886
- const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
14887
- return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14888
- }
14889
- getBaselineMapAlign() {
14890
- return Text.baselineMapAlign;
14891
- }
14892
- getAlignMapBaseline() {
14893
- return Text.alignMapBaseline;
14894
- }
14895
- updateVerticalSinglelineAABBBounds(text) {
14896
- var _a, _b, _c;
14897
- const textTheme = this.getGraphicTheme(),
14898
- textMeasure = application.graphicUtil.textMeasure;
14899
- let width;
14900
- const attribute = this.attribute,
14901
- {
14902
- ignoreBuf = textTheme.ignoreBuf
14903
- } = attribute,
14904
- buf = ignoreBuf ? 0 : 2,
14905
- {
14906
- maxLineWidth = textTheme.maxLineWidth,
14907
- ellipsis = textTheme.ellipsis,
14908
- fontSize = textTheme.fontSize,
14909
- fontWeight = textTheme.fontWeight,
14910
- fontFamily = textTheme.fontFamily,
14911
- stroke = textTheme.stroke,
14912
- lineWidth = textTheme.lineWidth,
14913
- verticalMode = textTheme.verticalMode,
14914
- suffixPosition = textTheme.suffixPosition
14915
- } = attribute,
14916
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14917
- let {
14918
- textAlign = textTheme.textAlign,
14919
- textBaseline = textTheme.textBaseline
14920
- } = attribute;
14921
- if (!verticalMode) {
14922
- const t = textAlign;
14923
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14924
- }
14925
- if (!this.shouldUpdateShape() && this.cache) {
14926
- width = this.cache.clipedWidth;
14927
- const dx = textDrawOffsetX(textAlign, width),
14928
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14929
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14930
- }
14931
- let verticalList = [verticalLayout(text.toString())];
14932
- if (Number.isFinite(maxLineWidth)) {
14933
- if (ellipsis) {
14934
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14935
- data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
14936
- fontSize: fontSize,
14937
- fontWeight: fontWeight,
14938
- fontFamily: fontFamily
14939
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14940
- verticalList = [data.verticalList], width = data.width;
14941
- } else {
14942
- const data = textMeasure.clipTextVertical(verticalList[0], {
14943
- fontSize: fontSize,
14944
- fontWeight: fontWeight,
14945
- fontFamily: fontFamily
14946
- }, maxLineWidth, !1);
14947
- verticalList = [data.verticalList], width = data.width;
14948
- }
14949
- this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14950
- } else width = 0, verticalList[0].forEach(t => {
14951
- const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
14952
- fontSize: fontSize,
14953
- fontWeight: fontWeight,
14954
- fontFamily: fontFamily
14955
- });
14956
- width += w, t.width = w;
14957
- }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14958
- this.clearUpdateShapeTag();
14959
- const dx = textDrawOffsetX(textAlign, width),
14960
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14961
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14962
- }
14963
- updateHorizontalMultilineAABBBounds(text) {
14964
- var _a, _b;
14965
- const textTheme = this.getGraphicTheme(),
14966
- {
14967
- wrap = textTheme.wrap
14968
- } = this.attribute;
14969
- if (wrap) return this.updateWrapAABBBounds(text);
14970
- const attribute = this.attribute,
14971
- {
14972
- fontFamily = textTheme.fontFamily,
14973
- textAlign = textTheme.textAlign,
14974
- textBaseline = textTheme.textBaseline,
14975
- fontSize = textTheme.fontSize,
14976
- fontWeight = textTheme.fontWeight,
14977
- ellipsis = textTheme.ellipsis,
14978
- maxLineWidth: maxLineWidth,
14979
- stroke = textTheme.stroke,
14980
- lineWidth = textTheme.lineWidth,
14981
- whiteSpace = textTheme.whiteSpace,
14982
- suffixPosition = textTheme.suffixPosition
14983
- } = attribute,
14984
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
14985
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14986
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14987
- const bbox = this.cache.layoutData.bbox;
14988
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14989
- }
14990
- const textMeasure = application.graphicUtil.textMeasure,
14991
- layoutData = new CanvasTextLayout(fontFamily, {
14992
- fontSize: fontSize,
14993
- fontWeight: fontWeight,
14994
- fontFamily: fontFamily
14995
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14996
- {
14997
- bbox: bbox
14998
- } = layoutData;
14999
- 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;
15000
- }
15001
14972
  updateVerticalMultilineAABBBounds(text) {
15002
- var _a, _b, _c;
14973
+ var _a, _b;
15003
14974
  const textTheme = this.getGraphicTheme(),
15004
14975
  textMeasure = application.graphicUtil.textMeasure;
15005
14976
  let width;
15006
14977
  const attribute = this.attribute,
15007
- {
15008
- ignoreBuf = textTheme.ignoreBuf
15009
- } = attribute,
15010
- buf = ignoreBuf ? 0 : 2,
15011
14978
  {
15012
14979
  maxLineWidth = textTheme.maxLineWidth,
15013
14980
  ellipsis = textTheme.ellipsis,
@@ -15019,14 +14986,14 @@
15019
14986
  verticalMode = textTheme.verticalMode,
15020
14987
  suffixPosition = textTheme.suffixPosition
15021
14988
  } = attribute,
15022
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14989
+ lineHeight = this.getLineHeight(attribute, textTheme);
15023
14990
  let {
15024
14991
  textAlign = textTheme.textAlign,
15025
14992
  textBaseline = textTheme.textBaseline
15026
14993
  } = attribute;
15027
14994
  if (!verticalMode) {
15028
14995
  const t = textAlign;
15029
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14996
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
15030
14997
  }
15031
14998
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
15032
14999
  this.cache.verticalList.forEach(item => {
@@ -15074,6 +15041,15 @@
15074
15041
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
15075
15042
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15076
15043
  }
15044
+ getMaxWidth(theme) {
15045
+ var _a, _b;
15046
+ const attribute = this.attribute;
15047
+ return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
15048
+ }
15049
+ getLineHeight(attribute, textTheme) {
15050
+ var _a;
15051
+ return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
15052
+ }
15077
15053
  needUpdateTags(keys) {
15078
15054
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
15079
15055
  return super.needUpdateTags(keys, k);
@@ -15088,6 +15064,12 @@
15088
15064
  getNoWorkAnimateAttr() {
15089
15065
  return Text.NOWORK_ANIMATE_ATTR;
15090
15066
  }
15067
+ getBaselineMapAlign() {
15068
+ return Text.baselineMapAlign;
15069
+ }
15070
+ getAlignMapBaseline() {
15071
+ return Text.alignMapBaseline;
15072
+ }
15091
15073
  }
15092
15074
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
15093
15075
  ellipsis: 1,
@@ -15166,7 +15148,9 @@
15166
15148
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15167
15149
  linesLayout.push({
15168
15150
  str: clip.str,
15169
- width: clip.width
15151
+ width: clip.width,
15152
+ ascent: 0,
15153
+ descent: 0
15170
15154
  });
15171
15155
  break;
15172
15156
  }
@@ -15180,7 +15164,9 @@
15180
15164
  }
15181
15165
  if (linesLayout.push({
15182
15166
  str: clip.str,
15183
- width: clip.width
15167
+ width: clip.width,
15168
+ ascent: 0,
15169
+ descent: 0
15184
15170
  }), clip.str.length === str.length) ;else if (needCut) {
15185
15171
  const newStr = str.substring(clip.str.length);
15186
15172
  lines.splice(i + 1, 0, newStr);
@@ -15199,13 +15185,17 @@
15199
15185
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15200
15186
  linesLayout.push({
15201
15187
  str: clip.str,
15202
- width: clip.width
15188
+ width: clip.width,
15189
+ ascent: 0,
15190
+ descent: 0
15203
15191
  }), lineWidth = Math.max(lineWidth, clip.width);
15204
15192
  break;
15205
15193
  }
15206
15194
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
15207
15195
  str: text,
15208
- width: width
15196
+ width: width,
15197
+ ascent: 0,
15198
+ descent: 0
15209
15199
  });
15210
15200
  }
15211
15201
  bboxWH[0] = lineWidth;
@@ -15249,6 +15239,9 @@
15249
15239
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
15250
15240
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
15251
15241
  }
15242
+ parseSize(size) {
15243
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15244
+ }
15252
15245
  }
15253
15246
 
15254
15247
  function circle(ctx, r, x, y, z) {
@@ -15259,13 +15252,13 @@
15259
15252
  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";
15260
15253
  }
15261
15254
  draw(ctx, size, x, y, z) {
15262
- return circle(ctx, size / 2, x, y, z);
15255
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
15263
15256
  }
15264
15257
  drawOffset(ctx, size, x, y, offset, z) {
15265
- return circle(ctx, size / 2 + offset, x, y, z);
15258
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15266
15259
  }
15267
15260
  drawToSvgPath(size, x, y, z) {
15268
- const r = size / 2;
15261
+ const r = this.parseSize(size) / 2;
15269
15262
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
15270
15263
  }
15271
15264
  }
@@ -15282,10 +15275,10 @@
15282
15275
  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";
15283
15276
  }
15284
15277
  draw(ctx, size, x, y, z) {
15285
- return cross(ctx, size / 6, x, y, z);
15278
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
15286
15279
  }
15287
15280
  drawOffset(ctx, size, x, y, offset, z) {
15288
- return crossOffset(ctx, size / 6, x, y, offset, z);
15281
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
15289
15282
  }
15290
15283
  }
15291
15284
  var cross$1 = new CrossSymbol();
@@ -15298,13 +15291,13 @@
15298
15291
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
15299
15292
  }
15300
15293
  draw(ctx, size, x, y, z) {
15301
- return diamond(ctx, size / 2, x, y, z);
15294
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15302
15295
  }
15303
15296
  drawFitDir(ctx, size, x, y, z) {
15304
- return diamond(ctx, size / 2, x, y, z);
15297
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15305
15298
  }
15306
15299
  drawOffset(ctx, size, x, y, offset, z) {
15307
- return diamond(ctx, size / 2 + offset, x, y, z);
15300
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15308
15301
  }
15309
15302
  }
15310
15303
  var diamond$1 = new DiamondSymbol();
@@ -15318,10 +15311,10 @@
15318
15311
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
15319
15312
  }
15320
15313
  draw(ctx, size, x, y) {
15321
- return square(ctx, size / 2, x, y);
15314
+ return square(ctx, this.parseSize(size) / 2, x, y);
15322
15315
  }
15323
15316
  drawOffset(ctx, size, x, y, offset) {
15324
- return square(ctx, size / 2 + offset, x, y);
15317
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
15325
15318
  }
15326
15319
  }
15327
15320
  var square$1 = new SquareSymbol();
@@ -15335,10 +15328,10 @@
15335
15328
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
15336
15329
  }
15337
15330
  draw(ctx, size, x, y) {
15338
- return trianglUpOffset(ctx, size / 2, x, y);
15331
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
15339
15332
  }
15340
15333
  drawOffset(ctx, size, x, y, offset) {
15341
- return trianglUpOffset(ctx, size / 2, x, y, offset);
15334
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15342
15335
  }
15343
15336
  }
15344
15337
  var triangleUp = new TriangleUpSymbol();
@@ -15370,10 +15363,10 @@
15370
15363
  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";
15371
15364
  }
15372
15365
  draw(ctx, size, transX, transY) {
15373
- return star(ctx, size / 2, transX, transY);
15366
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
15374
15367
  }
15375
15368
  drawOffset(ctx, size, transX, transY, offset) {
15376
- return star(ctx, size / 2 + offset, transX, transY);
15369
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15377
15370
  }
15378
15371
  }
15379
15372
  var star$1 = new StarSymbol();
@@ -15391,10 +15384,10 @@
15391
15384
  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";
15392
15385
  }
15393
15386
  draw(ctx, size, transX, transY) {
15394
- return arrow(ctx, size / 2, transX, transY);
15387
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
15395
15388
  }
15396
15389
  drawOffset(ctx, size, transX, transY, offset) {
15397
- return arrow(ctx, size / 2 + offset, transX, transY);
15390
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15398
15391
  }
15399
15392
  }
15400
15393
  var arrow$1 = new ArrowSymbol();
@@ -15408,10 +15401,10 @@
15408
15401
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
15409
15402
  }
15410
15403
  draw(ctx, size, transX, transY) {
15411
- return wedge(ctx, size / 2, transX, transY);
15404
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
15412
15405
  }
15413
15406
  drawOffset(ctx, size, transX, transY, offset) {
15414
- return wedge(ctx, size / 2 + offset, transX, transY);
15407
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15415
15408
  }
15416
15409
  }
15417
15410
  var wedge$1 = new WedgeSymbol();
@@ -15424,10 +15417,10 @@
15424
15417
  super(...arguments), this.type = "stroke", this.pathStr = "";
15425
15418
  }
15426
15419
  draw(ctx, size, transX, transY) {
15427
- return stroke(ctx, size / 2, transX, transY);
15420
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
15428
15421
  }
15429
15422
  drawOffset(ctx, size, transX, transY, offset) {
15430
- return stroke(ctx, size / 2 + offset, transX, transY);
15423
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15431
15424
  }
15432
15425
  }
15433
15426
  var stroke$1 = new StrokeSymbol();
@@ -15449,10 +15442,10 @@
15449
15442
  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";
15450
15443
  }
15451
15444
  draw(ctx, size, transX, transY) {
15452
- return wye(ctx, size / 2, transX, transY);
15445
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
15453
15446
  }
15454
15447
  drawOffset(ctx, size, transX, transY, offset) {
15455
- return wye(ctx, size / 2 + offset, transX, transY);
15448
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15456
15449
  }
15457
15450
  }
15458
15451
  var wye$1 = new WyeSymbol();
@@ -15465,10 +15458,10 @@
15465
15458
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
15466
15459
  }
15467
15460
  draw(ctx, size, x, y) {
15468
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
15461
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
15469
15462
  }
15470
15463
  drawOffset(ctx, size, x, y, offset) {
15471
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
15464
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15472
15465
  }
15473
15466
  }
15474
15467
  var triangleLeft = new TriangleLeftSymbol();
@@ -15482,10 +15475,10 @@
15482
15475
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
15483
15476
  }
15484
15477
  draw(ctx, size, x, y) {
15485
- return trianglRightOffset(ctx, size / 2, x, y);
15478
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
15486
15479
  }
15487
15480
  drawOffset(ctx, size, x, y, offset) {
15488
- return trianglRightOffset(ctx, size / 2, x, y, offset);
15481
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15489
15482
  }
15490
15483
  }
15491
15484
  var triangleRight = new TriangleRightSymbol();
@@ -15499,10 +15492,10 @@
15499
15492
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
15500
15493
  }
15501
15494
  draw(ctx, size, x, y) {
15502
- return trianglDownOffset(ctx, size / 2, x, y);
15495
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
15503
15496
  }
15504
15497
  drawOffset(ctx, size, x, y, offset) {
15505
- return trianglDownOffset(ctx, size / 2, x, y, offset);
15498
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15506
15499
  }
15507
15500
  }
15508
15501
  var triangleDown = new TriangleDownSymbol();
@@ -15517,10 +15510,10 @@
15517
15510
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
15518
15511
  }
15519
15512
  draw(ctx, size, x, y) {
15520
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
15513
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
15521
15514
  }
15522
15515
  drawOffset(ctx, size, x, y, offset) {
15523
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
15516
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
15524
15517
  }
15525
15518
  }
15526
15519
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -15534,10 +15527,10 @@
15534
15527
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
15535
15528
  }
15536
15529
  draw(ctx, size, transX, transY) {
15537
- return arrow2Left(ctx, size / 4, transX, transY);
15530
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
15538
15531
  }
15539
15532
  drawOffset(ctx, size, transX, transY, offset) {
15540
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
15533
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15541
15534
  }
15542
15535
  }
15543
15536
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -15551,10 +15544,10 @@
15551
15544
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
15552
15545
  }
15553
15546
  draw(ctx, size, transX, transY) {
15554
- return arrow2Right(ctx, size / 4, transX, transY);
15547
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
15555
15548
  }
15556
15549
  drawOffset(ctx, size, transX, transY, offset) {
15557
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
15550
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15558
15551
  }
15559
15552
  }
15560
15553
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -15568,10 +15561,10 @@
15568
15561
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
15569
15562
  }
15570
15563
  draw(ctx, size, transX, transY) {
15571
- return arrow2Up(ctx, size / 4, transX, transY);
15564
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
15572
15565
  }
15573
15566
  drawOffset(ctx, size, transX, transY, offset) {
15574
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
15567
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15575
15568
  }
15576
15569
  }
15577
15570
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -15585,10 +15578,10 @@
15585
15578
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
15586
15579
  }
15587
15580
  draw(ctx, size, transX, transY) {
15588
- return arrow2Down(ctx, size / 4, transX, transY);
15581
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
15589
15582
  }
15590
15583
  drawOffset(ctx, size, transX, transY, offset) {
15591
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
15584
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15592
15585
  }
15593
15586
  }
15594
15587
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -15601,13 +15594,13 @@
15601
15594
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
15602
15595
  }
15603
15596
  draw(ctx, size, x, y, z) {
15604
- return lineV(ctx, size / 2, x, y);
15597
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
15605
15598
  }
15606
15599
  drawOffset(ctx, size, x, y, offset, z) {
15607
- return lineV(ctx, size / 2 + offset, x, y);
15600
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
15608
15601
  }
15609
15602
  drawToSvgPath(size, x, y, z) {
15610
- const r = size / 2;
15603
+ const r = this.parseSize(size) / 2;
15611
15604
  return `M ${x}, ${y - r} L ${x},${y + r}`;
15612
15605
  }
15613
15606
  }
@@ -15621,13 +15614,13 @@
15621
15614
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
15622
15615
  }
15623
15616
  draw(ctx, size, x, y, z) {
15624
- return lineH(ctx, size / 2, x, y);
15617
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
15625
15618
  }
15626
15619
  drawOffset(ctx, size, x, y, offset, z) {
15627
- return lineH(ctx, size / 2 + offset, x, y);
15620
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
15628
15621
  }
15629
15622
  drawToSvgPath(size, x, y, z) {
15630
- const r = size / 2;
15623
+ const r = this.parseSize(size) / 2;
15631
15624
  return `M ${x - r}, ${y} L ${x + r},${y}`;
15632
15625
  }
15633
15626
  }
@@ -15641,13 +15634,13 @@
15641
15634
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
15642
15635
  }
15643
15636
  draw(ctx, size, x, y, z) {
15644
- return close(ctx, size / 2, x, y);
15637
+ return close(ctx, this.parseSize(size) / 2, x, y);
15645
15638
  }
15646
15639
  drawOffset(ctx, size, x, y, offset, z) {
15647
- return close(ctx, size / 2 + offset, x, y);
15640
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
15648
15641
  }
15649
15642
  drawToSvgPath(size, x, y, z) {
15650
- const r = size / 2;
15643
+ const r = this.parseSize(size) / 2;
15651
15644
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
15652
15645
  }
15653
15646
  }
@@ -15681,15 +15674,18 @@
15681
15674
  this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
15682
15675
  }
15683
15676
  drawOffset(ctx, size, x, y, offset, z, cb) {
15684
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15677
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15685
15678
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
15686
15679
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
15687
15680
  }
15688
15681
  draw(ctx, size, x, y, z, cb) {
15689
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
15682
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
15683
+ }
15684
+ parseSize(size) {
15685
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15690
15686
  }
15691
15687
  bounds(size, bounds) {
15692
- if (this.isSvg) {
15688
+ if (size = this.parseSize(size), this.isSvg) {
15693
15689
  if (!this.svgCache) return;
15694
15690
  return bounds.clear(), void this.svgCache.forEach(_ref => {
15695
15691
  let {
@@ -16372,7 +16368,11 @@
16372
16368
  case "sub":
16373
16369
  baseline += this.descent / 2;
16374
16370
  }
16375
- "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();
16371
+ "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);
16372
+ const {
16373
+ lineWidth = 1
16374
+ } = this.character;
16375
+ 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();
16376
16376
  }
16377
16377
  getWidthWithEllips(direction) {
16378
16378
  let text = this.text;
@@ -18589,7 +18589,7 @@
18589
18589
  constructor() {
18590
18590
  let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18591
18591
  var _a;
18592
- super({}), this._onVisibleChange = visible => {
18592
+ super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
18593
18593
  if (!(this._skipRender < 0)) if (visible) {
18594
18594
  if (this.dirtyBounds) {
18595
18595
  const b = this.window.getViewBox();
@@ -18600,7 +18600,10 @@
18600
18600
  }, this.beforeRender = stage => {
18601
18601
  this._beforeRender && this._beforeRender(stage);
18602
18602
  }, this.afterRender = stage => {
18603
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
18603
+ this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
18604
+ }, this.afterTickCb = () => {
18605
+ var _a;
18606
+ this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
18604
18607
  }, this.params = params, this.theme = new Theme(), this.hooks = {
18605
18608
  beforeRender: new SyncHook(["stage"]),
18606
18609
  afterRender: new SyncHook(["stage"])
@@ -18617,7 +18620,7 @@
18617
18620
  main: !0
18618
18621
  })), 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({
18619
18622
  background: this._background
18620
- });
18623
+ }), this.ticker.on("afterTick", this.afterTickCb);
18621
18624
  }
18622
18625
  pauseRender() {
18623
18626
  let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
@@ -18846,7 +18849,7 @@
18846
18849
  if ("released" === this.releaseStatus) return;
18847
18850
  this.ticker.start(), this.timeline.resume();
18848
18851
  const state = this.state;
18849
- 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++;
18852
+ 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++;
18850
18853
  }
18851
18854
  combineLayersToWindow() {
18852
18855
  if ("harmony" === this.global.env) {
@@ -18952,7 +18955,7 @@
18952
18955
  layer.release();
18953
18956
  }), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
18954
18957
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
18955
- }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
18958
+ }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
18956
18959
  }
18957
18960
  setStage(stage) {}
18958
18961
  dirty(b, matrix) {
@@ -19030,8 +19033,6 @@
19030
19033
  return new Stage(params);
19031
19034
  }
19032
19035
 
19033
- const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
19034
-
19035
19036
  var __decorate$1d = undefined && undefined.__decorate || function (decorators, target, key, desc) {
19036
19037
  var d,
19037
19038
  c = arguments.length,
@@ -23652,11 +23653,9 @@
23652
23653
  name: name,
23653
23654
  id: id,
23654
23655
  attribute: attribute,
23655
- stateProxy: stateProxy,
23656
- animation: animation,
23657
- timeline: timeline
23656
+ stateProxy: stateProxy
23658
23657
  } = _a,
23659
- props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy", "animation", "timeline"]);
23658
+ props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy"]);
23660
23659
  let c = type;
23661
23660
  isString$1(type) && (c = graphicCreator[type]);
23662
23661
  const childrenList = [];
@@ -23665,13 +23664,7 @@
23665
23664
  }
23666
23665
  children.length && flatten(1 === children.length ? children[0] : children, childrenList);
23667
23666
  const g = "Group" === c.name ? new c(attribute) : c(config);
23668
- if (parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), name && (g.name = name), isArray$1(animation)) {
23669
- const animate = g.animate();
23670
- timeline && animate.setTimeline(timeline), animation.forEach(item => {
23671
- animate[item[0]](...item.slice(1));
23672
- });
23673
- }
23674
- return g;
23667
+ return parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), g;
23675
23668
  }
23676
23669
  function parseToGraphic$1(g, childrenList, props) {
23677
23670
  let out,
@@ -23939,7 +23932,7 @@
23939
23932
  startTime: startTime,
23940
23933
  startPoints: startPoints
23941
23934
  } = this;
23942
- if (eventType) return eventType;
23935
+ if ("press" === eventType) return eventType;
23943
23936
  let type;
23944
23937
  return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
23945
23938
  }
@@ -24471,9 +24464,10 @@
24471
24464
  lineJoin = defaultParams.lineJoin,
24472
24465
  lineDash = defaultParams.lineDash,
24473
24466
  lineCap = defaultParams.lineCap,
24474
- miterLimit = defaultParams.miterLimit
24467
+ miterLimit = defaultParams.miterLimit,
24468
+ keepStrokeScale = defaultParams.keepStrokeScale
24475
24469
  } = attribute;
24476
- _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;
24470
+ _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;
24477
24471
  }
24478
24472
  }
24479
24473
  setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
@@ -25373,8 +25367,9 @@
25373
25367
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
25374
25368
  if (picked) return !0;
25375
25369
  const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
25376
- pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25377
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25370
+ pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25371
+ keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25372
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25378
25373
  }), pickContext.highPerformanceRestore(), picked;
25379
25374
  }
25380
25375
  }
@@ -25647,8 +25642,9 @@
25647
25642
  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) => {
25648
25643
  if (picked) return !0;
25649
25644
  const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
25650
- pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25651
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25645
+ pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25646
+ keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25647
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25652
25648
  });else {
25653
25649
  const {
25654
25650
  fill = rectAttribute.fill,
@@ -25962,9 +25958,10 @@
25962
25958
  lineJoin = defaultParams.lineJoin,
25963
25959
  lineDash = defaultParams.lineDash,
25964
25960
  lineCap = defaultParams.lineCap,
25965
- miterLimit = defaultParams.miterLimit
25961
+ miterLimit = defaultParams.miterLimit,
25962
+ keepStrokeScale = defaultParams.keepStrokeScale
25966
25963
  } = attribute;
25967
- _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;
25964
+ _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;
25968
25965
  }
25969
25966
  }
25970
25967
  measureText(text) {
@@ -26592,9 +26589,10 @@
26592
26589
  lineJoin = defaultParams.lineJoin,
26593
26590
  lineDash = defaultParams.lineDash,
26594
26591
  lineCap = defaultParams.lineCap,
26595
- miterLimit = defaultParams.miterLimit
26592
+ miterLimit = defaultParams.miterLimit,
26593
+ keepStrokeScale = defaultParams.keepStrokeScale
26596
26594
  } = attribute;
26597
- _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);
26595
+ _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);
26598
26596
  }
26599
26597
  }
26600
26598
  setTextStyleWithoutAlignBaseline(params, defaultParams) {
@@ -27634,9 +27632,10 @@
27634
27632
  lineJoin = defaultParams.lineJoin,
27635
27633
  lineDash = defaultParams.lineDash,
27636
27634
  lineCap = defaultParams.lineCap,
27637
- miterLimit = defaultParams.miterLimit
27635
+ miterLimit = defaultParams.miterLimit,
27636
+ keepStrokeScale = defaultParams.keepStrokeScale
27638
27637
  } = attribute;
27639
- _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;
27638
+ _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;
27640
27639
  }
27641
27640
  }
27642
27641
  measureText(text) {
@@ -28043,8 +28042,9 @@
28043
28042
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
28044
28043
  if (picked) return !0;
28045
28044
  const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
28046
- pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28047
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28045
+ pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28046
+ keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28047
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28048
28048
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28049
28049
  }
28050
28050
  }
@@ -28179,8 +28179,9 @@
28179
28179
  return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
28180
28180
  if (picked) return !0;
28181
28181
  const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
28182
- pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28183
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28182
+ pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28183
+ keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28184
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28184
28185
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28185
28186
  }
28186
28187
  };
@@ -28617,7 +28618,7 @@
28617
28618
 
28618
28619
  const roughModule = _roughModule;
28619
28620
 
28620
- const version = "0.21.0-alpha.4";
28621
+ const version = "0.21.0-alpha.6";
28621
28622
  preLoadAllModule();
28622
28623
  if (isBrowserEnv()) {
28623
28624
  loadBrowserEnv(container);