ox.image: add getTextSize method
This commit is contained in:
parent
f086c64e51
commit
cca251bc32
1 changed files with 5 additions and 0 deletions
|
@ -132,6 +132,11 @@ def getRGB(hsl):
|
||||||
rgb[i] = v1
|
rgb[i] = v1
|
||||||
return tuple(map(lambda x: int(x * 255), rgb))
|
return tuple(map(lambda x: int(x * 255), rgb))
|
||||||
|
|
||||||
|
def getTextSize(image, text, font_file, font_size):
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
font = ImageFont.truetype(font_file, font_size, encoding='unic')
|
||||||
|
return draw.textsize(text, font=font)
|
||||||
|
|
||||||
def wrapText(text, max_width, max_lines, font_file, font_size):
|
def wrapText(text, max_width, max_lines, font_file, font_size):
|
||||||
# wraps text to max_width and max_lines
|
# wraps text to max_width and max_lines
|
||||||
def get_width(string):
|
def get_width(string):
|
||||||
|
|
Loading…
Reference in a new issue