Commit 4ce59702 authored by limingzhe's avatar limingzhe

fix: 换行

parent 7f8fa9b6
...@@ -838,7 +838,6 @@ export class RichTextOld extends Label { ...@@ -838,7 +838,6 @@ export class RichTextOld extends Label {
export class RichText extends Label { export class RichText extends Label {
...@@ -870,10 +869,6 @@ export class RichText extends Label { ...@@ -870,10 +869,6 @@ export class RichText extends Label {
getSubTextRect(subText, targetIndex=0) { getSubTextRect(subText, targetIndex=0) {
this.isShowWordBg = true;
this.update();
const tmpLabel = new RichText(); const tmpLabel = new RichText();
tmpLabel.fontSize = this.fontSize; tmpLabel.fontSize = this.fontSize;
tmpLabel.fontName = this.fontName; tmpLabel.fontName = this.fontName;
...@@ -882,20 +877,18 @@ export class RichText extends Label { ...@@ -882,20 +877,18 @@ export class RichText extends Label {
tmpLabel.fontWeight = this.fontWeight; tmpLabel.fontWeight = this.fontWeight;
tmpLabel.width = this.width; tmpLabel.width = this.width;
tmpLabel.height = this.height; tmpLabel.height = this.height;
console.log('subText: ', subText);
console.log('this.text: ', this.text); // console.log('subText: ', subText);
// const indexArr = searchSubStr(this.text, subText); // const indexArr = searchSubStr(this.text, subText);
// console.log('indexArr: ', indexArr); // console.log('indexArr: ', indexArr);
// const index = indexArr[targetIndex]; // const index = indexArr[targetIndex];
const index = this.text.indexOf(subText, targetIndex); const index = this.text.indexOf(subText, targetIndex);
console.log('index: ', index);
if (index == -1) { if (!index) {
return; return;
} }
console.log('this.wordBgData: ', this.wordBgData);
// const index = this.text.indexOf(subText); // const index = this.text.indexOf(subText);
// console.log('!!!index: ', index); // console.log('!!!index: ', index);
...@@ -907,6 +900,20 @@ export class RichText extends Label { ...@@ -907,6 +900,20 @@ export class RichText extends Label {
return data; return data;
tmpLabel.text = this.text.substring(0, index);
tmpLabel.refreshSize();
const x = tmpLabel.width;
tmpLabel.text = subText;
tmpLabel.refreshSize();
const width = tmpLabel.width;
const y = this.fontSize / 2;
const height = this.fontSize;
return {x, y, width, height}
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment