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.
|
||||
applyParagraphIndent();
|
||||
if (bionicReadingEnabled) {
|
||||
applyBionicReadingTransform();
|
||||
// Skip on continuation flushes: the words are mid-paragraph and have
|
||||
// already been transformed by the initial layoutAndExtractLines call.
|
||||
if (!isContinuation_) {
|
||||
applyParagraphIndent();
|
||||
if (bionicReadingEnabled) {
|
||||
applyBionicReadingTransform();
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure SD card font glyph metrics are loaded before measuring word widths.
|
||||
|
||||
@@ -27,6 +27,7 @@ class ParsedText {
|
||||
bool extraParagraphSpacing;
|
||||
bool hyphenationEnabled;
|
||||
bool bionicReadingEnabled;
|
||||
bool isContinuation_ = false; ///< true after an intermediate flush; suppresses re-applying indent/transforms
|
||||
|
||||
void applyParagraphIndent();
|
||||
void applyBionicReadingTransform();
|
||||
@@ -74,6 +75,7 @@ class ParsedText {
|
||||
BlockStyle& getBlockStyle() { return blockStyle; }
|
||||
size_t size() const { return words.size(); }
|
||||
bool isEmpty() const { return words.empty(); }
|
||||
bool isContinuation() const { return isContinuation_; }
|
||||
void layoutAndExtractLines(
|
||||
const GfxRenderer& renderer, int fontId, uint16_t viewportWidth,
|
||||
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;
|
||||
|
||||
// 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();
|
||||
if (blockStyle.marginTop > 0) {
|
||||
currentPageNextY += blockStyle.marginTop;
|
||||
}
|
||||
if (blockStyle.paddingTop > 0) {
|
||||
currentPageNextY += blockStyle.paddingTop;
|
||||
if (!currentTextBlock->isContinuation()) {
|
||||
if (blockStyle.marginTop > 0) {
|
||||
currentPageNextY += blockStyle.marginTop;
|
||||
}
|
||||
if (blockStyle.paddingTop > 0) {
|
||||
currentPageNextY += blockStyle.paddingTop;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate effective width accounting for horizontal margins/padding
|
||||
|
||||
Reference in New Issue
Block a user