ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
24.85k stars 1.74k forks source link

Text - Changing colors, styles, etc does not work as expected #2330

Closed buffos closed 2 years ago

buffos commented 2 years ago

Description of bug / unexpected behavior

When you create Text object and use the t2c, t2s etc or use the functions set_color_by_t2c for example, the result is not the expected and the results are shifted

Expected behavior

For example

Text("this is the end of the world", t2c={"end": RED} )

you expect end to be in RED but you see of t in RED.

It seems that the find_indexes finds the indexes in the original text but probably these are not compatible with the chars array?

How to reproduce the issue

Code for reproducing the problem ``` Text("this is the end of the world", t2c={"end": RED} ) ```
PhilippImhof commented 2 years ago

In the meantime, you could also solve the problem by using MarkupText instead of Text. This avoids the t2c syntax (that I personally find cumbersome) and uses markup similar to basic HTML instead.