I want to draw a price into a picture with fontsize=2x vor the dollars and fontsize=x for the cents, like this:
I want to be able to write 1.90 and 19.90 and so on, which is why I want the dollars amount to be right aligned, while the cents amount is of standard left alignment.
Edit: I forgot a vital point: The comma is fixed (because of a display position) and I want to write the dollars value so that it expands to the left, while the cent value always stays as is (00, 05, 10, 19, 99....). So when instead of 12,99 I write for example 123,99 I still want the , to be in the same position. My only Idea so far was to work with single chars, which are less comfortable to handle :(
Using the ImageDraw module, you can get the size of a text string.
draw.textsize(string, options) ⇒ (width, height)
This is from the docs at http://effbot.org/imagingbook/imagedraw.htm. So, you can get the width of the string "12," in pixels. Now you can just subtract the width from the desired end position to know where to start it. Unfortunately PIL doesn't seem to give a way to position text except by specifying the upper left-hand corner, so for other anchors, you have to compute it yourself (so far as I know).
EDIT: I just looked at the Pillow docs at http://pillow.readthedocs.org/reference/ImageDraw.html#functions
The signature for the function given there is
PIL.ImageDraw.Draw.text(xy, text, fill=None, font=None, anchor=None)
However, in the comments below the signature, "anchor" is not explained, so it may be only a planned future enhancement. My own experience with the Pillow docs indicates that this is a real possibility. Personally, I would try to look at the Pillow source and determine the status before converting from PIL to Pillow just for this.