diff --git a/lib/Epub/Epub/ParsedText.cpp b/lib/Epub/Epub/ParsedText.cpp index 9934b44f..81d688ec 100644 --- a/lib/Epub/Epub/ParsedText.cpp +++ b/lib/Epub/Epub/ParsedText.cpp @@ -112,10 +112,6 @@ std::vector ParsedText::computeLineBreaks(const GfxRenderer& renderer, c // Ensure any word that would overflow even as the first entry on a line is split using fallback hyphenation. for (size_t i = 0; i < wordWidths.size(); ++i) { while (wordWidths[i] > pageWidth) { - // Try language-aware hyphenation first; only fall back to heuristics when no dictionary break fits. - if (hyphenateWordAtIndex(i, pageWidth, renderer, fontId, wordWidths, /*allowFallbackBreaks=*/false)) { - continue; - } if (!hyphenateWordAtIndex(i, pageWidth, renderer, fontId, wordWidths, /*allowFallbackBreaks=*/true)) { break; } @@ -279,10 +275,7 @@ bool ParsedText::hyphenateWordAtIndex(const size_t wordIndex, const int availabl const auto style = *styleIt; // Collect candidate breakpoints (byte offsets and hyphen requirements). - auto breakInfos = Hyphenator::breakOffsets(word, /*allowFallback=*/false); - if (breakInfos.empty() && allowFallbackBreaks) { - breakInfos = Hyphenator::breakOffsets(word, /*allowFallback=*/true); - } + auto breakInfos = Hyphenator::breakOffsets(word, allowFallbackBreaks); if (breakInfos.empty()) { return false; } diff --git a/lib/Epub/Epub/hyphenation/Hyphenator.cpp b/lib/Epub/Epub/hyphenation/Hyphenator.cpp index 5ad2bb85..0e151be3 100644 --- a/lib/Epub/Epub/hyphenation/Hyphenator.cpp +++ b/lib/Epub/Epub/hyphenation/Hyphenator.cpp @@ -78,14 +78,11 @@ std::vector Hyphenator::breakOffsets(const std::string& w indexes = hyphenator->breakIndexes(cps); } - // Only add fallback breaks if needed and deduplicate if both language and fallback breaks exist. - if (includeFallback) { + // Only add fallback breaks if needed + if (includeFallback && indexes.empty()) { for (size_t idx = minPrefix; idx + minSuffix <= cps.size(); ++idx) { indexes.push_back(idx); } - // Only deduplicate if we have both language-specific and fallback breaks. - std::sort(indexes.begin(), indexes.end()); - indexes.erase(std::unique(indexes.begin(), indexes.end()), indexes.end()); } if (indexes.empty()) {