天天看点

python获取某种字体字符串所占像素数

from PIL import ImageFont
fontfile = '***.tff'
font =  ImageFont.truetype(fontfile,170,0)
text == "hello"
width, height = self.font.getsize(text)