0

I want to get PIL to draw the text using their fonts to get them, I use this code:

fdia = Gtk.FontSelectionDialog("Font")
response = fdia.run()
if response == Gtk.ResponseType.OK:
    self.ui.eFont.set_text(fdia.get_font_name())
fdia.destroy()

(It's return "Impact 14", for example)

but PIL requires a full path, how to get it? I try to pango:

draw.text((5, 5), "exm", font=pango.FontDescription("Impact 10"),\
                                            fill="#FFFFFF")

but PIL says :

AttributeError: 'pango.FontDescription' object has no attribute 'getmask'

Any ideas? Thanks.

Alexander Z.
  • 101
  • 2
  • I also thought that would be using Pango to create an image with text and overlay it using PIL. But examples of such perversions are not found. – Alexander Z. Jun 21 '12 at 02:15

1 Answers1

0

I don't know if you're going to have an easy time making Pango fonts and PIL font description classes play nice. The Pango.FontDescription object is not the same as the ImageFont object. You may want to use Cairo to render your fonts and graphics rather than PIL.

I have seen some folks who write to a PNG with PIL and then open that with Cairo to do font rendering--but I would just pick one or the other.

Micah Carrick
  • 9,967
  • 3
  • 31
  • 43