diff --git a/lib/Epub/Epub/hyphenation/HyphenationCommon.cpp b/lib/Epub/Epub/hyphenation/HyphenationCommon.cpp index 15791ae0..3765fdc6 100644 --- a/lib/Epub/Epub/hyphenation/HyphenationCommon.cpp +++ b/lib/Epub/Epub/hyphenation/HyphenationCommon.cpp @@ -106,6 +106,7 @@ bool isAsciiDigit(const uint32_t cp) { return cp >= '0' && cp <= '9'; } bool isExplicitHyphen(const uint32_t cp) { switch (cp) { + case '/': case '-': case 0x00AD: // soft hyphen case 0x058A: // Armenian hyphen diff --git a/lib/Epub/Epub/hyphenation/Hyphenator.cpp b/lib/Epub/Epub/hyphenation/Hyphenator.cpp index e485083f..aa558e4e 100644 --- a/lib/Epub/Epub/hyphenation/Hyphenator.cpp +++ b/lib/Epub/Epub/hyphenation/Hyphenator.cpp @@ -35,13 +35,17 @@ size_t byteOffsetForIndex(const std::vector& cps, const size_t in std::vector buildExplicitBreakInfos(const std::vector& cps) { std::vector breaks; - // Scan every codepoint looking for explicit/soft hyphen markers that are surrounded by letters. for (size_t i = 1; i + 1 < cps.size(); ++i) { const uint32_t cp = cps[i].value; - if (!isExplicitHyphen(cp) || !isAlphabetic(cps[i - 1].value) || !isAlphabetic(cps[i + 1].value)) { + if (!isExplicitHyphen(cp)) { + continue; + } + if ((cp == '/' || cp == '-') && cps[i + 1].value == cp) { + continue; + } + if (cp != '/' && cp != '-' && (!isAlphabetic(cps[i - 1].value) || !isAlphabetic(cps[i + 1].value))) { continue; } - // Offset points to the next codepoint so rendering starts after the hyphen marker. breaks.push_back({cps[i + 1].byteOffset, isSoftHyphen(cp)}); }