leafer-ui 1.0.0-rc.2 → 1.0.0-rc.4

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.
@@ -647,7 +647,7 @@ const BoundsHelper = {
647
647
  },
648
648
  getFitMatrix(t, put) {
649
649
  const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
650
- return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
650
+ return new Matrix(scale, 0, 0, scale, -Math.ceil(put.x * scale), -Math.ceil(put.y * scale));
651
651
  },
652
652
  getSpread(t, spreadX, spreadY) {
653
653
  const n = {};
@@ -1048,6 +1048,9 @@ const EventCreator = {
1048
1048
  }
1049
1049
  }
1050
1050
  },
1051
+ has(type) {
1052
+ return !!this.nameList[type];
1053
+ },
1051
1054
  get(type, ...params) {
1052
1055
  return new nameList[type](...params);
1053
1056
  }
@@ -4588,7 +4591,8 @@ class InteractionBase {
4588
4591
  dragDistance: 2,
4589
4592
  swipeDistance: 20,
4590
4593
  ignoreMove: false
4591
- }
4594
+ },
4595
+ cursor: {}
4592
4596
  };
4593
4597
  this.tapCount = 0;
4594
4598
  this.downKeyMap = {};
@@ -4814,6 +4818,8 @@ class InteractionBase {
4814
4818
  this.hoverData = data;
4815
4819
  }
