Улучшена загрузка внешних шрифтов
This commit is contained in:
@@ -247,6 +247,9 @@ class TextPage extends Vue {
|
|||||||
this.parsed.imageHeightLines = this.imageHeightLines;
|
this.parsed.imageHeightLines = this.imageHeightLines;
|
||||||
this.parsed.imageFitWidth = this.imageFitWidth;
|
this.parsed.imageFitWidth = this.imageFitWidth;
|
||||||
this.parsed.compactTextPerc = this.compactTextPerc;
|
this.parsed.compactTextPerc = this.compactTextPerc;
|
||||||
|
|
||||||
|
this.parsed.testText = 'Это тестовый текст. Его ширина выдается системой неверно некоторое время.';
|
||||||
|
this.parsed.testWidth = this.drawHelper.measureText(this.parsed.testText, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
//scrolling page
|
//scrolling page
|
||||||
@@ -335,11 +338,15 @@ class TextPage extends Vue {
|
|||||||
// ширина шрифта некоторое время выдается неверно, поэтому
|
// ширина шрифта некоторое время выдается неверно, поэтому
|
||||||
if (!omitLoadFonts) {
|
if (!omitLoadFonts) {
|
||||||
const parsed = this.parsed;
|
const parsed = this.parsed;
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
const t = this.parsed.testText;
|
||||||
|
while (i++ < 50 && this.parsed === parsed && this.drawHelper.measureText(t, {}) === this.parsed.testWidth)
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
|
|
||||||
if (this.parsed === parsed) {
|
if (this.parsed === parsed) {
|
||||||
parsed.force = true;
|
this.parsed.testWidth = this.drawHelper.measureText(t, {});
|
||||||
this.draw();
|
this.draw();
|
||||||
parsed.force = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -605,6 +605,7 @@ export default class BookParser {
|
|||||||
|
|
||||||
if (!this.force &&
|
if (!this.force &&
|
||||||
para.parsed &&
|
para.parsed &&
|
||||||
|
para.parsed.testWidth === this.testWidth &&
|
||||||
para.parsed.w === this.w &&
|
para.parsed.w === this.w &&
|
||||||
para.parsed.p === this.p &&
|
para.parsed.p === this.p &&
|
||||||
para.parsed.wordWrap === this.wordWrap &&
|
para.parsed.wordWrap === this.wordWrap &&
|
||||||
@@ -620,6 +621,7 @@ export default class BookParser {
|
|||||||
return para.parsed;
|
return para.parsed;
|
||||||
|
|
||||||
const parsed = {
|
const parsed = {
|
||||||
|
testWidth: this.testWidth,
|
||||||
w: this.w,
|
w: this.w,
|
||||||
p: this.p,
|
p: this.p,
|
||||||
wordWrap: this.wordWrap,
|
wordWrap: this.wordWrap,
|
||||||
|
|||||||
Reference in New Issue
Block a user