What is the unit of ImageFont.textsize() returned values?

Viewed 544

I am trying to use PIL to precompute the size that a given line of text will take at a given font and size. PIL seemed to be more or less the only working solution.

I am not sure what is the unit of the returned value of font.textsize(..). The doc doesn't specify it.

The reason why I am asking is because I am confused by the returned values as mentioned here: ImageFont.textsize() seems wrong

1 Answers

The units are pixels, so it tells you how large a canvas you would need to accommodate the text.

There is no reason it should be the same as any other product's text size.

There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.

Related