4816
4820
  updateCursor(data) {
4821
+ if (this.config.cursor.stop)
4822
+ return;
4817
4823
  if (!data) {
4818
4824
  this.updateHoverData();
4819
4825
  data = this.hoverData;
@@ -4826,17 +4832,16 @@ class InteractionBase {
4826
4832
  }
4827
4833
  else if (!data || this.dragger.dragging)
4828
4834
  return;
4829
- const path = data.path;
4830
4835
  let leaf;
4836
+ let cursor;
4837
+ const { path } = data;
4831
4838
  for (let i = 0, len = path.length; i < len; i++) {
4832
4839
  leaf = path.list[i];
4833
- if (leaf.cursor) {
4834
- const { cursor } = leaf;
4835
- this.setCursor(cursor === 'grab' ? (this.downData ? 'grabbing' : cursor) : cursor);
4836
- return;
4837
- }
4840
+ cursor = leaf.cursor;
4841
+ if (cursor)
4842
+ break;
4838
4843
  }
4839
- this.setCursor('default');
4844
+ this.setCursor(cursor);
4840
4845
  }
4841
4846
  setCursor(cursor) {
4842
4847
  this.cursor = cursor;
@@ -5158,6 +5163,8 @@ const LeafEventer = {
5158
5163
  this.on(type, listener, { once: true, capture });
5159
5164
  },
5160
5165
  emit(type, event, capture) {
5166
+ if (!event && EventCreator.has(type))
5167
+ event = EventCreator.get(type, { type, target: this, current: this });
5161
5168
  const map = __getListenerMap(this, capture);
5162
5169
  const list = map[type];
5163
5170
  if (list) {
@@ -5452,7 +5459,7 @@ const LeafRender = {
5452
5459
  const tempCanvas = canvas.getSameCanvas(true);
5453
5460
  this.__draw(tempCanvas, options);
5454
5461
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5455
- if (options.matrix || this.__hasMirror) {
5462
+ if (this.__hasMirror || options.matrix) {
5456
5463
  canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
5457
5464
  }
5458
5465
  else {
@@ -5521,7 +5528,12 @@ const BranchRender = {
5521
5528
  this.__renderBranch(tempCanvas, options);
5522
5529
  canvas.opacity = this.__worldOpacity;
5523
5530
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5524
- options.matrix ? canvas.copyWorld(tempCanvas, null, null, blendMode) : canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5531
+ if (this.__hasMirror || options.matrix) {
5532
+ canvas.copyWorld(tempCanvas, null, null, blendMode);
5533
+ }
5534
+ else {
5535
+ canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5536
+ }
5525
5537
  tempCanvas.recycle();
5526
5538
  }
5527
5539
  else {
@@ -7420,7 +7432,7 @@ class UIData extends LeafData {
7420
7432
  if (typeof value === 'string' || !value) {
7421
7433
  if (this.__isFills) {
7422
7434
  this.__removeInput('fill');
7423
- Paint.recycleImage(this, 'fill');
7435
+ Paint.recycleImage('fill', this);
7424
7436
  this.__isFills = false;
7425
7437
  }
7426
7438
  this._fill = value;
@@ -7436,7 +7448,7 @@ class UIData extends LeafData {
7436
7448
  if (typeof value === 'string' || !value) {
7437
7449
  if (this.__isStrokes) {
7438
7450
  this.__removeInput('stroke');
7439
- Paint.recycleImage(this, 'stroke');
7451
+ Paint.recycleImage('stroke', this);
7440
7452
  this.__isStrokes = false;
7441
7453
  }
7442
7454
  this._stroke = value;
@@ -7688,11 +7700,11 @@ const UIRender = {
7688
7700
  const { fill, stroke, __drawAfterFill } = this.__;
7689
7701
  this.__drawRenderPath(canvas);
7690
7702
  if (fill)
7691
- Paint.fill(this, canvas, fill);
7703
+ Paint.fill(fill, this, canvas);
7692
7704
  if (__drawAfterFill)
7693
7705
  this.__drawAfterFill(canvas, options);
7694
7706
  if (stroke)
7695
- Paint.stroke(this, canvas, stroke);
7707
+ Paint.stroke(stroke, this, canvas, options);
7696
7708
  },
7697
7709
  __draw(canvas, options) {
7698
7710
  if (this.__.__complex) {
@@ -7704,40 +7716,40 @@ const UIRender = {
7704
7716
  if (shadow)
7705
7717
  Effect.shadow(this, canvas, shape, options);
7706
7718
  if (fill)
7707
- this.__.__isFills ? Paint.fills(this, canvas, fill) : Paint.fill(this, canvas, fill);
7719
+ this.__.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7708
7720
  if (__drawAfterFill)
7709
7721
  this.__drawAfterFill(canvas, options);
7710
7722
  if (innerShadow)
7711
7723
  Effect.innerShadow(this, canvas, shape, options);
7712
7724
  if (stroke)
7713
- this.__.__isStrokes ? Paint.strokes(this, canvas, stroke) : Paint.stroke(this, canvas, stroke);
7725
+ this.__.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7714
7726
  if (shape.worldCanvas)
7715
7727
  shape.worldCanvas.recycle();
7716
7728
  shape.canvas.recycle();
7717
7729
  }
7718
7730
  else {
7719
7731
  if (fill)
7720
- this.__.__isFills ? Paint.fills(this, canvas, fill) : Paint.fill(this, canvas, fill);
7732
+ this.__.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7721
7733
  if (__drawAfterFill)
7722
7734
  this.__drawAfterFill(canvas, options);
7723
7735
  if (stroke)
7724
- this.__.__isStrokes ? Paint.strokes(this, canvas, stroke) : Paint.stroke(this, canvas, stroke);
7736
+ this.__.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7725
7737
  }
7726
7738
  }
7727
7739
  else {
7728
7740
  this.__drawFast(canvas, options);
7729
7741
  }
7730
7742
  },
7731
- __renderShape(canvas, options) {
7743
+ __renderShape(canvas, renderOptions) {
7732
7744
  if (!this.__worldOpacity)
7733
7745
  return;
7734
- canvas.setWorld(this.__world, options.matrix);
7746
+ canvas.setWorld(this.__world, renderOptions.matrix);
7735
7747
  const { fill, stroke } = this.__;
7736
7748
  this.__drawRenderPath(canvas);
7737
7749
  if (fill)
7738
- Paint.fill(this, canvas, '#000000');
7750
+ Paint.fill('#000000', this, canvas);
7739
7751
  if (stroke)
7740
- Paint.stroke(this, canvas, '#000000');
7752
+ Paint.stroke('#000000', this, canvas, renderOptions);
7741
7753
  }
7742
7754
  };
7743
7755
 
@@ -7806,9 +7818,9 @@ let UI = UI_1 = class UI extends Leaf {
7806
7818
  if (this.__.__input) {
7807
7819
  const { fill, stroke } = this.__.__input;
7808
7820
  if (fill)
7809
- Paint.compute(this, 'fill');
7821
+ Paint.compute('fill', this);
7810
7822
  if (stroke)
7811
- Paint.compute(this, 'stroke');
7823
+ Paint.compute('stroke', this);
7812
7824
  }
7813
7825
  }
7814
7826
  __updateRenderPath() {
@@ -7925,7 +7937,7 @@ __decorate([
7925
7937
  hitType()
7926
7938
  ], UI.prototype, "hitRadius", void 0);
7927
7939
  __decorate([
7928
- cursorType('default')
7940
+ cursorType('')
7929
7941
  ], UI.prototype, "cursor", void 0);
7930
7942
  __decorate([
7931
7943
  surfaceType()
@@ -8272,14 +8284,19 @@ let Polygon = class Polygon extends UI {
8272
8284
  __updateRenderPath() {
8273
8285
  if (this.__.points && this.__.curve) {
8274
8286
  drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
8275
- this.__updateNaturalSize();
8276
8287
  }
8277
8288
  else {
8278
8289
  super.__updateRenderPath();
8279
8290
  }
8280
8291
  }
8281
8292
  __updateBoxBounds() {
8282
- this.__.points ? toBounds$2(this.__.path, this.__layout.boxBounds) : super.__updateBoxBounds();
8293
+ if (this.__.points) {
8294
+ toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
8295
+ this.__updateNaturalSize();
8296
+ }
8297
+ else {
8298
+ super.__updateBoxBounds();
8299
+ }
8283
8300
  }
8284
8301
  };
8285
8302
  __decorate([
@@ -8373,7 +8390,7 @@ let Line = class Line extends UI {
8373
8390
  }
8374
8391
  __updateBoxBounds() {
8375
8392
  if (this.points) {
8376
- toBounds$1(this.__.path, this.__layout.boxBounds);
8393
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8377
8394
  this.__updateNaturalSize();
8378
8395
  }
8379
8396
  else {
@@ -9383,7 +9400,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
9383
9400
  }
9384
9401
  }
9385
9402
 
9386
- function recycleImage(data, attrName) {
9403
+ function recycleImage(attrName, data) {
9387
9404
  const paints = (attrName === 'fill' ? data._fill : data._stroke);
9388
9405
  if (paints instanceof Array) {
9389
9406
  let image, recycleMap, input, url;
@@ -9428,11 +9445,11 @@ function fillText(ui, canvas) {
9428
9445
  }
9429
9446
  }
9430
9447
 
9431
- function fill(ui, canvas, fill) {
9448
+ function fill(fill, ui, canvas) {
9432
9449
  canvas.fillStyle = fill;
9433
9450
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
9434
9451
  }
9435
- function fills(ui, canvas, fills) {
9452
+ function fills(fills, ui, canvas) {
9436
9453
  let item;
9437
9454
  const { windingRule, __font } = ui.__;
9438
9455
  for (let i = 0, len = fills.length; i < len; i++) {
@@ -9463,32 +9480,37 @@ function fills(ui, canvas, fills) {
9463
9480
  }
9464
9481
  }
9465
9482
 
9466
- function strokeText(ui, canvas, stroke) {
9483
+ function strokeText(stroke, ui, canvas, renderOptions) {
9467
9484
  const { strokeAlign } = ui.__;
9468
9485
  const isStrokes = typeof stroke !== 'string';
9469
9486
  switch (strokeAlign) {
9470
9487
  case 'center':
9471
9488
  canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
9472
- isStrokes ? drawStrokesStyle(ui, stroke, canvas, true) : drawTextStroke(ui, canvas);
9489
+ isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9473
9490
  break;
9474
9491
  case 'inside':
9475
- drawAlignStroke(ui, canvas, stroke, 'inside', isStrokes);
9492
+ drawAlignStroke('inside', stroke, isStrokes, ui, canvas, renderOptions);
9476
9493
  break;
9477
9494
  case 'outside':
9478
- drawAlignStroke(ui, canvas, stroke, 'outside', isStrokes);
9495
+ drawAlignStroke('outside', stroke, isStrokes, ui, canvas, renderOptions);
9479
9496
  break;
9480
9497
  }
9481
9498
  }
9482
- function drawAlignStroke(ui, canvas, stroke, align, isStrokes) {
9499
+ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
9483
9500
  const { strokeWidth, __font } = ui.__;
9484
9501
  const out = canvas.getSameCanvas(true);
9485
9502
  out.setStroke(isStrokes ? undefined : stroke, strokeWidth * 2, ui.__);
9486
9503
  out.font = __font;
9487
- isStrokes ? drawStrokesStyle(ui, stroke, out, true) : drawTextStroke(ui, out);
9504
+ isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
9488
9505
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9489
9506
  fillText(ui, out);
9490
9507
  out.blendMode = 'normal';
9491
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9508
+ if (ui.__hasMirror || renderOptions.matrix) {
9509
+ canvas.copyWorldByReset(out);
9510
+ }
9511
+ else {
9512
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9513
+ }
9492
9514
  out.recycle();
9493
9515
  }
9494
9516
  function drawTextStroke(ui, canvas) {
@@ -9508,7 +9530,7 @@ function drawTextStroke(ui, canvas) {
9508
9530
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
9509
9531
  }
9510
9532
  }
9511
- function drawStrokesStyle(ui, strokes, canvas, isText) {
9533
+ function drawStrokesStyle(strokes, isText, ui, canvas) {
9512
9534
  let item;
9513
9535
  for (let i = 0, len = strokes.length; i < len; i++) {
9514
9536
  item = strokes[i];
@@ -9528,13 +9550,13 @@ function drawStrokesStyle(ui, strokes, canvas, isText) {
9528
9550
  }
9529
9551
  }
9530
9552
 
9531
- function stroke(ui, canvas, stroke) {
9553
+ function stroke(stroke, ui, canvas, renderOptions) {
9532
9554
  const options = ui.__;
9533
9555
  const { strokeWidth, strokeAlign, __font } = options;
9534
9556
  if (!strokeWidth)
9535
9557
  return;
9536
9558
  if (__font) {
9537
- strokeText(ui, canvas, stroke);
9559
+ strokeText(stroke, ui, canvas, renderOptions);
9538
9560
  }
9539
9561
  else {
9540
9562
  switch (strokeAlign) {
@@ -9556,31 +9578,36 @@ function stroke(ui, canvas, stroke) {
9556
9578
  out.stroke();
9557
9579
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9558
9580
  out.clearWorld(ui.__layout.renderBounds);
9559
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9581
+ if (ui.__hasMirror || renderOptions.matrix) {
9582
+ canvas.copyWorldByReset(out);
9583
+ }
9584
+ else {
9585
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9586
+ }
9560
9587
  out.recycle();
9561
9588
  break;
9562
9589
  }
9563
9590
  }
9564
9591
  }
9565
- function strokes(ui, canvas, strokes) {
9592
+ function strokes(strokes, ui, canvas, renderOptions) {
9566
9593
  const options = ui.__;
9567
9594
  const { strokeWidth, strokeAlign, __font } = options;
9568
9595
  if (!strokeWidth)
9569
9596
  return;
9570
9597
  if (__font) {
9571
- strokeText(ui, canvas, strokes);
9598
+ strokeText(strokes, ui, canvas, renderOptions);
9572
9599
  }
9573
9600
  else {
9574
9601
  switch (strokeAlign) {
9575
9602
  case 'center':
9576
9603
  canvas.setStroke(undefined, strokeWidth, options);
9577
- drawStrokesStyle(ui, strokes, canvas);
9604
+ drawStrokesStyle(strokes, false, ui, canvas);
9578
9605
  break;
9579
9606
  case 'inside':
9580
9607
  canvas.save();
9581
9608
  canvas.setStroke(undefined, strokeWidth * 2, options);
9582
9609
  options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9583
- drawStrokesStyle(ui, strokes, canvas);
9610
+ drawStrokesStyle(strokes, false, ui, canvas);
9584
9611
  canvas.restore();
9585
9612
  break;
9586
9613
  case 'outside':
@@ -9588,10 +9615,15 @@ function strokes(ui, canvas, strokes) {
9588
9615
  const out = canvas.getSameCanvas(true);
9589
9616
  ui.__drawRenderPath(out);
9590
9617
  out.setStroke(undefined, strokeWidth * 2, ui.__);
9591
- drawStrokesStyle(ui, strokes, out);
9618
+ drawStrokesStyle(strokes, false, ui, out);
9592
9619
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9593
9620
  out.clearWorld(renderBounds);
9594
- canvas.copyWorldToInner(out, ui.__world, renderBounds);
9621
+ if (ui.__hasMirror || renderOptions.matrix) {
9622
+ canvas.copyWorldByReset(out);
9623
+ }
9624
+ else {
9625
+ canvas.copyWorldToInner(out, ui.__world, renderBounds);
9626
+ }
9595
9627
  out.recycle();
9596
9628
  break;
9597
9629
  }
@@ -9723,21 +9755,21 @@ function conicGradient(paint, box) {
9723
9755
  }
9724
9756
 
9725
9757
  let recycleMap;
9726
- function compute(ui, attrName) {
9758
+ function compute(attrName, ui) {
9727
9759
  const value = [];
9728
9760
  let item;
9729
9761
  let paints = ui.__.__input[attrName];
9730
9762
  if (!(paints instanceof Array))
9731
9763
  paints = [paints];
9732
- recycleMap = recycleImage(ui.__, attrName);
9764
+ recycleMap = recycleImage(attrName, ui.__);
9733
9765
  for (let i = 0, len = paints.length; i < len; i++) {
9734
- item = getLeafPaint(ui, paints[i], attrName);
9766
+ item = getLeafPaint(attrName, paints[i], ui);
9735
9767
  if (item)
9736
9768
  value.push(item);
9737
9769
  }
9738
9770
  ui.__['_' + attrName] = value.length ? value : undefined;
9739
9771
  }
9740
- function getLeafPaint(ui, paint, attrName) {
9772
+ function getLeafPaint(attrName, paint, ui) {
9741
9773
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
9742
9774
  return undefined;
9743
9775
  const { boxBounds } = ui.__layout;
@@ -9775,7 +9807,7 @@ var UIPaint = /*#__PURE__*/Object.freeze({
9775
9807
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
9776
9808
  const tempBounds = {};
9777
9809
  const offsetOutBounds$1 = {};
9778
- function shadow(ui, current, shape, _options) {
9810
+ function shadow(ui, current, shape, renderOptions) {
9779
9811
  let copyBounds, spreadScale;
9780
9812
  const { __world, __layout } = ui;
9781
9813
  const { shadow } = ui.__;
@@ -9797,7 +9829,7 @@ function shadow(ui, current, shape, _options) {
9797
9829
  }
9798
9830
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9799
9831
  }
9800
- if (ui.__hasMirror) {
9832
+ if (ui.__hasMirror || renderOptions.matrix) {
9801
9833
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9802
9834
  }
9803
9835
  else {
@@ -9837,7 +9869,7 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9837
9869
 
9838
9870
  const { toOffsetOutBounds } = BoundsHelper;
9839
9871
  const offsetOutBounds = {};
9840
- function innerShadow(ui, current, shape, _options) {
9872
+ function innerShadow(ui, current, shape, renderOptions) {
9841
9873
  let copyBounds, spreadScale;
9842
9874
  const { __world, __layout: __layout } = ui;
9843
9875
  const { innerShadow } = ui.__;
@@ -9861,7 +9893,7 @@ function innerShadow(ui, current, shape, _options) {
9861
9893
  copyBounds = bounds;
9862
9894
  }
9863
9895
  other.fillWorld(copyBounds, item.color, 'source-in');
9864
- if (ui.__hasMirror) {
9896
+ if (ui.__hasMirror || renderOptions.matrix) {
9865
9897
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9866
9898
  }
9867
9899
  else {
@@ -9999,7 +10031,7 @@ function getTextCase(char, textCase, firstChar) {
9999
10031
  const { trimRight } = TextRowHelper;
10000
10032
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
10001
10033
  let word, row, wordWidth, rowWidth, realWidth;
10002
- let char, charWidth, charType, lastCharType, langBreak, afterBreak, paraStart;
10034
+ let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
10003
10035
  let textDrawData, rows = [], bounds;
10004
10036
  function createRows(drawData, content, style) {
10005
10037
  textDrawData = drawData;
@@ -10012,7 +10044,7 @@ function createRows(drawData, content, style) {
10012
10044
  if (charMode) {
10013
10045
  paraStart = true;
10014
10046
  lastCharType = null;
10015
- wordWidth = rowWidth = 0;
10047
+ startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
10016
10048
  word = { data: [] }, row = { words: [] };
10017
10049
  for (let i = 0, len = content.length; i < len; i++) {
10018
10050
  char = content[i];
@@ -10028,8 +10060,11 @@ function createRows(drawData, content, style) {
10028
10060
  if (charType === Letter && textCase !== 'none')
10029
10061
  char = getTextCase(char, textCase, !wordWidth);
10030
10062
  charWidth = canvas.measureText(char).width;
10031
- if (__letterSpacing)
10063
+ if (__letterSpacing) {
10064
+ if (__letterSpacing < 0)
10065
+ charSize = charWidth;
10032
10066
  charWidth += __letterSpacing;
10067
+ }
10033
10068
  langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
10034
10069
  afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
10035
10070
  realWidth = paraStart && paraIndent ? width - paraIndent : width;
@@ -10079,6 +10114,8 @@ function createRows(drawData, content, style) {
10079
10114
  }
10080
10115
  }
10081
10116
  function addChar(char, width) {
10117
+ if (charSize && !startCharSize)
10118
+ startCharSize = charSize;
10082
10119
  word.data.push({ char, width });
10083
10120
  wordWidth += width;
10084
10121
  }
@@ -10095,6 +10132,11 @@ function addRow() {
10095
10132
  row.paraStart = true;
10096
10133
  paraStart = false;
10097
10134
  }
10135
+ if (charSize) {
10136
+ row.startCharSize = startCharSize;
10137
+ row.endCharSize = charSize;
10138
+ startCharSize = 0;
10139
+ }
10098
10140
  row.width = rowWidth;
10099
10141
  if (bounds.width)
10100
10142
  trimRight(row);
@@ -10168,7 +10210,7 @@ function toChar(data, charX, rowData) {
10168
10210
 
10169
10211
  function layoutText(drawData, style) {
10170
10212
  const { rows, bounds } = drawData;
10171
- const { __lineHeight, __baseLine, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
10213
+ const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
10172
10214
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
10173
10215
  let starY = __baseLine;
10174
10216
  if (textOverflow !== 'show' && realHeight > height) {
@@ -10185,7 +10227,7 @@ function layoutText(drawData, style) {
10185
10227
  }
10186
10228
  }
10187
10229
  starY += y;
10188
- let row;
10230
+ let row, rowX, rowWidth;
10189
10231
  for (let i = 0, len = rows.length; i < len; i++) {
10190
10232
  row = rows[i];
10191
10233
  row.x = x;
@@ -10204,20 +10246,22 @@ function layoutText(drawData, style) {
10204
10246
  row.isOverflow = true;
10205
10247
  drawData.overflow = i + 1;
10206
10248
  }
10207
- if (row.width < 0) {
10208
- const charWidth = row.words[0].data[0].width;
10209
- const rowX = row.x + row.width;
10210
- if (rowX < bounds.x)
10211
- bounds.x = rowX - charWidth;
10212
- if (-row.width > bounds.width)
10213
- bounds.width = -row.width + style.fontSize + charWidth;
10214
- }
10215
- else {
10216
- if (row.x < bounds.x)
10217
- bounds.x = row.x;
10218
- if (row.width > bounds.width)
10219
- bounds.width = row.width;
10249
+ rowX = row.x;
10250
+ rowWidth = row.width;
10251
+ if (__letterSpacing < 0) {
10252
+ if (row.width < 0) {
10253
+ rowWidth = -row.width + style.fontSize + __letterSpacing;
10254
+ rowX -= rowWidth;
10255
+ rowWidth += style.fontSize;
10256
+ }
10257
+ else {
10258
+ rowWidth -= __letterSpacing;
10259
+ }
10220
10260
  }
10261
+ if (rowX < bounds.x)
10262
+ bounds.x = rowX;
10263
+ if (rowWidth > bounds.width)
10264
+ bounds.width = rowWidth;
10221
10265
  }
10222
10266
  bounds.y = y;
10223
10267
  bounds.height = realHeight;
@@ -10269,10 +10313,9 @@ const TextConvert = {
10269
10313
  if (typeof content !== 'string')
10270
10314
  content = String(content);
10271
10315
  let x = 0, y = 0;
10272
- let { width, height, padding } = style;
10273
- const { textDecoration, textOverflow, __font } = style;
10274
- if (!width)
10275
- width = 0;
10316
+ let width = style.__getInput('width') || 0;
10317
+ let height = style.__getInput('height') || 0;
10318
+ const { textDecoration, textOverflow, __font, padding } = style;
10276
10319
  if (padding) {
10277
10320
  const [top, right, bottom, left] = MathHelper.fourNumber(padding);
10278
10321
  if (width) {