@galacean/effects-core 1.6.0-beta.1 → 1.6.0-beta.2

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
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.6.0-beta.1
6
+ * Version: v1.6.0-beta.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -20284,32 +20284,37 @@ var TextLayout = /** @class */ (function () {
20284
20284
  this.textAlign = textAlign;
20285
20285
  this.lineHeight = lineHeight;
20286
20286
  }
20287
- TextLayout.prototype.getOffsetY = function (style) {
20288
- var offsetY = 0;
20289
- var offset = (style.fontSize + style.outlineWidth) * style.fontScale;
20287
+ TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight) {
20288
+ var offsetResult = 0;
20289
+ var fontSize = style.fontSize, outlineWidth = style.outlineWidth, fontScale = style.fontScale;
20290
+ // 计算基础偏移量
20291
+ var baseOffset = (fontSize + outlineWidth) * fontScale;
20292
+ // /3 计算Y轴偏移量,以匹配编辑器行为
20293
+ var offsetY = (lineHeight - fontSize) / 3;
20294
+ var commonCalculation = lineHeight * (lineCount - 1);
20290
20295
  switch (this.textBaseline) {
20291
- case 0:
20292
- offsetY = offset;
20296
+ case TextBaseline$1.top:
20297
+ offsetResult = baseOffset + offsetY;
20293
20298
  break;
20294
- case 1:
20295
- offsetY = (this.height + offset) / 2; // fonSize;
20299
+ case TextBaseline$1.middle:
20300
+ offsetResult = (this.height * fontScale - commonCalculation + baseOffset) / 2;
20296
20301
  break;
20297
- case 2:
20298
- offsetY = this.height - offset / 2;
20302
+ case TextBaseline$1.bottom:
20303
+ offsetResult = (this.height * fontScale - commonCalculation) - offsetY;
20299
20304
  break;
20300
20305
  }
20301
- return offsetY;
20306
+ return offsetResult;
20302
20307
  };
20303
20308
  TextLayout.prototype.getOffsetX = function (style, maxWidth) {
20304
20309
  var offsetX = 0;
20305
20310
  switch (this.textAlign) {
20306
- case 0:
20311
+ case TextAlignment$1.left:
20307
20312
  offsetX = style.outlineWidth * style.fontScale;
20308
20313
  break;
20309
- case 1:
20314
+ case TextAlignment$1.middle:
20310
20315
  offsetX = (this.width * style.fontScale - maxWidth) / 2;
20311
20316
  break;
20312
- case 2:
20317
+ case TextAlignment$1.right:
20313
20318
  offsetX = (this.width * style.fontScale - maxWidth);
20314
20319
  break;
20315
20320
  }
@@ -20543,7 +20548,7 @@ var TextItem = /** @class */ (function (_super) {
20543
20548
  var fontScale = style.fontScale;
20544
20549
  var width = (layout.width + style.fontOffset) * fontScale;
20545
20550
  var height = layout.height * fontScale;
20546
- var fontSize = style.fontSize * fontScale;
20551
+ style.fontSize * fontScale;
20547
20552
  var lineHeight = layout.lineHeight * fontScale;
20548
20553
  this.char = (this.text || '').split('');
20549
20554
  this.canvas.width = width;
@@ -20563,10 +20568,9 @@ var TextItem = /** @class */ (function (_super) {
20563
20568
  // 文本颜色
20564
20569
  context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
20565
20570
  var charsInfo = [];
20566
- // /3 为了和编辑器行为保持一致
20567
- var offsetY = (lineHeight - fontSize) / 3;
20568
20571
  var x = 0;
20569
- var y = layout.getOffsetY(style) + offsetY;
20572
+ var lineCount = this.text.split('\n').length;
20573
+ var y = layout.getOffsetY(style, lineCount, lineHeight);
20570
20574
  var charsArray = [];
20571
20575
  var charOffsetX = [];
20572
20576
  for (var i = 0; i < this.char.length; i++) {