RenderPMError when using TTF in bitmaps

Dinu Gherman <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
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
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.