From 971acef0a5697bb7cbbc2b28b5faf0dc2c132160 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 11:44:18 +0200 Subject: [PATCH] Review comments --- .../Epub/parsers/ChapterHtmlSlimParser.cpp | 6 ++++-- scripts/generate_test_epub.py | 4 ++-- test/epubs/test_jpeg_images.epub | Bin 306767 -> 306767 bytes test/epubs/test_mixed_images.epub | Bin 52139 -> 52139 bytes test/epubs/test_png_images.epub | Bin 101094 -> 101094 bytes test/epubs/test_text_rendering.epub | Bin 3586 -> 3568 bytes 6 files changed, 6 insertions(+), 4 deletions(-) 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 c5f1bc2570c6a6bcf2a5e24767d3c7fac28b3038..600bdbfb0bbcbcf04cc1db23449e44226f24fbd9 100644 GIT binary patch delta 399 zcmX?qN9g<=A)WwlW)=|!5GaqG$Ya3-B;6hW$;}#!p^PB9p6Rw3h>o$80rRV@n4`hs zQ#rx>u4z}}K>Wn7OkjTMx7!iC<+1ByTtqdCE&xZPz)-d@Bef$|1sH0TSKrB+6pt0%FufvM7K>7DTc9aRrIY zTfm|W7CF3-ZybcUudQ?^w&?2vUD~EsHIP=32+%3IG(jikAQY delta 399 zcmX?qN9g<=A)WwlW)=|!5SS7&k;j4wNV+`$lAARcLm5GIJ=1M75FKMF1Ljv*F-L>N zr*eY%UDK|{f%u7EnZW$iZ?_|Or-ZDJaS_!lx&$;=W4gcrCXwlh{)~@->e}4`7`M9x zFzw9;a<;P`U{VF?YS%f)v|Z;Q^Q|C|D2E7(1xR$elPHUo3y4t{$)W%jSrEnY#}y

9XFlg@;8XfZ&fb@ z;!g1S3F3D9GDm~x2`g4egJ`QGs$gA-N6&+4qvI|hdUC}H6A-oTgcFGRbix5dnVj?h lQFSN5yaOlQK|Ib=V4n9WZxC+=gn9}QR6lJC5==Yo3IO~iNZJ4Z diff --git a/test/epubs/test_png_images.epub b/test/epubs/test_png_images.epub index ed3b0645d9544a797c4cf2d310d198027f738c22..4f1a548a1374b460d374f24b9c0d1a3b042f0b97 100644 GIT binary patch delta 407 zcmaDhmF?M7Hl6@)W)=|!5GaqG$Ya3-B;6hW$;}#!!HgifmZ@F{ME?`f0P{7(R!H-f z$F7el>3AA(1E^1D`hs*uk;xwoUxJj~G2)W~(QkYh!OGwJc7XYn8B7r4GB1~dwRfJ- zzw#BRJqoOSdRzx1`{as;|3P{yAK4ZF>Fqm$7%f1Wwtos{Tqq1;OigE00E=wTU~Cov ziP+RKDuYE5>lp7afkf;Z8P&jy^k&8`kks_gEsQ20TCTC zZ`H==4dS=ALF7-iF?xacqU{iVcsoRX36%e=ozW8{Z`c8mFYaLU1Mv?-`K+A~`G8J{ b{3Iy2V#5?2{`V{s-x;d}Lbyq_^(~VzdBh+Wsk+aiK7XF*Ti00W7jTgRxlz zBw|y`s0rEr?#&#pntEc!!X5 diff --git a/test/epubs/test_text_rendering.epub b/test/epubs/test_text_rendering.epub index 8907acad60d6bd629078bf6eb23db6655ba293c0..74be4b31dcab7af67b255eae394a951486de2b17 100644 GIT binary patch delta 705 zcmZpY`5?^`;LXe;!Tp6VAX?{0YHblW79b*+WMiUiAol1JM=2FvbG*l!ZO zPtMZ&R;r-5U*VKWaBma?X<4my=R@+)79VS z-_PB5|Nf!O=c`?3%HJrpTe5m-@LT<^B$?w^f265y)V=on`SYWC$AQ-Bh*8 z&g02^p(_g~khClU$R%-r9E@WZ5hDTArkQ5L@>CTb&F{^*dT{TPX|nQ}HA~%^Y!^f(8lU}16K|?rlal_*-ze>vj@Zu9ssx?yXBYl$-mrezviXsH>GQnj z{(NsCQU89vU;4xe-e*0y%CZWjvN*MVF8lnAbIk@PPDhbm$sj-dug)owm*k?|jrb+* z-YZfma0>b+7ntI=VEw<%pMzC4ZD4w&Semr(%2%O-3lmS5adbI8^qu=&^6C7qKd;O* zlaM%X&sH4r^6kCXj_-rTW_?fPkDYS#{a&qQs{dF)X@~=qh&X_WX!CiFUT{K*KBg#dXn*$6@jk;LXe;!TMBJpP!9%|Er27+sth> zwnfu&r!R`LI6CqEp68XHm+iXoO|D!-*xMq0UDtK*fQ+L>FV0QBfBm|8{&exLi>f|8 zJpKD?|7>lGx3zm$d}6smudQfk~4uM$br85SG`LIUCwL{hOJiS-`EVz^Tr2x8{9I z$;eQinD(bFIq1m6;6{I;mF)bPZxWAs*SjROzVz(B=;d)m>!n1Z4*#4eKG_qW;|?7C z)Y)@W<7j=zwZ3Prb`JTW0%`=;&J^qEGFb(R&|my5igc*W(co^(of1XG;byE$?u z^FAM_Us(Nh`lEpJffW-fm#sKp%KrH8-;Z&&PcqY4Sgrf73$k4n4EZ#wa+q2pXH}zz;=PJ#N_Q`whs#4$-^i3`>CI4)||8$AIi6;(mbsWFa-5O-?!O}iW z_qL&iTdTP*pTg7QziM9jiu3e5pTD@$==JK@_3Vu^_DWsY<6-?`k=B2m7|Z