Move pangoText example from example script to Docs (#533)

* moved pangoText example to docs

* Update text_mobject.py

* Update text_mobject.py

fix docsting
This commit is contained in:
kolibril13 2020-10-12 18:09:33 +02:00 committed by GitHub
commit e0d62d7388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 43 deletions

View file

@ -1,41 +0,0 @@
from manim import *
class PangoRendering(Scene):
CONFIG = {"font": "sans-serif"}
def construct(self):
morning = PangoText("வணக்கம்", font="sans-serif")
self.play(Write(morning))
self.wait(3)
self.clear()
chin = PangoText(
"見 角 言 谷 辛 辰 辵 邑 酉 釆 里!", t2c={"見 角 言": BLUE}
) # works same as ``Text``.
self.play(Write(chin))
self.wait(2)
mess = PangoText("Multi-Language", style=BOLD)
self.play(Transform(chin, mess))
self.wait(2)
self.clear()
russ = PangoText("Здравствуйте मस नम म ", font="sans-serif")
self.play(Write(russ))
self.wait(2)
self.clear()
hin = PangoText("नमस्ते", font="sans-serif")
self.play(Write(hin))
self.wait(2)
self.clear()
arb = PangoText("صباح الخير ", font="sans-serif")
self.play(Write(arb))
self.wait(3)
self.clear()
arb = PangoText(
"صباح الخير \n تشرفت بمقابلتك", font="sans-serif"
) # don't mix RTL and LTR languages nothing shows up then ;-)
self.play(Write(arb))
self.wait(3)
self.clear()
jap = PangoText("臂猿「黛比」帶著孩子", font="sans-serif")
self.play(Write(jap))
self.wait(3)

View file

@ -582,7 +582,7 @@ class Paragraph(VGroup):
class PangoText(SVGMobject):
"""Display (non-LaTeX) text rendered using `Pango <https://pango.gnome.org/>`_.
r"""Display (non-LaTeX) text rendered using `Pango <https://pango.gnome.org/>`_.
PangoText objects behave like a :class:`.VGroup`-like iterable of all characters
in the given text. In particular, slicing is possible.
@ -598,7 +598,28 @@ class PangoText(SVGMobject):
The mobject like :class:`.VGroup`.
Examples
--------
---------
.. manim:: MultipleFonts
:save_last_frame:
class MultipleFonts(Scene):
def construct(self):
morning = PangoText("வணக்கம்", font="sans-serif")
chin = PangoText(
"見 角 言 谷 辛 辰 辵 邑 酉 釆 里!", t2c={"見 角 言": BLUE}
) # works same as ``Text``.
mess = PangoText("Multi-Language", style=BOLD)
russ = PangoText("Здравствуйте मस नम म ", font="sans-serif")
hin = PangoText("नमस्ते", font="sans-serif")
arb = PangoText(
"صباح الخير \n تشرفت بمقابلتك", font="sans-serif"
) # don't mix RTL and LTR languages nothing shows up then ;-)
japanese = PangoText("臂猿「黛比」帶著孩子", font="sans-serif")
self.add(morning,chin,mess,russ,hin,arb,japanese)
for i,mobj in enumerate(self.mobjects):
mobj.shift(DOWN*(i-3))
.. manim:: PangoRender
:quality: low