Re: RenderPMError when using TTF in bitmaps
Robin Becker <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <CAOBYczqzmxpvAuwk6YLmqXTCv6ta+KjL+WdE7y9U42EG5FBqjA@mail.gmail.com> |
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 <[email protected]> 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 > [email protected] > https://pairlist2.pair.net/mailman/listinfo/reportlab-users > -- Robin Becker