Search code examples
manim

Globally or Locally change manim default font color for Tex and Text


Manim Community v0.15.1

I am new to Manim. I have been trying to change the font color of both Tex and Text objects without having to set the color for each Tex or Text object individually.

How do I change the font color for all Tex and Text objects within a scene or globally?

Here are some solutions that I believe I tried, but came up with nothing:

https://github.com/3b1b/manim/issues/1145

Change Text Colour Manim Community

I think this all has something to do with the following from Manim: https://docs.manim.community/en/stable/installation/troubleshooting.html?highlight=config#config

Here is a code example I have:

from manim import *
class My_made_Up_Scene_Name(Scene):
    def construct(self):
        text_1 = Text("Text_1", font = "Arial", font_size = 50)

Where would I insert a scene-wide change of font color?


Solution

  • You can use the set_default method:

    def construct(self):
        Text.set_default(font="Arial", font_size=50)
        text_1 = Text("Hello world!")