[reportlab-users] RenderPM in 1.1.9

Robin Becker reportlab-users@reportlab.com
Thu, 29 Jan 2004 07:54:53 +0000


In article <20040129060019.74834.qmail@web15202.mail.bjs.yahoo.com>,
=?gb2312?q?=FFffffca=FFffffbf=FFffffb7=FFffffbc=20=FFffffcd=FFfffff5?=
<wangshifang_2008@yahoo.com.cn> writes

Did you try fontName='comic'? The registerFont command allows renderPM
to use TTF fonts. The name 'comic' is used internally by reportlab. The
name 'GOTHIC.TTF' is not a fontname, but the name of a file.


Try this for a 3d chart.
#Autogenerated by ReportLab guiedit do not edit
from rlextra.graphics.quickchart import QuickChart
from reportlab.graphics.charts.barcharts import VerticalBarChart3D
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin
from reportlab.lib.colors import grey

class Drawing_003(_DrawingEditorMixin,Drawing):
    def __init__(self,width=400,height=200,*args,**kw):
        apply(Drawing.__init__,(self,width,height)+args,kw)
        self._add(self,VerticalBarChart3D(),name=None,validate=None,desc
=None)
        self.contents[0].fillColor        = grey
        self.contents[0].width            = 310
        self.contents[0].height           = 110
        self.contents[0].zSpace=3
        self.contents[0].zDepth = 7.5
        self.contents[0].categoryAxis.style = 'parallel_3d'
        self.contents[0].categoryAxis.categoryNames = ['North', 'South',
'Central','Mars']
        self.contents[0].y                = 20
        self.contents[0].categoryAxis.visibleGrid         = 1
        self.contents[0].valueAxis.visibleGrid         = 1

if __name__=="__main__": #NORUNTESTS
    Drawing_003().save(formats=['pdf'],outDir='.',fnRoot=None)

>    Hi:
>
>    1   In reportlab 1.1.9 said: Support for True Type Fonts in 
>    renderPM.
>
>         Can you tell me how to use it?
>
>         I do it as following;
>
>         from reportlab  import *
>         from reportlab.graphics import renderPM
>         from reportlab.pdfbase import pdfmetrics
>         from reportlab.pdfbase.ttfonts import TTFont
>         pdfmetrics.registerFont(TTFont('comic', 'georgia.ttf'))
>         from reportlab.lib import colors
>         from reportlab.graphics.shapes import *
>        d = Drawing(400,200)
>        d.add(Rect(50,50,300,100, fillColor=colors.yellow))
>        d.add(String(30,50,'jjj',fontName='GOTHIC.TTF'))
>        renderPM.drawToFile(d, 'out.jpg', 'JPG')
>
>    The resualt is:
>
>      RenderPMError: Can't setFont(GOTHIC.TTF) missing the T1 files?
>      Originally exceptions.KeyError: GOTHIC.TTF
>
>      GOTHIC.TTF is in c:\winnt\fonts
>
>    2   How could I draw some 3dchart,can you give me some examples/
>
>     Thanks in advance
>
>
>    Do You Yahoo!?

-- 
Robin Becker