From 7c04edcced38eea1046b934aa853e8500c4b3af9 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Fri, 15 Jan 2021 23:39:24 +0800 Subject: [PATCH] improve Text's size --- example_scenes.py | 4 ++-- manimlib/mobject/svg/text_mobject.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/example_scenes.py b/example_scenes.py index c38599f4..510a09b3 100644 --- a/example_scenes.py +++ b/example_scenes.py @@ -108,13 +108,13 @@ class TextExample(Scene): def construct(self): # 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 - text = Text("Here is a text", font="Consolas", size=2) + text = Text("Here is a text", font="Consolas", font_size=90) difference = Text( """ 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 """, - font="Arial", size=0.5, + font="Arial", font_size=24, # t2c is a dict that you can choose color for different text t2c={"Text": BLUE, "TextMobject": BLUE, "LaTeX": ORANGE} ) diff --git a/manimlib/mobject/svg/text_mobject.py b/manimlib/mobject/svg/text_mobject.py index baeb33b4..1a42eea0 100644 --- a/manimlib/mobject/svg/text_mobject.py +++ b/manimlib/mobject/svg/text_mobject.py @@ -9,7 +9,7 @@ from manimlib.utils.config_ops import digest_config 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 @@ -36,6 +36,7 @@ class Text(SVGMobject): 'gradient': None, 'lsh': -1, 'size': 1, + 'font_size': 48, 'slant': NORMAL, 'weight': NORMAL, 't2c': {}, @@ -64,7 +65,7 @@ class Text(SVGMobject): # anti-aliasing 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): with open(file_name, 'r') as fpr: