improve Text's size

This commit is contained in:
Tony031218 2021-01-15 23:39:24 +08:00
parent 97ecfcda9b
commit 7c04edcced
2 changed files with 5 additions and 4 deletions

View file

@ -108,13 +108,13 @@ class TextExample(Scene):
def construct(self): def construct(self):
# To run this scene properly, you should have "Consolas" font in your computer # To run this scene properly, you should have "Consolas" font in your computer
# for full usage, you can see https://github.com/3b1b/manim/pull/680 # for full usage, you can see https://github.com/3b1b/manim/pull/680
text = Text("Here is a text", font="Consolas", size=2) text = Text("Here is a text", font="Consolas", font_size=90)
difference = Text( difference = Text(
""" """
The most important difference between Text and TextMobject is that\n The most important difference between Text and TextMobject is that\n
you can change the font more easily, but can't use the LaTeX gramma you can change the font more easily, but can't use the LaTeX gramma
""", """,
font="Arial", size=0.5, font="Arial", font_size=24,
# t2c is a dict that you can choose color for different text # t2c is a dict that you can choose color for different text
t2c={"Text": BLUE, "TextMobject": BLUE, "LaTeX": ORANGE} t2c={"Text": BLUE, "TextMobject": BLUE, "LaTeX": ORANGE}
) )

View file

@ -9,7 +9,7 @@ from manimlib.utils.config_ops import digest_config
from manimlib.utils.directories import get_text_dir from manimlib.utils.directories import get_text_dir
TEXT_MOB_SCALE_FACTOR = 0.05 TEXT_MOB_SCALE_FACTOR = 0.001048
# Warning, these classes are currently based on an old rendering mode # Warning, these classes are currently based on an old rendering mode
@ -36,6 +36,7 @@ class Text(SVGMobject):
'gradient': None, 'gradient': None,
'lsh': -1, 'lsh': -1,
'size': 1, 'size': 1,
'font_size': 48,
'slant': NORMAL, 'slant': NORMAL,
'weight': NORMAL, 'weight': NORMAL,
't2c': {}, 't2c': {},
@ -64,7 +65,7 @@ class Text(SVGMobject):
# anti-aliasing # anti-aliasing
if self.height is None: if self.height is None:
self.scale(TEXT_MOB_SCALE_FACTOR) self.scale(TEXT_MOB_SCALE_FACTOR * self.font_size)
def remove_last_M(self, file_name): def remove_last_M(self, file_name):
with open(file_name, 'r') as fpr: with open(file_name, 'r') as fpr: