[reportlab-users] Hyphenation

Robin Becker robin at reportlab.com
Mon Apr 23 11:42:16 EDT 2018


I'm fairly sure we never really implemented any satisfactory paragraph splitting that used hyphenation.
I know the wordaxe package did a lot, but I suspect that wordaxe is now unsupported.
The latest reportlab code does at least acknowledge that sometimes words need to be split.

if newWidth>maxWidth:
     nmw = min(lineno,maxlineno)
     if wordWidth>max(maxWidths[nmw:nmw+1]) and not isinstance(word,_SplitText) and splitLongWords:
         #a long word
         words[0:0] = _splitWord(word,maxWidth-spaceWidth-currentWidth,maxWidths,lineno,fontName,fontSize,self.encoding)
         self._splitLongWordCount += 1
         continue

so logically it ought to be possible to try and hyphenate before arbitrarily splitting. However, looking at the wordaxe code it 
seems to try and do a lot more that just allowing splits inside long words. I think the guts are in the function findBestSolution 
which is applied at the overflow and the code that follows immediately. I will have a go at getting the wordaxe stff to work 
inside latest reportlab when I get to rest after an upcoming surgery :(
-- 
Robin Becker



On 23/04/2018 15:47, Mike Driscoll wrote:
> Hi Dinu and Lele,
> 
> I haven't actually used wordaxe before. I had thought I had seen something
> on the mailing list about ReportLab having better support for this
> built-in, but I can't find anything obvious with Google. Dinu, did
> ReportLab ever include your changes that you mentioned in this thread:
> https://pairlist2.pair.net/pipermail/reportlab-users/2008-September/007283.html
> ?
> 
> If I had some samples of what it looks like before wordaxe is applied and
> then after, I think I would understand it a bit better. I have a general
> idea, but I prefer concrete examples. Then maybe I could put together a
> tutorial around the subject. It is too bad that wordaxe looks like its been
> dead for 8 years.
> 
> Here's a link to the book Dinu mentioned: https://leanpub.com/reportlab/  I
> still have around 4 chapters left to write, but you can get what's
> currently done if you're interested (plus free updates)
> 
> Mike
> 
> -----------------
> Mike Driscoll
> 
> Blog:   http://blog.pythonlibrary.org
> Books: Python 101 <https://gum.co/py101>, Python 201: Intermediate Python
> <https://gum.co/py201>, wxPython Recipes
> <https://www.apress.com/us/book/9781484232361>, Python Interviews
> <https://www.packtpub.com/web-development/python-interviews>
> 
> On Sat, Apr 21, 2018 at 3:03 AM, Dinu Gherman <gherman at darwin.in-berlin.de>
> wrote:
> 
>> Hyphenation has always been rather low on the priority list, given that
>> average word lengths in English are pretty short compared to German or
>> French, say.
>>
>> I've used Henning's wordaxe and its previous incarnations, but it's too
>> long ago to give any useful advice now (also while still travelling back
>> from vacation).
>>
>> In any case that topic would be one more cool "pro" thing to be covered in
>> Mike's emerging book, if he's still looking for topics. ;-)
>>
>> Cheers,
>>
>> Dinu
>>
>> Lele Gaifax <lele at metapensiero.it>:
>>>
>>> Hi all,
>>>
>>> is there a multi-language hyphenation solution for current ReportLab?
>>>
>>> I found the "wordaxe" package, but seems a little old and
>> unmaintained... In
>>> the current RL source there are just a few mentions to the capability,
>> but I
>>> fail to see how one could inject a language-specific hyphenator into the
>>> Paragraph class.
>>>
>>> Thanks in advance for any hint,
>>> 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.
>>>
>>> _______________________________________________
>>> reportlab-users mailing list
>>> reportlab-users at lists2.reportlab.com
>>> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>>
>>
> 
> 
> 
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
> 




More information about the reportlab-users mailing list