diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index 11b39f4d..7abc5617 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -1050,13 +1050,15 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char* } } } else if (strcmp(name, "hr") == 0) { - if (self->partWordBufferIndex > 0) self->flushPartWordBuffer(); + if (self->partWordBufferIndex > 0) { + if (!self->flushPartWordBuffer()) return; + } self->makePages(); if (!self->currentPage) { self->currentPage.reset(new Page()); self->currentPageNextY = 0; } - const int lineHeight = self->renderer.getLineHeight(self->fontId) * self->lineCompression; + const int lineHeight = static_cast(self->renderer.getLineHeight(self->fontId) * self->lineCompression + 0.5f); const int16_t marginV = static_cast(lineHeight / 2); self->currentPageNextY += marginV; if (self->currentPageNextY + 1 + marginV > self->viewportHeight) { diff --git a/scripts/generate_test_epub.py b/scripts/generate_test_epub.py index 126c5a09..f13bb192 100644 --- a/scripts/generate_test_epub.py +++ b/scripts/generate_test_epub.py @@ -1079,9 +1079,9 @@ greet("World");

Second rule above. Two rules in a row with no text between them:



-

Two rules appeared above. Now a rule at the very start of a section (right after the heading):

+

Two rules appeared above. Now a rule right after the heading:


-

Rule appeared right after the heading. Finally, a rule near the end of the page to verify it does not cause a spurious page break when there is still room:

+

Rule appeared right after the paragraph above. Finally, a rule near the end of the page to verify it does not cause a spurious page break when there is still room:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.


End of horizontal rule tests.

diff --git a/test/epubs/test_jpeg_images.epub b/test/epubs/test_jpeg_images.epub index c5f1bc25..600bdbfb 100644 Binary files a/test/epubs/test_jpeg_images.epub and b/test/epubs/test_jpeg_images.epub differ diff --git a/test/epubs/test_mixed_images.epub b/test/epubs/test_mixed_images.epub index bac6c348..9c3826f6 100644 Binary files a/test/epubs/test_mixed_images.epub and b/test/epubs/test_mixed_images.epub differ diff --git a/test/epubs/test_png_images.epub b/test/epubs/test_png_images.epub index ed3b0645..4f1a548a 100644 Binary files a/test/epubs/test_png_images.epub and b/test/epubs/test_png_images.epub differ diff --git a/test/epubs/test_text_rendering.epub b/test/epubs/test_text_rendering.epub index 8907acad..74be4b31 100644 Binary files a/test/epubs/test_text_rendering.epub and b/test/epubs/test_text_rendering.epub differ