Commit e8c3aa8b authored by Chen Jiping's avatar Chen Jiping

fix:修复排版问题

parent 253254ac
...@@ -188,8 +188,8 @@ export class Exercises { ...@@ -188,8 +188,8 @@ export class Exercises {
text.fontName = "GOTHIC"; text.fontName = "GOTHIC";
text.boldFontName = 'GOTHICB'; text.boldFontName = 'GOTHICB';
text.textArr = getTextArr(); text.textArr = getTextArr();
text.disH = 20 * this.scaleX; text.disH = 20;
text.maxWidth = 980 * this.scaleX; text.maxWidth = 980;
text.setScaleXY(this.scaleX); text.setScaleXY(this.scaleX);
text.refreshSize(); text.refreshSize();
......
...@@ -1176,7 +1176,7 @@ export class RichText extends Label { ...@@ -1176,7 +1176,7 @@ export class RichText extends Label {
const getBlank = () => { const getBlank = () => {
let blank = new Text(); let blank = new Text();
blank.val = ' '; blank.val = ' ';
blank.width = this.ctx.measureText(blank.val).width * this.scaleX; blank.width = this.ctx.measureText(blank.val).width;
return blank; return blank;
} }
...@@ -1200,13 +1200,13 @@ export class RichText extends Label { ...@@ -1200,13 +1200,13 @@ export class RichText extends Label {
else { else {
this.ctx.font = `${this.fontSize}px ${this.fontName}`; this.ctx.font = `${this.fontSize}px ${this.fontName}`;
} }
this.textArr[i].width = this.ctx.measureText(c).width * this.scaleX; this.textArr[i].width = this.ctx.measureText(c).width;
tempStr += text.val; tempStr += text.val;
tempArr.push(this.textArr[i]); tempArr.push(this.textArr[i]);
continue continue
} }
if (this.ctx.measureText(temp).width * this.scaleX < w && this.ctx.measureText(temp + (tempStr)).width * this.scaleX <= w) { if (this.ctx.measureText(temp).width < w && this.ctx.measureText(temp + (tempStr)).width <= w) {
temp += ' ' + tempStr; temp += ' ' + tempStr;
tempArr.push(getBlank()); tempArr.push(getBlank());
...@@ -1300,17 +1300,18 @@ export class RichText extends Label { ...@@ -1300,17 +1300,18 @@ export class RichText extends Label {
for (let b = 0; b < row.length; b++) { for (let b = 0; b < row.length; b++) {
let textArr = row[b]; let textArr = row[b];
let temp = "";
for (let i = 0; i < textArr.length; ++i) { for (let i = 0; i < textArr.length; ++i) {
this.ctx.strokeText(textArr[i].val, x, y + (b + 1) * disH); // 每行字体y坐标间隔 temp += textArr[i].val;
x += textArr[i].width;
} }
this.ctx.strokeText(temp, x, y + (b + 1) * disH); // 每行字体y坐标间隔
x = 0; x = 0;
} }
} }
x = 0; x = 0;this.ctx.font = `${this.fontSize}px ${this.boldFontName}`;
// this.ctx.fillStyle = '#ff7600'; // this.ctx.fillStyle = '#ff7600';
for (let b = 0; b < row.length; b++) { for (let b = 0; b < row.length; b++) {
......
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