[reportlab-users] Hyphenation

Lele Gaifax lele at metapensiero.it
Thu Jun 21 04:51:07 EDT 2018


Lele Gaifax <lele at metapensiero.it> writes:

> However, I must be missing something in the "width" argument, because for
> example when using a ImageAndFlowables it clearly uses the wrong width in the
> "second" part (where the image ends so there's a wider space available)...

I think I figured it out and spotted the problem with ImageAndFlowables: the
widget basically first calls .wrap() on the paragraphs on image's side, that
in turn compute their blPara attribute, then if the height of the flowables is
taller than the image's it splits the paragraphs, and that's where it does the
wrong thing (for my purpose, of course): the Paragraph.split() method cuts it
in two halves, rebuilding their respective frags attribute from blPara
honoring the height constraint, and thus possibly already hyphenated words end
into the ParaFrag structure and are eventually rendered as-is into a possibly
wider context.

Fixing the issue is complicated, because the Paragraph.split() method calls
plain functions (_split_blParaSimple() and _split_blParaHard()) so I should
override the whole method simply to call a "smarter" implementation that knows
about _SplitText and _SplitList...

At this point, given that my need for ImageAndFlowables is marginal at best, I
won't be feeding it PyphenParagraphs, using them only in "plain" containers.

I updated my gist to what I'm currently using, previous version had a glitch
with multifrag paragraphs.

Thanks in advance for any further insight.

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



More information about the reportlab-users mailing list