fix: Hanging indent causes overlapping words (#2324)

This commit is contained in:
Zach Nelson
2026-06-11 18:23:49 +03:00
committed by GitHub
parent 9202522a39
commit f2e3d117dc
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -799,7 +799,7 @@ void ParsedText::extractLine(const size_t breakIndex, const int pageWidth, const
}
for (size_t wordIdx = 0; wordIdx < reorderedWidthsScratch.size(); wordIdx++) {
lineXPos.push_back(static_cast<int16_t>(xpos < 0 ? 0 : xpos));
lineXPos.push_back(static_cast<int16_t>(xpos));
xpos += reorderedWidthsScratch[wordIdx];
const bool nextIsContinuation =
@@ -830,7 +830,7 @@ void ParsedText::extractLine(const size_t breakIndex, const int pageWidth, const
// Standard LTR/RTL positioning loop when no visual reordering is needed
if (blockStyle.isRtl) {
// RTL: position words from right to left
auto xpos = static_cast<int>(effectivePageWidth);
int xpos = effectivePageWidth;
if (effectiveAlignment == CssTextAlign::Left) {
// Explicit left alignment in RTL context
xpos = lineWordWidthSum + totalNaturalGaps;
@@ -841,7 +841,7 @@ void ParsedText::extractLine(const size_t breakIndex, const int pageWidth, const
for (size_t wordIdx = 0; wordIdx < lineWordCount; wordIdx++) {
xpos -= wordWidths[lastBreakAt + wordIdx];
lineXPos.push_back(static_cast<int16_t>(xpos < 0 ? 0 : xpos));
lineXPos.push_back(static_cast<int16_t>(xpos));
const bool nextIsContinuation = wordIdx + 1 < lineWordCount && continuesVec[lastBreakAt + wordIdx + 1];
if (nextIsContinuation) {
@@ -867,7 +867,7 @@ void ParsedText::extractLine(const size_t breakIndex, const int pageWidth, const
}
} else {
// LTR: position words from left to right
auto xpos = static_cast<int16_t>(firstLineIndent);
int xpos = firstLineIndent;
if (effectiveAlignment == CssTextAlign::Right) {
xpos = effectivePageWidth - lineWordWidthSum - totalNaturalGaps;
} else if (effectiveAlignment == CssTextAlign::Center) {
@@ -875,7 +875,7 @@ void ParsedText::extractLine(const size_t breakIndex, const int pageWidth, const
}
for (size_t wordIdx = 0; wordIdx < lineWordCount; wordIdx++) {
lineXPos.push_back(static_cast<int16_t>(xpos < 0 ? 0 : xpos));
lineXPos.push_back(static_cast<int16_t>(xpos));
const bool nextIsContinuation = wordIdx + 1 < lineWordCount && continuesVec[lastBreakAt + wordIdx + 1];
if (nextIsContinuation) {
+1 -1
View File
@@ -10,7 +10,7 @@
#include "parsers/ChapterHtmlSlimParser.h"
namespace {
constexpr uint8_t SECTION_FILE_VERSION = 25;
constexpr uint8_t SECTION_FILE_VERSION = 26;
constexpr uint32_t HEADER_SIZE = sizeof(uint8_t) + sizeof(int) + sizeof(float) + sizeof(bool) + sizeof(uint8_t) +
sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(bool) + sizeof(bool) +
sizeof(uint8_t) + sizeof(bool) + sizeof(uint32_t) + sizeof(uint32_t) +