From ed77cb2bba5261941e74177fe1b575e5756f8eef Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 30 Jun 2026 16:17:46 +0530 Subject: [PATCH] fix(text): apply constructor color to Text/MarkupText mobject The color passed to Text/MarkupText is baked into the glyph SVGs but the parent mobject keeps its default fill, so get_color() returned the wrong value. Set the parent fill/stroke (family=False) to preserve per-character colors. Fixes #4817. --- manim/mobject/text/text_mobject.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manim/mobject/text/text_mobject.py b/manim/mobject/text/text_mobject.py index d484420301..9a6dde2a70 100644 --- a/manim/mobject/text/text_mobject.py +++ b/manim/mobject/text/text_mobject.py @@ -527,6 +527,10 @@ def __init__( **kwargs, ) self.text = text + # The color is baked into the glyph SVGs, but the parent mobject keeps + # the default fill/stroke, so get_color() ignores it. Reflect it here + # (family=False preserves any per-character t2c/gradient colors). + self.set_color(parsed_color, family=False) if self.disable_ligatures: self.submobjects = [*self._gen_chars()] self.chars = self.get_group_class()(*self.submobjects) @@ -1225,6 +1229,11 @@ def __init__( **kwargs, ) + # The color is baked into the glyph SVGs, but the parent mobject keeps + # the default fill/stroke, so get_color() ignores it. Reflect it here; + # gradient/colormap tags below still override per-character colors. + self.set_color(parsed_color, family=False) + self.chars = self.get_group_class()(*self.submobjects) self.text = text_without_tabs.replace(" ", "").replace("\n", "")