0

I'm looking for a tool that can draw images (and write them to disk, obviously). Basically, the usual 2D rendering stuff you'd see in most GUI, except the destination needs to be an image file rather than a window. My specific needs are:

  1. Can read images and scale-blit them to arbitrary places on the output image.
  2. Can use system-installed fonts.
  3. Can handle non-English text as well as figuring out which fonts to get appropriate glyphs from if the given font face can't handle those particular pieces of text. Of course, this should include text measurement tools.
  4. Works from a standard Windows install of Python, as this is part of a larger Python program and I have no interest in managing multiple Python installs on the same machine.
  5. Does not create windows. That is, it's something that could be done from the command-line without creating a momentary flash of anything.

Now, the obvious answer is the pycairo module, since Cairo can basically do all of this. And that'd be great... except for #3 and 4. PyCairo installs on Windows, but you can only use its basic "toy" text rendering API. That violates #3, since I need a text handling system that actually works.

Fortunately, Pango exists and integrates with Cairo quite naturally. And that'd be fine... if I were using C or C++. But I'm using Python. And "pangocairo" isn't a separate package you can install with Pip. The pangocairo module is part of PyGTK, which relies on PyGObject, which (apparently?) cannot be installed on regular Windows Python installations. Instead, you have to create an MSYS2 thing and make a second installation of Python inside that. This violates #4.

And frankly, if I'm going to have to shell out to a different Python executable from within my main app just to be able to invoke this functionality, I'd just as soon write the thing in C++. That's easier than trying to manage multiple Python installations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.