From d9c7964410c28563b135f1c9c42e18d92db02095 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 30 Jul 2024 21:28:27 +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/DrawHelper.js | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/client/components/Reader/TextPage/DrawHelper.js b/client/components/Reader/TextPage/DrawHelper.js index c1b52ed7..9446e967 100644 --- a/client/components/Reader/TextPage/DrawHelper.js +++ b/client/components/Reader/TextPage/DrawHelper.js @@ -44,9 +44,34 @@ export default class DrawHelper { let center = false; let space = 0; let j = 0; - const pad = this.fontSize/2; //формируем строку for (const part of line.parts) { + let tOpen = ''; + tOpen += (part.style.bold ? '' : ''); + tOpen += (part.style.italic ? '' : ''); + tOpen += (part.style.sup ? '' : ''); + tOpen += (part.style.sub ? '' : ''); + if (part.style.note) { + const t = part.text; + const m = this.measureTextMetrics(t, part.style); + const d = this.fontSize - 1.1*m.fontBoundingBoxAscent; + const w = m.width; + const size = (this.fontSize > 18 ? this.fontSize : 18); + const pad = size/2; + const btnW = (w >= size ? w : size) + pad*2; + + tOpen += `` + + ``; + } + let tClose = ''; + tClose += (part.style.note ? '' : ''); + tClose += (part.style.sub ? '' : ''); + tClose += (part.style.sup ? '' : ''); + tClose += (part.style.italic ? '' : ''); + tClose += (part.style.bold ? '' : ''); + let text = ''; if (lineIndex == 0 && this.searching) { for (let k = 0; k < part.text.length; k++) { @@ -59,29 +84,6 @@ export default class DrawHelper { if (text && text.trim() == '') text = `${text}`; - let tOpen = ''; - tOpen += (part.style.bold ? '' : ''); - tOpen += (part.style.italic ? '' : ''); - tOpen += (part.style.sup ? '' : ''); - tOpen += (part.style.sub ? '' : ''); - if (part.style.note) { - const m = this.measureTextMetrics(text, part.style); - const d = this.fontSize - 1.1*m.fontBoundingBoxAscent; - const w = m.width; - const btnW = (w >= this.fontSize ? w : this.fontSize) + pad*2; - - tOpen += `` + - ``; - } - let tClose = ''; - tClose += (part.style.note ? '' : ''); - tClose += (part.style.sub ? '' : ''); - tClose += (part.style.sup ? '' : ''); - tClose += (part.style.italic ? '' : ''); - tClose += (part.style.bold ? '' : ''); - lineText += `${tOpen}${text}${tClose}`; center = center || part.style.center;