3b1b / 3b1b/manim

Hi, How can I configure the tex_template to write Arabic In Manim?

未關閉
#1,241 9 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
93.9k
分支
7.7k
平均合併
2 天 13 小時
30 天內合併 PR
4

描述

I want to display the text `"عشق"` in Manim.

This issue is pretty similar to #840

I have tried to do what was suggested for this issue (#840 that is) but I was unable to make it work.

1. Firstly, I changed TEX_USE_CTEX in manimlib/constants.py to True.

2. Then I changed the file ctex_template.tex as follows:

The original ctex_template.tex file was:
```tex
\documentclass[preview]{standalone}

\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
%\DisableLigatures{encoding = *, family = * }
\usepackage[UTF8]{ctex}
\linespread{1}

\begin{document}

YourTextHere

\end{document}
```

I have change it to:
```tex
\documentclass[preview]{standalone}

%\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
%\DisableLigatures{encoding = *, family = * }
\usepackage[UTF8]{ctex}
%\linespread{1}

\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\englishfont[Scale=MatchLowercase]{Linux Biolinum O}
\newfontfamily\arabicfont{Droid Arabic Naskh}

\begin{document}

YourTextHere

\end{document}
```
3. After this I tried rendering the following scene:

```python
class Test(Scene):
def construct(self):
text = TextMobject("عشق", font="Droid Arabic Naskh")
self.add(text)
```

I got the following error:

Traceback (most recent call last):
File "/Users/sameedmac/PycharmProjects/ManimPyCharmTrial/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/Users/sameedmac/PycharmProjects/ManimPyCharmTrial/manim/manimlib/scene/scene.py", line 75, in __init__
self.construct()
File "/Users/sameedmac/Desktop/ManimTemplatePyCharm/main.py", line 15, in construct
text = TextMobject("عشق", font="Droid Arabic Naskh")
File "/Users/sameedmac/PycharmProjects/ManimPyCharmTrial/manim/manimlib/mobject/svg/tex_mobject.py", line 147, in __init__
SingleStringTexMobject.__init__(
File "/Users/sameedmac/PycharmProjects/ManimPyCharmTrial/manim/manimlib/mobject/svg/tex_mobject.py", line 42, in __init__
file_name = tex_to_svg_file(
File "/Users/sameedmac/PycharmProjects/ManimPyCharmTrial/manim/manimlib/utils/tex_file_writing.py", line 21, in tex_to_svg_file
dvi_file = tex_to_dvi(tex_file)
File "/Users/sameedmac/PycharmProjects/ManimPyCharmTrial/manim/manimlib/utils/tex_file_writing.py", line 69, in tex_to_dvi
raise Exception(
Exception: Latex error converting to dvi. See log output above or the log file: media/Tex/1fdc1280131ec656.log

Process finished with exit code 0

I am not sure what I am supposed to do now. Any help with this issue would be great.
Thank you:)

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

此問題涉及在 Manim 中為阿拉伯文配置 tex_template。先檢查 manimlib/constants.py 中的 TEX_USE_CTEX 與 ctex_template.tex 檔案。查看 media/Tex/1fdc1280131ec656.log 的錯誤日誌以理解 LaTeX 失敗。查看 TextMobject 如何處理字型以及 manimlib/utils/tex_file_writing.py 中的 tex_to_svg_file 函式。完成後看起來像是成功渲染阿拉伯文且沒有 LaTeX 錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
latex
領域
internationalization
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。