MuhammadSajid commited on
Commit
aa8af41
·
verified ·
1 Parent(s): e79bd55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -133,7 +133,10 @@ def create_basic_animation(text, audio_file):
133
  y_start = (height - len(lines) * font_size) // 2
134
  for j, line in enumerate(lines):
135
  try:
136
- text_x = (width - d.textsize(line, font=font)[0]) // 2
 
 
 
137
  except AttributeError as e:
138
  print(f"AttributeError: {e}")
139
  print(f"Pillow version: {pillow_version}")
 
133
  y_start = (height - len(lines) * font_size) // 2
134
  for j, line in enumerate(lines):
135
  try:
136
+ bbox = d.textbbox((0, 0), line, font=font)
137
+ text_width = bbox[2] - bbox[0]
138
+ text_x = (width - text_width) // 2
139
+
140
  except AttributeError as e:
141
  print(f"AttributeError: {e}")
142
  print(f"Pillow version: {pillow_version}")