Does PNMTextMaker currently work?

I can’t seem to get PNMTextMaker to show me any results. I’m testing different geometry- and texture-making features in Panda, to see what works and what doesn’t. So far, it looks like PNMTextMaker thinks it’s working, but maybe it isn’t doing anything.

Here’s my test code:

xsize = white.getXSize()
ysize = white.getYSize()
text_img = PNMImage(xsize, ysize)
text_img.fill(1.0)
pt = PNMTextMaker("arial.ttf",0)
b = pt.generate_into("testing testing",text_img,xsize/2,ysize/2)
self.texts.images["orange"] = text_img
print b

Where “white” is a PNMImage and self.texts.images is a dict containing a series of PNMImages. The above code simply replaces the “orange” image with a blank white image. Yet variable b reports a pixel width for the result, suggesting that something was supposed to have happened. The font file, “arial.ttf”, has been copied to the same directory as the script. I’m not 100% sure that .ttf fonts are meant to be compatible with this function. The information I found with Google suggested that .ttf should be FreeType compatible.

Is there a trick to this? Is it broken? Does it only work in Panda C++, perhaps? I’m coding in Python, as shown above. I tested to see if Canvas() was working, and Panda Python rejected my effort. I assume Canvas is C++ only, or no longer working at all. I wonder if PNMTextMaker is the same. :question:

Okay, I see what’s happening. I had the x and y positioning wrong. This works, as shown:

xsize = white.getXSize()
ysize = white.getYSize()
text_img = PNMImage(xsize, ysize)
text_img.fill(1.0)
pt = PNMTextMaker("arial.ttf",0)
b = pt.generate_into("testing testing",text_img,0,ysize)

There doesn’t seem to be a way to get the height of the text, which complicates matters when trying to place it as desired on an image. There doesn’t seem to be a constant height, either. Both height and width of the text vary by font. We can get the width of the text, but not the height, unless I’m missing something, or there’s an undocumented option. :question: