@galacean/effects-plugin-rich-text 2.8.0-alpha.5 → 2.8.0
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/alipay.js +1 -1
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -1
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +134 -83
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +134 -83
- package/dist/index.mjs.map +1 -1
- package/dist/strategies/rich-text-interfaces.d.ts +1 -0
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -1
- package/dist/weapp.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
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.0
|
|
6
|
+
* Version: v2.8.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -413,8 +413,11 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
413
413
|
this.width = size ? size[0] : 100;
|
|
414
414
|
this.height = size ? size[1] : 100;
|
|
415
415
|
this.wrapEnabled = wrapEnabled;
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
// 兜底,避免 0/负数/NaN/Infinity
|
|
417
|
+
var safeMaxW = Number.isFinite(maxTextWidth) ? maxTextWidth : 0;
|
|
418
|
+
var safeMaxH = Number.isFinite(maxTextHeight) ? maxTextHeight : 0;
|
|
419
|
+
this.maxTextWidth = Math.max(1, safeMaxW);
|
|
420
|
+
this.maxTextHeight = Math.max(1, safeMaxH);
|
|
418
421
|
this.sizeMode = sizeMode;
|
|
419
422
|
}
|
|
420
423
|
var _proto = RichTextLayout.prototype;
|
|
@@ -496,7 +499,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
496
499
|
*/ _proto.getOffsetXRich = function getOffsetXRich(style, maxWidth, contentW) {
|
|
497
500
|
switch(this.textAlign){
|
|
498
501
|
case spec.TextAlignment.left:
|
|
499
|
-
return style.outlineWidth;
|
|
502
|
+
return style.outlineWidth * style.fontScale;
|
|
500
503
|
case spec.TextAlignment.middle:
|
|
501
504
|
return (maxWidth - contentW) / 2;
|
|
502
505
|
case spec.TextAlignment.right:
|
|
@@ -864,14 +867,15 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
864
867
|
var safeDiv = function(a, b) {
|
|
865
868
|
return Math.abs(b) > 1e-5 ? a / b : 1;
|
|
866
869
|
};
|
|
867
|
-
|
|
868
|
-
var
|
|
870
|
+
// 用像素空间计算
|
|
871
|
+
var frameWpx = layout.maxTextWidth * style.fontScale;
|
|
872
|
+
var frameHpx = layout.maxTextHeight * style.fontScale;
|
|
869
873
|
var _sizeResult_contentWidth;
|
|
870
|
-
var
|
|
874
|
+
var contentWpx = Math.max(1, (_sizeResult_contentWidth = sizeResult.contentWidth) != null ? _sizeResult_contentWidth : sizeResult.canvasWidth);
|
|
871
875
|
var _sizeResult_bboxHeight;
|
|
872
|
-
var
|
|
873
|
-
//
|
|
874
|
-
var s = Math.min(1, safeDiv(
|
|
876
|
+
var contentHpx = Math.max(1, (_sizeResult_bboxHeight = sizeResult.bboxHeight) != null ? _sizeResult_bboxHeight : sizeResult.canvasHeight);
|
|
877
|
+
// 只缩小不放大(基于像素空间计算)
|
|
878
|
+
var s = Math.min(1, safeDiv(frameWpx, contentWpx), safeDiv(frameHpx, contentHpx));
|
|
875
879
|
// 浮点精度处理
|
|
876
880
|
if (s > 0.9999) {
|
|
877
881
|
return {
|
|
@@ -951,13 +955,15 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
951
955
|
function RichHorizontalAlignStrategyImpl() {}
|
|
952
956
|
var _proto = RichHorizontalAlignStrategyImpl.prototype;
|
|
953
957
|
_proto.getHorizontalOffsets = function getHorizontalOffsets(lines, sizeResult, overflowResult, layout, style) {
|
|
954
|
-
var
|
|
955
|
-
var
|
|
956
|
-
|
|
958
|
+
var _sizeResult_containerWidth;
|
|
959
|
+
var containerWidthPx = (_sizeResult_containerWidth = sizeResult.containerWidth) != null ? _sizeResult_containerWidth : layout.maxTextWidth * style.fontScale;
|
|
960
|
+
var _sizeResult_baselineCompensationX;
|
|
961
|
+
var compX = (_sizeResult_baselineCompensationX = sizeResult.baselineCompensationX) != null ? _sizeResult_baselineCompensationX : 0;
|
|
962
|
+
// 使用像素单位的容器宽度
|
|
957
963
|
var baseOffsets = lines.map(function(line) {
|
|
958
|
-
return layout.getOffsetXRich(style,
|
|
964
|
+
return layout.getOffsetXRich(style, containerWidthPx, line.width);
|
|
959
965
|
});
|
|
960
|
-
//
|
|
966
|
+
// visible 模式下使用 baseOffset + baselineCompensationX
|
|
961
967
|
var lineOffsets = layout.overflow === spec.TextOverflow.visible ? baseOffsets.map(function(x) {
|
|
962
968
|
return x + compX;
|
|
963
969
|
}) : baseOffsets;
|
|
@@ -975,10 +981,8 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
975
981
|
function RichVerticalAlignStrategyImpl() {}
|
|
976
982
|
var _proto = RichVerticalAlignStrategyImpl.prototype;
|
|
977
983
|
_proto.getVerticalOffsets = function getVerticalOffsets(lines, sizeResult, overflowResult, layout, style, singleLineHeight) {
|
|
978
|
-
var
|
|
979
|
-
|
|
980
|
-
});
|
|
981
|
-
var compY = sizeResult.baselineCompensationY || 0;
|
|
984
|
+
var _sizeResult_baselineCompensationY;
|
|
985
|
+
var compY = (_sizeResult_baselineCompensationY = sizeResult.baselineCompensationY) != null ? _sizeResult_baselineCompensationY : 0;
|
|
982
986
|
var baselineY = 0;
|
|
983
987
|
if (lines.length === 0) {
|
|
984
988
|
return {
|
|
@@ -990,7 +994,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
990
994
|
case spec.TextOverflow.visible:
|
|
991
995
|
{
|
|
992
996
|
// frame-based 计算
|
|
993
|
-
var
|
|
997
|
+
var frameHpx = layout.maxTextHeight * style.fontScale;
|
|
994
998
|
var _sizeResult_bboxTop;
|
|
995
999
|
var bboxTop = (_sizeResult_bboxTop = sizeResult.bboxTop) != null ? _sizeResult_bboxTop : 0;
|
|
996
1000
|
var _sizeResult_bboxHeight, _sizeResult_bboxBottom;
|
|
@@ -1004,10 +1008,10 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
1004
1008
|
baselineYFrame = -bboxTop;
|
|
1005
1009
|
break;
|
|
1006
1010
|
case spec.TextVerticalAlign.middle:
|
|
1007
|
-
baselineYFrame = (
|
|
1011
|
+
baselineYFrame = (frameHpx - bboxHeight) / 2 - bboxTop;
|
|
1008
1012
|
break;
|
|
1009
1013
|
case spec.TextVerticalAlign.bottom:
|
|
1010
|
-
baselineYFrame =
|
|
1014
|
+
baselineYFrame = frameHpx - bboxHeight - bboxTop;
|
|
1011
1015
|
break;
|
|
1012
1016
|
}
|
|
1013
1017
|
baselineY = baselineYFrame + compY; // 关键:叠加"向下移动 E"
|
|
@@ -1015,26 +1019,8 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
1015
1019
|
}
|
|
1016
1020
|
case spec.TextOverflow.clip:
|
|
1017
1021
|
{
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
var _Math;
|
|
1021
|
-
var richSizes = firstLine.richOptions.map(function(o) {
|
|
1022
|
-
return o.fontSize;
|
|
1023
|
-
});
|
|
1024
|
-
var firstMax = (_Math = Math).max.apply(_Math, [].concat(richSizes.length ? richSizes : [
|
|
1025
|
-
style.fontSize
|
|
1026
|
-
]));
|
|
1027
|
-
var fontSizeForOffset = firstMax * style.fontScale * singleLineHeight;
|
|
1028
|
-
baselineY = layout.getOffsetYRich(style, lineHeights, fontSizeForOffset) + compY;
|
|
1029
|
-
} else {
|
|
1030
|
-
baselineY = layout.getOffsetYRich(style, lineHeights, style.fontSize * style.fontScale) + compY;
|
|
1031
|
-
}
|
|
1032
|
-
break;
|
|
1033
|
-
}
|
|
1034
|
-
case spec.TextOverflow.display:
|
|
1035
|
-
{
|
|
1036
|
-
// display 垂直对齐改为基于 bbox,而不是 getOffsetYRich
|
|
1037
|
-
var frameH1 = layout.maxTextHeight;
|
|
1022
|
+
// 让 clip 垂直对齐逻辑与 display 保持一致(基于 bbox 的几何模型)
|
|
1023
|
+
var frameHpx1 = layout.maxTextHeight * style.fontScale;
|
|
1038
1024
|
// 用缩放后的行数据重建 baselines 和 bbox
|
|
1039
1025
|
var baselines = [
|
|
1040
1026
|
0
|
|
@@ -1042,7 +1028,6 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
1042
1028
|
for(var i = 1; i < lines.length; i++){
|
|
1043
1029
|
baselines[i] = baselines[i - 1] + lines[i].lineHeight;
|
|
1044
1030
|
}
|
|
1045
|
-
// 计算 bboxTop / bboxBottom(使用行的测量值 lineAscent/lineDescent)
|
|
1046
1031
|
var bboxTop1 = Infinity;
|
|
1047
1032
|
var bboxBottom1 = -Infinity;
|
|
1048
1033
|
for(var i1 = 0; i1 < lines.length; i1++){
|
|
@@ -1054,26 +1039,64 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
1054
1039
|
bboxBottom1 = Math.max(bboxBottom1, baselines[i1] + desc);
|
|
1055
1040
|
}
|
|
1056
1041
|
var bboxHeight1 = bboxBottom1 - bboxTop1;
|
|
1042
|
+
var baselineClipY = 0;
|
|
1043
|
+
switch(layout.textVerticalAlign){
|
|
1044
|
+
case spec.TextVerticalAlign.top:
|
|
1045
|
+
baselineClipY = -bboxTop1;
|
|
1046
|
+
break;
|
|
1047
|
+
case spec.TextVerticalAlign.middle:
|
|
1048
|
+
baselineClipY = (frameHpx1 - bboxHeight1) / 2 - bboxTop1;
|
|
1049
|
+
break;
|
|
1050
|
+
case spec.TextVerticalAlign.bottom:
|
|
1051
|
+
baselineClipY = frameHpx1 - bboxHeight1 - bboxTop1;
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
1054
|
+
baselineY = baselineClipY + compY;
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
case spec.TextOverflow.display:
|
|
1058
|
+
{
|
|
1059
|
+
// display 垂直对齐改为基于 bbox,而不是 getOffsetYRich
|
|
1060
|
+
var frameHpx2 = layout.maxTextHeight * style.fontScale;
|
|
1061
|
+
// 用缩放后的行数据重建 baselines 和 bbox
|
|
1062
|
+
var baselines1 = [
|
|
1063
|
+
0
|
|
1064
|
+
];
|
|
1065
|
+
for(var i2 = 1; i2 < lines.length; i2++){
|
|
1066
|
+
baselines1[i2] = baselines1[i2 - 1] + lines[i2].lineHeight;
|
|
1067
|
+
}
|
|
1068
|
+
// 计算 bboxTop / bboxBottom(使用行的测量值 lineAscent/lineDescent)
|
|
1069
|
+
var bboxTop2 = Infinity;
|
|
1070
|
+
var bboxBottom2 = -Infinity;
|
|
1071
|
+
for(var i3 = 0; i3 < lines.length; i3++){
|
|
1072
|
+
var _lines_i_lineAscent1;
|
|
1073
|
+
var asc1 = (_lines_i_lineAscent1 = lines[i3].lineAscent) != null ? _lines_i_lineAscent1 : 0;
|
|
1074
|
+
var _lines_i_lineDescent1;
|
|
1075
|
+
var desc1 = (_lines_i_lineDescent1 = lines[i3].lineDescent) != null ? _lines_i_lineDescent1 : 0;
|
|
1076
|
+
bboxTop2 = Math.min(bboxTop2, baselines1[i3] - asc1);
|
|
1077
|
+
bboxBottom2 = Math.max(bboxBottom2, baselines1[i3] + desc1);
|
|
1078
|
+
}
|
|
1079
|
+
var bboxHeight2 = bboxBottom2 - bboxTop2;
|
|
1057
1080
|
// 计算 display 模式的基线
|
|
1058
1081
|
var baselineDisplayY = 0;
|
|
1059
1082
|
switch(layout.textVerticalAlign){
|
|
1060
1083
|
case spec.TextVerticalAlign.top:
|
|
1061
|
-
baselineDisplayY = -
|
|
1084
|
+
baselineDisplayY = -bboxTop2;
|
|
1062
1085
|
break;
|
|
1063
1086
|
case spec.TextVerticalAlign.middle:
|
|
1064
|
-
baselineDisplayY = (
|
|
1087
|
+
baselineDisplayY = (frameHpx2 - bboxHeight2) / 2 - bboxTop2;
|
|
1065
1088
|
break;
|
|
1066
1089
|
case spec.TextVerticalAlign.bottom:
|
|
1067
|
-
baselineDisplayY =
|
|
1090
|
+
baselineDisplayY = frameHpx2 - bboxHeight2 - bboxTop2;
|
|
1068
1091
|
break;
|
|
1069
1092
|
}
|
|
1070
1093
|
// 后续 lineYOffsets 保持按行高累计
|
|
1071
1094
|
var lineYOffsets = [];
|
|
1072
1095
|
var currentY = baselineDisplayY;
|
|
1073
|
-
for(var
|
|
1096
|
+
for(var i4 = 0; i4 < lines.length; i4++){
|
|
1074
1097
|
lineYOffsets.push(currentY);
|
|
1075
|
-
if (
|
|
1076
|
-
currentY += lines[
|
|
1098
|
+
if (i4 < lines.length - 1) {
|
|
1099
|
+
currentY += lines[i4 + 1].lineHeight;
|
|
1077
1100
|
}
|
|
1078
1101
|
}
|
|
1079
1102
|
return {
|
|
@@ -1428,9 +1451,12 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1428
1451
|
// 使用 this.canvasSize 统一设置画布尺寸
|
|
1429
1452
|
assertExist(this.canvasSize);
|
|
1430
1453
|
var _this_canvasSize = this.canvasSize, canvasWidth = _this_canvasSize.x, canvasHeight = _this_canvasSize.y;
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1454
|
+
// 确保canvas宽高至少为1
|
|
1455
|
+
var safeW = Math.max(1, Math.ceil(canvasWidth));
|
|
1456
|
+
var safeH = Math.max(1, Math.ceil(canvasHeight));
|
|
1457
|
+
layout.width = safeW / this.textStyle.fontScale;
|
|
1458
|
+
layout.height = safeH / this.textStyle.fontScale;
|
|
1459
|
+
this.renderToTexture(safeW, safeH, flipY, function(context) {
|
|
1434
1460
|
// 步骤6: 绘制文本
|
|
1435
1461
|
_this.drawTextWithStrategies(context, wrapResult.lines, horizontalAlignResult, TextVerticalAlignResult, overflowResult, _this.textStyle);
|
|
1436
1462
|
}, {
|
|
@@ -1445,12 +1471,15 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1445
1471
|
}
|
|
1446
1472
|
var _this_size = this.size, _this_size_x = _this_size.x, x = _this_size_x === void 0 ? 1 : _this_size_x, _this_size_y = _this_size.y, y = _this_size_y === void 0 ? 1 : _this_size_y;
|
|
1447
1473
|
var layout = this.textLayout;
|
|
1474
|
+
var fontScale = this.textStyle.fontScale || 1;
|
|
1475
|
+
// 防止 frameW / frameH 为 0
|
|
1476
|
+
var frameW = Math.max(1, layout.maxTextWidth || 0);
|
|
1477
|
+
var frameH = Math.max(1, layout.maxTextHeight || 0);
|
|
1448
1478
|
switch(layout.overflow){
|
|
1449
1479
|
case spec.TextOverflow.visible:
|
|
1450
1480
|
{
|
|
1451
|
-
var
|
|
1452
|
-
var
|
|
1453
|
-
var frameH = layout.maxTextHeight;
|
|
1481
|
+
var frameWpx = frameW * fontScale;
|
|
1482
|
+
var frameHpx = frameH * fontScale;
|
|
1454
1483
|
var _sizeResult_bboxTop;
|
|
1455
1484
|
var bboxTop = (_sizeResult_bboxTop = sizeResult.bboxTop) != null ? _sizeResult_bboxTop : 0;
|
|
1456
1485
|
var _sizeResult_bboxHeight, _sizeResult_bboxBottom;
|
|
@@ -1464,17 +1493,17 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1464
1493
|
baselineYFrame = -bboxTop;
|
|
1465
1494
|
break;
|
|
1466
1495
|
case spec.TextVerticalAlign.middle:
|
|
1467
|
-
baselineYFrame = (
|
|
1496
|
+
baselineYFrame = (frameHpx - bboxHeight) / 2 - bboxTop;
|
|
1468
1497
|
break;
|
|
1469
1498
|
case spec.TextVerticalAlign.bottom:
|
|
1470
|
-
baselineYFrame =
|
|
1499
|
+
baselineYFrame = frameHpx - bboxHeight - bboxTop;
|
|
1471
1500
|
break;
|
|
1472
1501
|
}
|
|
1473
1502
|
// 上下溢出检测
|
|
1474
1503
|
var contentTopInFrame = baselineYFrame + bboxTop;
|
|
1475
1504
|
var contentBottomInFrame = baselineYFrame + bboxBottom;
|
|
1476
1505
|
var overflowTop = Math.max(0, -contentTopInFrame);
|
|
1477
|
-
var overflowBottom = Math.max(0, contentBottomInFrame -
|
|
1506
|
+
var overflowBottom = Math.max(0, contentBottomInFrame - frameHpx);
|
|
1478
1507
|
// 垂直扩张
|
|
1479
1508
|
var expandTop = overflowTop;
|
|
1480
1509
|
var expandBottom = overflowBottom;
|
|
@@ -1505,56 +1534,78 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1505
1534
|
var compY = expandTop;
|
|
1506
1535
|
// 水平扩张
|
|
1507
1536
|
var lines = sizeResult.lines || [];
|
|
1537
|
+
// 1. 先按 frameWpx 计算每行的对齐起点(逻辑对齐)
|
|
1508
1538
|
var xOffsetsFrame = lines.map(function(line) {
|
|
1509
|
-
return layout.getOffsetXRich(_this.textStyle,
|
|
1539
|
+
return layout.getOffsetXRich(_this.textStyle, frameWpx, line.width);
|
|
1510
1540
|
});
|
|
1511
|
-
|
|
1512
|
-
var
|
|
1513
|
-
var
|
|
1514
|
-
var
|
|
1515
|
-
|
|
1516
|
-
|
|
1541
|
+
// 2. 用对齐后的偏移 + 行宽算出内容的左右边界
|
|
1542
|
+
var contentMinX = Infinity;
|
|
1543
|
+
var contentMaxX = -Infinity;
|
|
1544
|
+
for(var i = 0; i < lines.length; i++){
|
|
1545
|
+
var _xOffsetsFrame_i;
|
|
1546
|
+
var off = (_xOffsetsFrame_i = xOffsetsFrame[i]) != null ? _xOffsetsFrame_i : 0;
|
|
1547
|
+
var _lines_i_width;
|
|
1548
|
+
var w = (_lines_i_width = lines[i].width) != null ? _lines_i_width : 0; // 像素宽
|
|
1549
|
+
contentMinX = Math.min(contentMinX, off);
|
|
1550
|
+
contentMaxX = Math.max(contentMaxX, off + w);
|
|
1551
|
+
}
|
|
1552
|
+
if (!isFinite(contentMinX)) {
|
|
1553
|
+
contentMinX = 0;
|
|
1554
|
+
}
|
|
1555
|
+
if (!isFinite(contentMaxX)) {
|
|
1556
|
+
contentMaxX = 0;
|
|
1557
|
+
}
|
|
1558
|
+
// 3. 计算内容相对于 frame 的越界量
|
|
1559
|
+
var overflowLeft = Math.max(0, -contentMinX); // 内容左边 < 0
|
|
1560
|
+
var overflowRight = Math.max(0, contentMaxX - frameWpx); // 内容右边 > frameWpx?
|
|
1561
|
+
// 4. 让 canvas 左右都扩张到能容下整个内容 bbox
|
|
1562
|
+
var expandLeft = overflowLeft;
|
|
1563
|
+
var expandRight = overflowRight;
|
|
1564
|
+
// 5. 最终 canvas 宽高
|
|
1565
|
+
var finalWpx = Math.ceil(frameWpx + expandLeft + expandRight);
|
|
1566
|
+
var finalHpx = Math.ceil(frameHpx + expandTop + expandBottom);
|
|
1517
1567
|
// 记录补偿,供垂直对齐策略叠加
|
|
1518
1568
|
sizeResult.baselineCompensationX = expandLeft;
|
|
1519
1569
|
sizeResult.baselineCompensationY = compY;
|
|
1520
|
-
|
|
1521
|
-
sizeResult.
|
|
1522
|
-
|
|
1570
|
+
// containerWidth 用 frameWpx,而不是 finalWpx
|
|
1571
|
+
sizeResult.containerWidth = frameWpx;
|
|
1572
|
+
sizeResult.canvasWidth = finalWpx;
|
|
1573
|
+
sizeResult.canvasHeight = finalHpx;
|
|
1574
|
+
this.canvasSize = new math.Vector2(finalWpx, finalHpx);
|
|
1523
1575
|
var _this_size1;
|
|
1524
1576
|
var _ref = (_this_size1 = this.size) != null ? _this_size1 : this.item.transform.size, _ref_x = _ref.x, x1 = _ref_x === void 0 ? 1 : _ref_x, _ref_y = _ref.y, y1 = _ref_y === void 0 ? 1 : _ref_y;
|
|
1525
|
-
this.item.transform.size.set(x1 *
|
|
1526
|
-
this.size = this.item.transform.size.clone();
|
|
1577
|
+
this.item.transform.size.set(x1 * finalWpx * this.SCALE_FACTOR * this.SCALE_FACTOR, y1 * finalHpx * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1527
1578
|
this.initialized = true;
|
|
1528
1579
|
break;
|
|
1529
1580
|
}
|
|
1530
1581
|
case spec.TextOverflow.clip:
|
|
1531
1582
|
{
|
|
1532
|
-
var
|
|
1533
|
-
var
|
|
1583
|
+
var frameWpx1 = frameW * fontScale;
|
|
1584
|
+
var frameHpx1 = frameH * fontScale;
|
|
1534
1585
|
// 直接使用 frame 尺寸作为画布尺寸
|
|
1535
|
-
sizeResult.canvasWidth =
|
|
1536
|
-
sizeResult.canvasHeight =
|
|
1586
|
+
sizeResult.canvasWidth = frameWpx1;
|
|
1587
|
+
sizeResult.canvasHeight = frameHpx1;
|
|
1537
1588
|
// clip 模式不需要任何补偿
|
|
1538
1589
|
sizeResult.baselineCompensationX = 0;
|
|
1539
1590
|
sizeResult.baselineCompensationY = 0;
|
|
1540
1591
|
// 设置 canvas 和节点变换
|
|
1541
|
-
this.canvasSize = new math.Vector2(
|
|
1592
|
+
this.canvasSize = new math.Vector2(frameWpx1, frameHpx1);
|
|
1542
1593
|
// 把 layout 的尺寸更新为 frame 尺寸
|
|
1543
|
-
layout.width =
|
|
1544
|
-
layout.height =
|
|
1594
|
+
layout.width = frameW;
|
|
1595
|
+
layout.height = frameH;
|
|
1545
1596
|
var _this_size2;
|
|
1546
1597
|
var _ref1 = (_this_size2 = this.size) != null ? _this_size2 : this.item.transform.size, _ref_x1 = _ref1.x, x2 = _ref_x1 === void 0 ? 1 : _ref_x1, _ref_y1 = _ref1.y, y2 = _ref_y1 === void 0 ? 1 : _ref_y1;
|
|
1547
|
-
this.item.transform.size.set(x2 *
|
|
1548
|
-
this.size = this.item.transform.size.clone();
|
|
1598
|
+
this.item.transform.size.set(x2 * frameWpx1 * this.SCALE_FACTOR * this.SCALE_FACTOR, y2 * frameHpx1 * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1549
1599
|
this.initialized = true;
|
|
1550
1600
|
break;
|
|
1551
1601
|
}
|
|
1552
1602
|
case spec.TextOverflow.display:
|
|
1553
1603
|
{
|
|
1554
1604
|
if (!this.initialized) {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
this.
|
|
1605
|
+
var frameWpx2 = frameW * fontScale;
|
|
1606
|
+
var frameHpx2 = frameH * fontScale;
|
|
1607
|
+
this.canvasSize = new math.Vector2(frameWpx2, frameHpx2);
|
|
1608
|
+
this.item.transform.size.set(x * frameWpx2 * this.SCALE_FACTOR * this.SCALE_FACTOR, y * frameHpx2 * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1558
1609
|
this.initialized = true;
|
|
1559
1610
|
}
|
|
1560
1611
|
break;
|
|
@@ -1673,7 +1724,7 @@ applyMixins(RichTextComponent, [
|
|
|
1673
1724
|
|
|
1674
1725
|
/**
|
|
1675
1726
|
* 插件版本号
|
|
1676
|
-
*/ var version = "2.8.0
|
|
1727
|
+
*/ var version = "2.8.0";
|
|
1677
1728
|
registerPlugin("rich-text", RichTextLoader);
|
|
1678
1729
|
logger.info("Plugin rich text version: " + version + ".");
|
|
1679
1730
|
if (version !== EFFECTS.version) {
|