From ece17dc0dd46eea5e629e4803bfc6ea4cab1d6f7 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 30 Jul 2024 18:23:52 +0700 Subject: [PATCH 1/9] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BD=D0=BE=D1=81=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/DrawHelper.js | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/client/components/Reader/TextPage/DrawHelper.js b/client/components/Reader/TextPage/DrawHelper.js index f3bf9e77..df414c01 100644 --- a/client/components/Reader/TextPage/DrawHelper.js +++ b/client/components/Reader/TextPage/DrawHelper.js @@ -14,6 +14,11 @@ export default class DrawHelper { return this.context.measureText(text).width; } + measureTextMetrics(text, style) {// eslint-disable-line no-unused-vars + this.context.font = this.fontByStyle(style); + return this.context.measureText(text); + } + measureTextFont(text, font) {// eslint-disable-line no-unused-vars this.context.font = font; return this.context.measureText(text).width; @@ -42,22 +47,6 @@ export default class DrawHelper { 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 ? '' : ''); - tOpen += (part.style.note ? `` + - `__TEXT` : ''); - 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++) { @@ -70,8 +59,28 @@ export default class DrawHelper { if (text && text.trim() == '') text = `${text}`; - if (part.style.note) - tOpen = tOpen.replace('__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}`; From 110952b4c4bf3358c7db57f391d790d901b0c9da Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 30 Jul 2024 18:41:21 +0700 Subject: [PATCH 2/9] =?UTF-8?q?=D0=9A=20=D0=BF=D1=80=D0=B5=D0=B4=D1=8B?= =?UTF-8?q?=D0=B4=D1=83=D1=89=D0=B5=D0=BC=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/TextPage/DrawHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/Reader/TextPage/DrawHelper.js b/client/components/Reader/TextPage/DrawHelper.js index df414c01..c1b52ed7 100644 --- a/client/components/Reader/TextPage/DrawHelper.js +++ b/client/components/Reader/TextPage/DrawHelper.js @@ -72,7 +72,7 @@ export default class DrawHelper { tOpen += `` + ``; } let tClose = ''; From d9c7964410c28563b135f1c9c42e18d92db02095 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 30 Jul 2024 21:28:27 +0700 Subject: [PATCH 3/9] =?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 | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 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,36 +44,26 @@ 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 text = ''; - if (lineIndex == 0 && this.searching) { - for (let k = 0; k < part.text.length; k++) { - text += (sel.has(j) ? `${part.text[k]}` : part.text[k]); - j++; - } - } else - text = part.text; - - 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 t = part.text; + const m = this.measureTextMetrics(t, part.style); const d = this.fontSize - 1.1*m.fontBoundingBoxAscent; const w = m.width; - const btnW = (w >= this.fontSize ? w : this.fontSize) + pad*2; + const size = (this.fontSize > 18 ? this.fontSize : 18); + const pad = size/2; + const btnW = (w >= size ? w : size) + pad*2; tOpen += `` + ``; + `height: ${this.fontSize + pad*2}px; padding: ${pad}px; left: -${(btnW - w)/2 - pad*0.05}px; top: -${pad + d}px; width: ${btnW}px; border-radius: ${size}px;" ` + + `onclick="onNoteClickLiberama('${part.style.note.id}', ${part.style.note.orig ? 1 : 0})">`; } let tClose = ''; tClose += (part.style.note ? '' : ''); @@ -82,6 +72,18 @@ export default class DrawHelper { tClose += (part.style.italic ? '' : ''); tClose += (part.style.bold ? '' : ''); + let text = ''; + if (lineIndex == 0 && this.searching) { + for (let k = 0; k < part.text.length; k++) { + text += (sel.has(j) ? `${part.text[k]}` : part.text[k]); + j++; + } + } else + text = part.text; + + if (text && text.trim() == '') + text = `${text}`; + lineText += `${tOpen}${text}${tClose}`; center = center || part.style.center; From 5160c5fb753766305ba1c759714f379fc8d16b1f Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 30 Jul 2024 21:29:02 +0700 Subject: [PATCH 4/9] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/TextPage/TextPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index bc890feb..47cd9711 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -49,7 +49,7 @@