From 801b563d4cc6c1fcc86ad0c3d02bbc37188fbd78 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 17 Jan 2019 21:35:56 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/TextPage.vue | 3 ++- client/components/Reader/share/BookParser.js | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index c066abde..d896d3eb 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -63,7 +63,8 @@ class TextPage extends Vue { this.parsed.font = this.font; this.parsed.wordWrap = this.wordWrap; this.measureText = (text, style) => {// eslint-disable-line no-unused-vars - this.context.font = this.fontByStyle(style); + if (style) + this.context.font = this.fontByStyle(style); return this.context.measureText(text).width; }; this.parsed.measureText = this.measureText; diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 1d6f7149..eedb4b30 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -396,7 +396,16 @@ export default class BookParser { } } - line.parts.push({style, text: partText}); + if (partText != '') + line.parts.push({style, text: partText}); + + if (line.parts.length) {//корявенько, коррекция при переносе + let t = line.parts[line.parts.length - 1].text; + if (t.trimRight() != t) { + line.parts[line.parts.length - 1].text = t.trimRight(); + prevW -= this.measureText(' '); + } + } line.end = para.offset + ofs; line.width = prevW; line.first = (j == 0); @@ -417,10 +426,18 @@ export default class BookParser { prevW = w; } - line.parts.push({style, text: partText}); + if (partText != '') + line.parts.push({style, text: partText}); partText = ''; } + if (line.parts.length) {//корявенько, коррекция при переносе + let t = line.parts[line.parts.length - 1].text; + if (t.trimRight() != t) { + line.parts[line.parts.length - 1].text = t.trimRight(); + prevW -= this.measureText(' '); + } + } line.end = para.offset + para.length - 1; line.width = prevW; line.first = (j == 0);