[reportlab-users] Hyphenation

Lele Gaifax lele at metapensiero.it
Fri Jun 22 13:08:45 EDT 2018

Robin Becker <robin at reportlab.com> writes:

> I have mostly got hyphenation working using Pyphen. Currently about 5 tests fail because of
> simple paragraph corner cases involving splits.
> I will try and finish a working version next week.

Great news, thank you!

> Unfortunately my simple approach is also trying to hyphenate things like
> URLS which I suppose should be handled separately.
> Also currently I lack a way to get just the word and not non-alpahabetics. I
> suppose that should be easy if we know what constitutes hyphenatable matter.
> Any ideas welcome.

IMHO I would leave such decision to the final user, as I do not think there is
one single *right* answer... Even for URLs, which I actually happen to manage
in the app where I experimented this matter, I could not reach a consensus on
what should happen, I mean between what currently happens:

  |This is a long URL: https://hostname/contentna|

and with pyphen:

  |This is a long URL: https://hostname/content- |

it's obviously debatable...

> I am presently running with the idea of using a string setting to indicate
> what language so my settings override has
> hyphenationLang='en_GB'
> which corresponds to one of the pyphen dictionaries. This gets into the
> style and is used only if pyphen can be imported.

Not sure what you mean here, but just to make my use case clear: the app I'm
currently developing is multilingual, and produces several PDFs for a given
"item", one for each language the customer decided to support. So having a
"static" setting for the target language would not work very well for me...
best would be having a way to pass the hyphenator to the Paragraph
constructor, possibly taking a default from the SimpleDocument...

I will surely try out your solution as soon as it hits the repository and will
report back.

Thanks again,
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