ImageFont.textsize()返回值的单位是什么? [英] What is the unit of ImageFont.textsize() returned values?
问题描述
我正在尝试使用PIL来预先计算给定文本行在给定字体和大小下所占的大小. PIL或多或少是唯一可行的解决方案.
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.
我不确定font.textsize(..)
的返回值的单位是什么. 文档未指定.
I am not sure what is the unit of the returned value of font.textsize(..)
. The doc doesn't specify it.
我问的原因是因为我对这里提到的返回值感到困惑: ImageFont. textsize()似乎不正确
The reason why I am asking is because I am confused by the returned values as mentioned here: ImageFont.textsize() seems wrong
推荐答案
单位是像素,因此它告诉您容纳文本所需的画布大小.
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.
偶尔可能会有3-4像素的微小差异,这可能是由于抗锯齿造成的.
There is occasionally a small discrepancy of 3-4 pixels, probably as a result of anti-aliasing.
这篇关于ImageFont.textsize()返回值的单位是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!