Explorar el Código

Поправки багов

Book Pauk hace 6 años
padre
commit
801b563d4c

+ 2 - 1
client/components/Reader/TextPage/TextPage.vue

@@ -63,7 +63,8 @@ class TextPage extends Vue {
             this.parsed.font = this.font;
             this.parsed.font = this.font;
             this.parsed.wordWrap = this.wordWrap;
             this.parsed.wordWrap = this.wordWrap;
             this.measureText = (text, style) => {// eslint-disable-line no-unused-vars
             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;
                 return this.context.measureText(text).width;
             };
             };
             this.parsed.measureText = this.measureText;
             this.parsed.measureText = this.measureText;

+ 19 - 2
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.end = para.offset + ofs;
                     line.width = prevW;
                     line.width = prevW;
                     line.first = (j == 0);
                     line.first = (j == 0);
@@ -417,10 +426,18 @@ export default class BookParser {
                 prevW = w;
                 prevW = w;
             }
             }
 
 
-            line.parts.push({style, text: partText});
+            if (partText != '')
+                line.parts.push({style, text: partText});
             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.end = para.offset + para.length - 1;
         line.width = prevW;
         line.width = prevW;
         line.first = (j == 0);
         line.first = (j == 0);