Spaces:
Running
Running
Update video.py
Browse files
video.py
CHANGED
@@ -58,25 +58,17 @@ def create_text_image(text,id,image_olst, image_size=(1280, 720), bg_color="whit
|
|
58 |
|
59 |
heading_color = "#0033cc" # Deep attractive blue
|
60 |
normal_color = text_color # Usually black
|
61 |
-
|
62 |
y = (image_size[1] - total_height) // 2
|
63 |
for line in best_lines:
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
words = line.split()
|
68 |
-
for word in words:
|
69 |
-
is_bold = word.startswith("*") and word.endswith("*")
|
70 |
-
clean_word = word.strip("*") if is_bold else word
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
draw.text((x, y_line), clean_word + " ", font=font_to_use, fill=color_to_use)
|
77 |
-
x += w
|
78 |
-
|
79 |
-
y += get_text_size(line, best_font)[1] + 23
|
80 |
image_name="slide"+str(id)+".png"
|
81 |
image_olst.append(image_name)
|
82 |
image_path=os.path.join(IMAGE_DIR,image_name)
|
|
|
58 |
|
59 |
heading_color = "#0033cc" # Deep attractive blue
|
60 |
normal_color = text_color # Usually black
|
61 |
+
|
62 |
y = (image_size[1] - total_height) // 2
|
63 |
for line in best_lines:
|
64 |
+
is_heading = line.strip().endswith("?") or line.strip().endswith(";")
|
65 |
+
font_to_use = ImageFont.truetype(bold_font_path, best_font.size) if is_heading else best_font
|
66 |
+
color_to_use = heading_color if is_heading else normal_color
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
w, h = get_text_size(line, font_to_use)
|
69 |
+
x = 80 # Left padding
|
70 |
+
draw.text((x, y), line, font=font_to_use, fill=color_to_use)
|
71 |
+
y += h + 23
|
|
|
|
|
|
|
|
|
72 |
image_name="slide"+str(id)+".png"
|
73 |
image_olst.append(image_name)
|
74 |
image_path=os.path.join(IMAGE_DIR,image_name)
|