Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Pesian/Farsi language for using inside TexText class. by creating a .tex template and an example #1758

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions example_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,5 +670,48 @@ def text_updater(old_text):
# self.wait(60)
# self.embed()

class WritePersianExample(Scene):
"""
This is the simplest and basic form of implementing Persian/Farsi Language for manim library.

User needs to make some changes in

default_config.yml file like this:
tex:
executable: "xelatex -no-pdf"
template_file: "ftex_template.tex"
intermediate_filetype: "xdv"
text_to_replace: "[tex_expression]"

and
User need to have "HM XNiloofar" font in his computer or any desired persian font in HM family.
"""

def construct(self):
rtarrow0 = Tex(r"X^{20} + 123456", font_size=96).to_edge(UP)
rtarrow1 = TexText(
r"""
\lr{Hello World}

سلام دنیا

$x^2 + y^2 = z^2$

""",
font_size=96,
)
self.add(rtarrow0)
self.add(rtarrow1)

source = TexText("سلام علیکم", height=1).to_edge(DOWN)
target = TexText("علی سالم است", height=1).to_edge(DOWN)

self.play(Write(source))
self.wait()
kw = {"run_time": 3, "path_arc": PI / 2}
self.play(TransformMatchingShapes(source, target, **kw))
self.wait()
self.play(TransformMatchingShapes(target, source, **kw))
self.wait()

# See https://github.com/3b1b/videos for many, many more
8 changes: 4 additions & 4 deletions manimlib/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ directories:
# specify them elsewhere,
temporary_storage: ""
tex:
executable: "latex"
template_file: "tex_template.tex"
intermediate_filetype: "dvi"
executable: "xelatex -no-pdf"
template_file: "ftex_template.tex"
intermediate_filetype: "xdv"
text_to_replace: "[tex_expression]"
# For ctex, use the following configuration
# For ctex, xepersian use the following configuration
# executable: "xelatex -no-pdf"
# template_file: "ctex_template.tex"
# intermediate_filetype: "xdv"
Expand Down
28 changes: 28 additions & 0 deletions manimlib/tex_templates/ftex_template.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
\documentclass[preview]{standalone}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage[localise]{xepersian}
\settextfont{HM XNiloofar}


\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}

\usepackage{microtype}
\linespread{1}


\begin{document}

[tex_expression]

\end{document}