Re: Parsing of <table> & ICU wordWrap

Robin Becker <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CAOBYczoPzn6_Y0VX-nGwB+vkMpwawfo5Bh2bZb2pa1GqcxgzeQ@mail.gmail.com>
The font name should be 'Helvetica' so some where you have a wrong
font specification; styles['Normal'] has the canvas_basefontname set
into it (imported from rl_settings.py via rl_config). There are
override mechanisms which can alter the default value.

$ python
Python 2.7.10 (default, Sep  7 2015, 13:51:49)
[GCC 5.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from reportlab.lib.styles import getSampleStyleSheet
>>> styles=getSampleStyleSheet()
>>> styles['Normal'].fontName
'Helvetica'
>>>

On 7 November 2015 at 12:32, Buganini <[email protected]> wrote:
> http://pastebin.com/JuQVrGzC
>
> But I just found two problem:
> 1. table is double if width < 100mm (line 55)
> 2. this program dies with following message if fontName is not set (line 51)
>
> Traceback (most recent call last):
>   File "table.py", line 63, in <module>
>     p.wrap(width-padding*2, height-padding*2)
>   File "/usr/local/lib/python2.7/dist-packages/reportlab-3.2.9-py2.7-linux-x86_64.egg/reportlab/platypus/paragraph.py",
> line 1111, in wrap
>     blPara = self.breakLines(self._wrapWidths)
>   File "/usr/local/lib/python2.7/dist-packages/reportlab-3.2.9-py2.7-linux-x86_64.egg/reportlab/platypus/paragraph.py",
> line 1430, in breakLines
>     spaceWidth = stringWidth(' ',fontName, fontSize)
>   File "/usr/local/lib/python2.7/dist-packages/reportlab-3.2.9-py2.7-linux-x86_64.egg/reportlab/pdfbase/pdfmetrics.py",
> line 720, in stringWidth
>     return getFont(fontName).stringWidth(text, fontSize, encoding=encoding)
>   File "/usr/local/lib/python2.7/dist-packages/reportlab-3.2.9-py2.7-linux-x86_64.egg/reportlab/pdfbase/pdfmetrics.py",
> line 686, in getFont
>     return findFontAndRegister(fontName)
>   File "/usr/local/lib/python2.7/dist-packages/reportlab-3.2.9-py2.7-linux-x86_64.egg/reportlab/pdfbase/pdfmetrics.py",
> line 668, in findFontAndRegister
>     face = getTypeFace(fontName)
>   File "/usr/local/lib/python2.7/dist-packages/reportlab-3.2.9-py2.7-linux-x86_64.egg/reportlab/pdfbase/pdfmetrics.py",
> line 625, in getTypeFace
>     return _typefaces[faceName]
> KeyError: 'helvetica'
>
> 2015-11-04 21:08 GMT+08:00 Robin Becker <[email protected]>:
>> On 04/11/2015 05:52, Buganini wrote:
>> .........
>>>>
>>>> correct?
>>>
>>>
>>> That's correct, BTW I don't know the meaning of cbDefn.
>>>
>> .....
>> my bad; come from pre-history where var names are too long and use memory.
>> cbDefn originally stood for "call back definition" and originally we
>> intended it for really simple stuff like indexing which didn't use any width
>> etc etc, but it got reused as the carrier of information for the img tag
>> since it was the one non-regular thing we were already doing in the break
>> lines and similar functions.
>>
>> If you have a good use case please post some small example so we can see how
>> it looks. If it seems useful perhaps it can be rolled into RL.
>>
>> --
>> Robin Becker
>> _______________________________________________
>> reportlab-users mailing list
>> [email protected]
>> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
> _______________________________________________
> reportlab-users mailing list
> [email protected]
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users



-- 
Robin Becker
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.