Skip to content

Commit

Permalink
Fix DecimalNumber.set_value font size issue
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Feb 8, 2024
1 parent 45f8ca7 commit c531e56
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions manimlib/mobject/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def __init__(
self.edge_to_fix = edge_to_fix
self.font_size = font_size
self.text_config = dict(text_config)
self.text_config["font_size"] = font_size

super().__init__(
color=color,
Expand Down Expand Up @@ -80,15 +79,18 @@ def set_submobjects_from_number(self, number: float | complex) -> None:
submob_templates.append(self.char_to_mob(self.unit))

# Set internals
font_size = self.get_font_size()
if len(submob_templates) == len(self.submobjects):
for sm, smt in zip(self.submobjects, submob_templates):
sm.become(smt)
sm.scale(font_size / smt.font_size)
else:
self.set_submobjects([smt.copy() for smt in submob_templates])
self.set_submobjects([
smt.copy().scale(font_size / smt.font_size)
for smt in submob_templates
])

font_size = self.get_font_size()
digit_buff = self.digit_buff_per_font_unit * font_size
self.scale(font_size / self.text_config["font_size"])
self.arrange(RIGHT, buff=digit_buff, aligned_edge=DOWN)

# Handle alignment of special characters
Expand Down

0 comments on commit c531e56

Please sign in to comment.