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 += `` +
+ `${text}`;
+ }
+ 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}`;