|
@@ -620,7 +620,8 @@ export default class BookParser {
|
|
para.parsed.addEmptyParagraphs === this.addEmptyParagraphs &&
|
|
para.parsed.addEmptyParagraphs === this.addEmptyParagraphs &&
|
|
para.parsed.showImages === this.showImages &&
|
|
para.parsed.showImages === this.showImages &&
|
|
para.parsed.imageHeightLines === this.imageHeightLines &&
|
|
para.parsed.imageHeightLines === this.imageHeightLines &&
|
|
- para.parsed.imageFitWidth === this.imageFitWidth
|
|
|
|
|
|
+ para.parsed.imageFitWidth === this.imageFitWidth &&
|
|
|
|
+ para.parsed.compactTextPerc === this.compactTextPerc
|
|
)
|
|
)
|
|
return para.parsed;
|
|
return para.parsed;
|
|
|
|
|
|
@@ -635,6 +636,7 @@ export default class BookParser {
|
|
showImages: this.showImages,
|
|
showImages: this.showImages,
|
|
imageHeightLines: this.imageHeightLines,
|
|
imageHeightLines: this.imageHeightLines,
|
|
imageFitWidth: this.imageFitWidth,
|
|
imageFitWidth: this.imageFitWidth,
|
|
|
|
+ compactTextPerc: this.compactTextPerc,
|
|
visible: !(
|
|
visible: !(
|
|
(this.cutEmptyParagraphs && para.cut) ||
|
|
(this.cutEmptyParagraphs && para.cut) ||
|
|
(para.addIndex > this.addEmptyParagraphs)
|
|
(para.addIndex > this.addEmptyParagraphs)
|
|
@@ -665,6 +667,7 @@ export default class BookParser {
|
|
let style = {};
|
|
let style = {};
|
|
let ofs = 0;//смещение от начала параграфа para.offset
|
|
let ofs = 0;//смещение от начала параграфа para.offset
|
|
let imgW = 0;
|
|
let imgW = 0;
|
|
|
|
+ const compactWidth = this.measureText('W', {})*this.compactTextPerc/100;
|
|
// тут начинается самый замес, перенос по слогам и стилизация, а также изображения
|
|
// тут начинается самый замес, перенос по слогам и стилизация, а также изображения
|
|
for (const part of parts) {
|
|
for (const part of parts) {
|
|
style = part.style;
|
|
style = part.style;
|
|
@@ -749,7 +752,7 @@ export default class BookParser {
|
|
p = (style.space ? p + parsed.p*style.space : p);
|
|
p = (style.space ? p + parsed.p*style.space : p);
|
|
let w = this.measureText(str, style) + p;
|
|
let w = this.measureText(str, style) + p;
|
|
let wordTail = word;
|
|
let wordTail = word;
|
|
- if (w > parsed.w && prevStr != '') {
|
|
|
|
|
|
+ if (w > parsed.w + compactWidth && prevStr != '') {
|
|
if (parsed.wordWrap) {//по слогам
|
|
if (parsed.wordWrap) {//по слогам
|
|
let slogi = this.splitToSlogi(word);
|
|
let slogi = this.splitToSlogi(word);
|
|
|
|
|
|
@@ -762,7 +765,7 @@ export default class BookParser {
|
|
for (let k = 0; k < slogiLen - 1; k++) {
|
|
for (let k = 0; k < slogiLen - 1; k++) {
|
|
let slog = slogi[0];
|
|
let slog = slogi[0];
|
|
let ww = this.measureText(s + slog + (slog[slog.length - 1] == '-' ? '' : '-'), style) + p;
|
|
let ww = this.measureText(s + slog + (slog[slog.length - 1] == '-' ? '' : '-'), style) + p;
|
|
- if (ww <= parsed.w) {
|
|
|
|
|
|
+ if (ww <= parsed.w + compactWidth) {
|
|
s += slog;
|
|
s += slog;
|
|
ss += slog;
|
|
ss += slog;
|
|
} else
|
|
} else
|