[reportlab-users] RenderPMError when using TTF in bitmaps

Robin Becker robin at reportlab.com
Mon Jan 15 03:30:03 EST 2018


Hi Dinu, I believe this is just a generic response to a font loading error.
If you want send me a copy of Code2000.ttf; it's possible that it is a file
we cannot handle; possibly a type 1 otf.

On 13 January 2018 at 09:34, Dinu Gherman <gherman at darwin.in-berlin.de>
wrote:

> Hello!
>
> in a toy project I register a TrueType font, use it in a Drawing and save
> that as a PNG (see code below), but I’m getting a warning and traceback,
> that suggests I need PFB files for that font. I’ve reproduced this at least
> with one other TTF, too.
>
> I believe I did that kind of thing without any trouble some years ago, or
> maybe I have false memories? Any ideas? This is on Python 3.6 and reportlab
> 3.4.0.
>
> Cheers,
>
> Dinu
>
>
> from reportlab.pdfbase.ttfonts import TTFont
> from reportlab.pdfbase import pdfmetrics
> from reportlab.graphics.shapes import Drawing, String
> from reportlab.graphics import renderPM
>
> ttf = TTFont('Code2000', 'fonts/Code2000.ttf')
> pdfmetrics.registerFont(ttf)
> d = Drawing(500, 500)
> fn, fs = 'Code2000', 24
> text = String(0, 0, "foo bar", fontName=fn, fontSize=fs)
> d.add(text)
> renderPM.drawToFile(d, "foo_bar.png", fmt="PNG", dpi=72)
>
>
> Warn: Can't find .pfb for face 'b'Code2000‘'
> [...]
> [...]/lib/python3.6/site-packages/reportlab/graphics/renderPM.py in
> _setFont(gs, fontName, fontSize)
>     249         except:
>     250             s1, s2 = list(map(str,sys.exc_info()[:2]))
> --> 251             raise RenderPMError("Can't setFont(%s) missing the T1
> files?\nOriginally %s: %s" % (fontName,s1,s2))
>     252         gs.setFont(fontName,fontSize)
>     253
>
> RenderPMError: Can't setFont(Code2000) missing the T1 files?
> Originally <class 'AttributeError'>: 'TTEncoding' object has no attribute
> ‚v
> ector'
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>



-- 
Robin Becker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20180115/d049666a/attachment.html>


More information about the reportlab-users mailing list