@galacean/effects-core 2.8.7 → 2.8.8

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: v2.8.7
6
+ * Version: v2.8.8
7
7
  */
8
8
 
9
9
  'use strict';
@@ -28985,8 +28985,8 @@ var TextComponentBase = /*#__PURE__*/ function() {
28985
28985
  };
28986
28986
  _proto.setupShadow = function setupShadow() {
28987
28987
  var context = this.context;
28988
- var _this_textStyle = this.textStyle, outlineColor = _this_textStyle.outlineColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
28989
- var r = outlineColor[0], g = outlineColor[1], b = outlineColor[2], a = outlineColor[3];
28988
+ var _this_textStyle = this.textStyle, shadowColor = _this_textStyle.shadowColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
28989
+ var r = shadowColor[0], g = shadowColor[1], b = shadowColor[2], a = shadowColor[3];
28990
28990
  if (context) {
28991
28991
  context.shadowColor = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
28992
28992
  context.shadowBlur = shadowBlur;
@@ -29211,11 +29211,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29211
29211
  _proto.getLineCount = function getLineCount(text) {
29212
29212
  var context = this.context;
29213
29213
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
29214
- // const fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
29215
29214
  this.maxLineWidth = 0;
29216
29215
  var width = this.textLayout.width + this.textStyle.fontOffset;
29217
29216
  var lineCount = 1;
29218
29217
  var x = 0;
29218
+ var charCountInLine = 0; // 跟踪当前行的字符数
29219
29219
  // 设置 context.font 的字号,确保 measureText 能正确计算字宽
29220
29220
  if (context) {
29221
29221
  context.font = this.getFontDesc(this.textStyle.fontSize);
@@ -29226,14 +29226,19 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29226
29226
  var _context_measureText_width;
29227
29227
  var textMetrics = (_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0;
29228
29228
  // 和浏览器行为保持一致
29229
- x += letterSpace;
29229
+ // 字符间距只应用在字符之间,每行第一个字符不加间距
29230
+ if (charCountInLine > 0) {
29231
+ x += letterSpace;
29232
+ }
29230
29233
  // 处理文本结束行为
29231
29234
  if (overflow === TextOverflow.display) {
29232
29235
  if (str === "\n") {
29233
29236
  lineCount++;
29234
29237
  x = 0;
29238
+ charCountInLine = 0; // 重置行字符计数
29235
29239
  } else {
29236
29240
  x += textMetrics;
29241
+ charCountInLine++;
29237
29242
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
29238
29243
  }
29239
29244
  } else {
@@ -29241,9 +29246,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29241
29246
  lineCount++;
29242
29247
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
29243
29248
  x = 0;
29249
+ charCountInLine = 0; // 重置行字符计数
29244
29250
  }
29245
29251
  if (str !== "\n") {
29246
29252
  x += textMetrics;
29253
+ charCountInLine++;
29247
29254
  }
29248
29255
  }
29249
29256
  }
@@ -29390,7 +29397,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29390
29397
  var str = char[i];
29391
29398
  var textMetrics = context.measureText(str);
29392
29399
  // 和浏览器行为保持一致
29393
- x += layout.letterSpace * fontScale;
29400
+ // 字符间距只应用在字符之间,每行第一个字符不加间距
29401
+ if (charsArray.length > 0) {
29402
+ x += layout.letterSpace * fontScale;
29403
+ }
29394
29404
  if (x + textMetrics.width > baseWidth && i > 0 || str === "\n") {
29395
29405
  charsInfo.push({
29396
29406
  y: y,
@@ -31620,7 +31630,7 @@ function getStandardSpriteContent(sprite, transform) {
31620
31630
  return ret;
31621
31631
  }
31622
31632
 
31623
- var version$1 = "2.8.7";
31633
+ var version$1 = "2.8.8";
31624
31634
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31625
31635
  var standardVersion = /^(\d+)\.(\d+)$/;
31626
31636
  var reverseParticle = false;
@@ -35320,7 +35330,7 @@ registerPlugin("text", TextLoader);
35320
35330
  registerPlugin("sprite", SpriteLoader);
35321
35331
  registerPlugin("particle", ParticleLoader);
35322
35332
  registerPlugin("interact", InteractLoader);
35323
- var version = "2.8.7";
35333
+ var version = "2.8.8";
35324
35334
  logger.info("Core version: " + version + ".");
35325
35335
 
35326
35336
  exports.ActivationMixerPlayable = ActivationMixerPlayable;