Skip to content

fix(text): apply constructor color to Text/MarkupText mobject#4846

Closed
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/4817-text-color-attribute
Closed

fix(text): apply constructor color to Text/MarkupText mobject#4846
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/4817-text-color-attribute

Conversation

@Chessing234

Copy link
Copy Markdown

Problem

Text("test", color=WHITE).get_color() returns #000000, not #FFFFFF (#4817). The color is baked into the glyph SVGs during rendering, but the parent mobject keeps its default fill, so get_color() (which reads the parent fill) ignores the constructor argument. set_color() after construction works, which is the inconsistency users hit.

Fix

After init, set the parent mobject's fill/stroke to the parsed color with family=False, so per-character t2c/gradient colors on the glyphs are preserved while get_color() reports the right value. Applied to both Text and MarkupText.

Closes #4817.

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 ManimCommunity#4817.
@Chessing234

Copy link
Copy Markdown
Author

Closing as duplicate of #4844, which already fixes this and adds a regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text color attribute ignored on constructions

1 participant