[reportlab-users] Parsing of <table> & ICU wordWrap
Robin Becker
robin at reportlab.com
Sat Nov 7 16:10:53 EST 2015
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 <buganini at gmail.com> 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 <robin at reportlab.com>:
>> 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
>> 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
--
Robin Becker
More information about the reportlab-users
mailing list