Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.07k stars 1.51k forks source link

Text For Stroke/Outline Doesn't Align properly #2150

Open frannerkea opened 2 months ago

frannerkea commented 2 months ago

Hey, I'm currently trying to create videos with Moviepy but run into a few problems with the text.

Solution: Add another text layer on top without stroke.

Here are 2 Images. The first one is how the Moviepy file is exported with weird alignment. The second is a Figma file of how it should look like. text alignment exsample MoviePy Export (note: the stroke size is bigger than the Figma file stroke to showcase the issue)

Figam Exsample Example of what it should look like.

Here is some of the code:

Create text clips with stroke

english_text_stroke = TextClip(english_word, fontsize=font_size, color='white', font=font_path, stroke_color='black', stroke_width=3)

spanish_text_stroke = TextClip(spanish_word, fontsize=font_size, color='white', font=font_path, stroke_color='black', stroke_width=3)

Create text clips without stroke (to overlay on top)

english_text = TextClip(english_word, fontsize=font_size, color='white', font=font_path)

spanish_text = TextClip(spanish_word, fontsize=font_size, color='white', font=font_path)

Position text clips

english_text_stroke = english_text_stroke.set_position((left_column_x - english_text.w // 2, y_position))

spanish_text_stroke = spanish_text_stroke.set_position((right_column_x - spanish_text.w // 2, y_position))

english_text = english_text.set_position((left_column_x - english_text.w // 2, y_position))

spanish_text = spanish_text.set_position((right_column_x - spanish_text.w // 2, y_position))

Does anyone know of any solutions?