[reportlab-users] Hyphenation glitch when using HTML entities

9 views
Skip to first unread message

Lele Gaifax

unread,
Dec 4, 2021, 12:03:35 PM12/4/21
to reportl...@lists2.reportlab.com
Hi,

I have an issue when rendering a justified-hyphenated paragraph containing
HTML entities. It may very well be a font issue, because I was not able to
replicate it with a standard font, but I will try harder if that helps.

Basically, when the paragraph is a plain text everything goes well, but as
soon as it contains, say, a '"' entity instead of the corresponding
double quote '"', apparently the machinery that compute the extra space and
adjust the word space fails, even on subsequent lines of text.

I wrote a trimmed down example that exhibits the problem:

https://gist.github.com/lelit/f0e1ed1e2f9dec431463bec77a047362

You can see the problem in the third paragraph here:

https://gist.github.com/lelit/f0e1ed1e2f9dec431463bec77a047362#file-hyphenation_glitch-pdf

Does this ring any bell or should I simply blame the specific font's metrics?

Thanks in advance,
bye, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
le...@metapensiero.it | -- Fortunato Depero, 1929.

_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users

Robin Becker

unread,
Dec 5, 2021, 3:13:40 AM12/5/21
to Lele Gaifax, For users of Reportlab open source software
On 04/12/2021 17:03, Lele Gaifax wrote:
> Hi,
>
> I have an issue when rendering a justified-hyphenated paragraph containing
> HTML entities. It may very well be a font issue, because I was not able to
> replicate it with a standard font, but I will try harder if that helps.
>
> Basically, when the paragraph is a plain text everything goes well, but as
> soon as it contains, say, a '"' entity instead of the corresponding
> double quote '"', apparently the machinery that compute the extra space and
> adjust the word space fails, even on subsequent lines of text.
>
> I wrote a trimmed down example that exhibits the problem:
>
> https://gist.github.com/lelit/f0e1ed1e2f9dec431463bec77a047362
>
> You can see the problem in the third paragraph here:
>
> https://gist.github.com/lelit/f0e1ed1e2f9dec431463bec77a047362#file-hyphenation_glitch-pdf
>
> Does this ring any bell or should I simply blame the specific font's metrics?
>
> Thanks in advance,
> bye, lele.
>

I see that the justification has failed in the last paragraph. Use of the quote turns the paragraph into a multi-frag
para and that is handled differently. It will need some detailed debugging to figure out why.

It looks like the space count has failed in those lines, but exactly why I don't know.
--
Robin Becker

Robin Becker

unread,
Dec 5, 2021, 3:26:36 AM12/5/21
to reportlab-users, Lele Gaifax
My first impression was correct. If you add any tag into the paragraphs so eg in oara2


> text2 = """
> <span color='red'>My</span> recent u

then the lines which are hyphenated seem to lose the right space adjustment.
It's not specific to using &quot;; all entity usage turns the para into a multi-fragment case.

I will try and fix.
--
Robin Becker

Robin Becker

unread,
Dec 14, 2021, 4:52:35 AM12/14/21
to reportlab-users, Lele Gaifax
Hi Lele,

thanks for the report; it turns out there were a number of issues related to multi-fragment paragraphs.

1) The computation of space shrinkage was wrong.
2) Final lines of paragraphs were not justified properly (also for single fragment paras).

It did make some differences to the standard test renders so I have not yet released fully. If you want you can try the
changes by down loading a 3.6.4 wheel from https://www.reportlab.com/pypi (needs a login see
http://www.reportlab.com/accounts/register/) or get the source from https://hg.reportlab.com/hg/reportlab.

It made the tests work OK and there's a test output with single and multi-frag text matching.
--
Robin Becker
test_platypus_breaking_lelegaifax.pdf

Lele Gaifax

unread,
Dec 14, 2021, 12:15:47 PM12/14/21
to Robin Becker, reportlab-users
Hi Robin,

Robin Becker <ro...@reportlab.com> writes:

that's really great, thank you so much!

I will surely test your work as soon as possible, reasonably tomorrow early
morning, and will report back.

Thanks again,

Robin Becker

unread,
Dec 14, 2021, 3:34:17 PM12/14/21
to Lele Gaifax, reportlab-users
Hi Lele,
>> https://hg.reportlab.com/hg/reportlab.
whoops, I gave the wrong mercurial URL.

The right one is

https://hg.reportlab.com/hg-public/reportlab

--
Robin Becker

Lele Gaifax

unread,
Dec 15, 2021, 6:04:50 AM12/15/21
to Robin Becker, reportlab-users
Lele Gaifax <le...@metapensiero.it> writes:

> I will surely test your work as soon as possible, reasonably tomorrow early
> morning, and will report back.

I did a few tests, and everything seems ok: all paragraphs I checked were
justified correctly with the new version.

Reply all
Reply to author
Forward
0 new messages