@galacean/effects-plugin-rich-text 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 player rich text plugin
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';
@@ -532,6 +532,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
532
532
  /**
533
533
  * 设置文本框尺寸
534
534
  * - 不包含 fontScale 缩放
535
+ * @deprecated use maxTextWidth / maxTextHeight instead
535
536
  */ _proto.setSize = function setSize(width, height) {
536
537
  this.width = width;
537
538
  this.height = height;
@@ -618,11 +619,12 @@ var RichTextLayout = /*#__PURE__*/ function() {
618
619
  */ var RichWrapDisabledStrategy = /*#__PURE__*/ function() {
619
620
  function RichWrapDisabledStrategy() {}
620
621
  var _proto = RichWrapDisabledStrategy.prototype;
621
- _proto.computeLines = function computeLines(processedOptions, context, style, layout, singleLineHeight, fontScale, letterSpace, scaleFactor) {
622
+ _proto.computeLines = function computeLines(processedOptions, context, style, layout, singleLineHeight, fontScale, letterSpace) {
622
623
  var _this = this;
623
624
  var lines = [];
624
625
  var baselines = [];
625
626
  var gapPx = (layout.lineHeight || 0) * fontScale;
627
+ var scaleFactor = 1 / 10; // 1/10px, 后面 context.font 设置的字号为10px
626
628
  var currentLine = this.createNewLine();
627
629
  var maxLineWidth = 0;
628
630
  var totalHeight = 0;
@@ -735,11 +737,12 @@ var RichTextLayout = /*#__PURE__*/ function() {
735
737
  */ var RichWrapEnabledStrategy = /*#__PURE__*/ function() {
736
738
  function RichWrapEnabledStrategy() {}
737
739
  var _proto = RichWrapEnabledStrategy.prototype;
738
- _proto.computeLines = function computeLines(processedOptions, context, style, layout, singleLineHeight, fontScale, letterSpace, scaleFactor) {
740
+ _proto.computeLines = function computeLines(processedOptions, context, style, layout, singleLineHeight, fontScale, letterSpace) {
739
741
  var _this = this;
740
742
  var lines = [];
741
743
  var baselines = [];
742
744
  var gapPx = (layout.lineHeight || 0) * fontScale;
745
+ var scaleFactor = 1 / 10; // 1/10px, 后面 context.font 设置的字号为10px
743
746
  var currentLine = this.createNewLine();
744
747
  var maxLineWidth = 0;
745
748
  var totalHeight = 0;
@@ -1229,7 +1232,7 @@ exports.RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1229
1232
  this.textLayout.textVerticalAlign = EFFECTS.spec.TextVerticalAlign.middle;
1230
1233
  }
1231
1234
  this.updateStrategies();
1232
- this.renderText(options);
1235
+ this.updateTexture();
1233
1236
  // 设置默认颜色(math.Color)
1234
1237
  this.material.setColor("_Color", new EFFECTS.math.Color(1, 1, 1, 1));
1235
1238
  };
@@ -1289,13 +1292,6 @@ exports.RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1289
1292
  this.updateStrategies();
1290
1293
  this.isDirty = true;
1291
1294
  };
1292
- _proto.renderText = function renderText(options) {
1293
- var size = options.size;
1294
- if (size) {
1295
- this.canvasSize = new EFFECTS.math.Vector2(size[0], size[1]);
1296
- }
1297
- this.updateTexture();
1298
- };
1299
1295
  /**
1300
1296
  * 更新文本
1301
1297
  * @returns
@@ -1455,7 +1451,7 @@ exports.RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1455
1451
  return;
1456
1452
  }
1457
1453
  // 步骤1: 换行策略计算行信息
1458
- var wrapResult = this.richWrapStrategy.computeLines(this.processedTextOptions, context, this.textStyle, layout, this.singleLineHeight, this.textStyle.fontScale, letterSpace, this.SCALE_FACTOR);
1454
+ var wrapResult = this.richWrapStrategy.computeLines(this.processedTextOptions, context, this.textStyle, layout, this.singleLineHeight, this.textStyle.fontScale, letterSpace);
1459
1455
  if (wrapResult.lines.length === 0 || wrapResult.maxLineWidth === 0 || wrapResult.totalHeight === 0) {
1460
1456
  this.isDirty = false;
1461
1457
  return;
@@ -1747,7 +1743,7 @@ EFFECTS.applyMixins(exports.RichTextComponent, [
1747
1743
 
1748
1744
  /**
1749
1745
  * 插件版本号
1750
- */ var version = "2.8.7";
1746
+ */ var version = "2.8.8";
1751
1747
  EFFECTS.registerPlugin("rich-text", RichTextLoader);
1752
1748
  EFFECTS.logger.info("Plugin rich text version: " + version + ".");
1753
1749
  if (version !== EFFECTS__namespace.version) {