ImageFont.textsize()返回值的单位是什么? [英] What is the unit of ImageFont.textsize() returned values?

查看:154
本文介绍了ImageFont.textsize()返回值的单位是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