question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to choose a font with Text object?

See original GitHub issue

This code does not change the font and letter become distorted (click on the image to enlarge and look at letters: B, D, f, g, P, U...):

script = '''
AaBbCcDdEeFfGg
HhIiJjKkLlMmNn
OoPpQqRrSsTtUu
VvWwXxYyZz
'''

class WriteText(Scene):
  def construct(self):
    text = Text(script, font='/usr/share/fonts/truetype/open-sans/OpenSans-Regular.ttf')
    self.play(Write(text))
    self.wait(.1)

!python3 -m manim example_scenes.py WriteText -r 480,854 image

If I change this line the result is kind of similar to the target, but I can’t choose regular and letters are distorted (look at the small g it has a stair on the top): text = Text(script, font="Open Sans") image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:48 (25 by maintainers)

github_iconTop GitHub Comments

1reaction
xy-23commented, Feb 29, 2020
from manimlib.imports import *

class Demo(Scene):
    def construct(self):
        svg = SVGMobject(file_name='temp.svg', stroke_color=BLUE)
        self.play(Write(svg))
        

res

1reaction
xy-23commented, Feb 21, 2020

The Text mobject is based on an other package called pycario, which only support for this way and it doesn’t support to use the font file directly, but I do find some way to use the font file directly, and I need to do some research which takes some time.

I doesn’t think it is a bug, it is just doesn’t support this feature at all.

So until I can finish this feature to Text mobject, you need to use the way I gave above.

Or you maybe you can try to write a function by yourself, I found that freetype-py dose support the way you want, but it needs some code to be integrated into manim.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fundamental text and font styling - Learn web development
To set a different font for your text, you use the font-family property — this allows you to specify a font (or list...
Read more >
How to Change Fonts for 3D Text - Blender Text Tutorial
... Learn Video Editing - Complete Guide to DaVinci Resolve Course ($5 Off) Basics of editing text objects within Blender 2.77 ...
Read more >
How to change font for text objects? - Blender Stack Exchange
You can change the font used for a text object under the Object Data properties panel. enter image description here.
Read more >
[SOLVED] How to change the font for every text object?
if you are just trying to change all the fonts in a scene you could use search by type and put in "text"....
Read more >
Different font and style in qlikview text object - Qlik Community
I want to show a Qlikview text object where some fonts are bold and different font type and other is different font type....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found