Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
elebumm
GitHub Repository: elebumm/RedditVideoMakerBot
Path: blob/master/utils/fonts.py
327 views
1
from PIL.ImageFont import FreeTypeFont, ImageFont
2
3
4
def getsize(font: ImageFont | FreeTypeFont, text: str):
5
left, top, right, bottom = font.getbbox(text)
6
width = right - left
7
height = bottom - top
8
return width, height
9
10
11
def getheight(font: ImageFont | FreeTypeFont, text: str):
12
_, height = getsize(font, text)
13
return height
14
15