When a large paragraph is split across blocks, don't treat the continuation as a new paragraph
This commit is contained in:
@@ -215,9 +215,13 @@ void ParsedText::layoutAndExtractLines(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply fixed transforms before any per-line layout work.
|
// Apply fixed transforms before any per-line layout work.
|
||||||
applyParagraphIndent();
|
// Skip on continuation flushes: the words are mid-paragraph and have
|
||||||
if (bionicReadingEnabled) {
|
// already been transformed by the initial layoutAndExtractLines call.
|
||||||
applyBionicReadingTransform();
|
if (!isContinuation_) {
|
||||||
|
applyParagraphIndent();
|
||||||
|
if (bionicReadingEnabled) {
|
||||||
|
applyBionicReadingTransform();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure SD card font glyph metrics are loaded before measuring word widths.
|
// Ensure SD card font glyph metrics are loaded before measuring word widths.
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class ParsedText {
|
|||||||
bool extraParagraphSpacing;
|
bool extraParagraphSpacing;
|
||||||
bool hyphenationEnabled;
|
bool hyphenationEnabled;
|
||||||
bool bionicReadingEnabled;
|
bool bionicReadingEnabled;
|
||||||
|
bool isContinuation_ = false; ///< true after an intermediate flush; suppresses re-applying indent/transforms
|
||||||
|
|
||||||
void applyParagraphIndent();
|
void applyParagraphIndent();
|
||||||
void applyBionicReadingTransform();
|
void applyBionicReadingTransform();
|
||||||
@@ -74,6 +75,7 @@ class ParsedText {
|
|||||||
BlockStyle& getBlockStyle() { return blockStyle; }
|
BlockStyle& getBlockStyle() { return blockStyle; }
|
||||||
size_t size() const { return words.size(); }
|
size_t size() const { return words.size(); }
|
||||||
bool isEmpty() const { return words.empty(); }
|
bool isEmpty() const { return words.empty(); }
|
||||||
|
bool isContinuation() const { return isContinuation_; }
|
||||||
void layoutAndExtractLines(
|
void layoutAndExtractLines(
|
||||||
const GfxRenderer& renderer, int fontId, uint16_t viewportWidth,
|
const GfxRenderer& renderer, int fontId, uint16_t viewportWidth,
|
||||||
const std::function<LineProcessResult(std::shared_ptr<TextBlock>, bool, bool)>& processLine,
|
const std::function<LineProcessResult(std::shared_ptr<TextBlock>, bool, bool)>& processLine,
|
||||||
|
|||||||
@@ -1592,13 +1592,17 @@ void ChapterHtmlSlimParser::makePages() {
|
|||||||
|
|
||||||
const int lineHeight = renderer.getLineHeight(fontId) * lineCompression;
|
const int lineHeight = renderer.getLineHeight(fontId) * lineCompression;
|
||||||
|
|
||||||
// Apply top spacing before the paragraph (stored in pixels)
|
// Apply top spacing before the paragraph — skip for continuation fragments
|
||||||
|
// (words left over after an intermediate flush): the top margin was already
|
||||||
|
// applied before the first set of lines from this logical paragraph.
|
||||||
const BlockStyle& blockStyle = currentTextBlock->getBlockStyle();
|
const BlockStyle& blockStyle = currentTextBlock->getBlockStyle();
|
||||||
if (blockStyle.marginTop > 0) {
|
if (!currentTextBlock->isContinuation()) {
|
||||||
currentPageNextY += blockStyle.marginTop;
|
if (blockStyle.marginTop > 0) {
|
||||||
}
|
currentPageNextY += blockStyle.marginTop;
|
||||||
if (blockStyle.paddingTop > 0) {
|
}
|
||||||
currentPageNextY += blockStyle.paddingTop;
|
if (blockStyle.paddingTop > 0) {
|
||||||
|
currentPageNextY += blockStyle.paddingTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate effective width accounting for horizontal margins/padding
|
// Calculate effective width accounting for horizontal margins/padding
|
||||||
|
|||||||
Reference in New Issue
Block a user