manim-fa 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
manim_fa-0.1.0/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ton Nom
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software...
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include manim_fa *.py
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: manim-fa
3
+ Version: 0.1.0
4
+ Summary: Plugin Manim pour le texte persan (RTL) avec translittération
5
+ Author-email: Ton Nom <ton.email@example.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/tonpseudo/manim-fa
8
+ Project-URL: Repository, https://github.com/tonpseudo/manim-fa
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: manim
13
+ Dynamic: license-file
14
+
15
+ # manim-fa
16
+
17
+ Plugin Manim pour le texte persan (RTL) avec translittération automatique.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install manim-fa
23
+ ```
24
+
25
+ ## Utilisation
26
+
27
+ ```python
28
+ from manim import *
29
+ from manim_fa import create_fa_text
30
+
31
+ class Demo(Scene):
32
+ def construct(self):
33
+ # Texte persan direct
34
+ t1 = create_fa_text("سلام دنیا!", color="BLUE", font_size=70)
35
+
36
+ # Texte translittéré
37
+ t2 = create_fa_text("salam manim fa", translit=True, color="GREEN", font_size=70)
38
+
39
+ self.play(Write(t1))
40
+ self.play(Transform(t1, t2))
41
+ self.wait(2)
42
+ ```
43
+
44
+ ## Alignement RTL
45
+ Pour gérer plusieurs lignes :
46
+
47
+ ```python
48
+ from manim_fa.layout import arrange_rtl
49
+ text_group = VGroup(line1, line2, line3)
50
+ arrange_rtl(text_group)
51
+ ```
@@ -0,0 +1,37 @@
1
+ # manim-fa
2
+
3
+ Plugin Manim pour le texte persan (RTL) avec translittération automatique.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install manim-fa
9
+ ```
10
+
11
+ ## Utilisation
12
+
13
+ ```python
14
+ from manim import *
15
+ from manim_fa import create_fa_text
16
+
17
+ class Demo(Scene):
18
+ def construct(self):
19
+ # Texte persan direct
20
+ t1 = create_fa_text("سلام دنیا!", color="BLUE", font_size=70)
21
+
22
+ # Texte translittéré
23
+ t2 = create_fa_text("salam manim fa", translit=True, color="GREEN", font_size=70)
24
+
25
+ self.play(Write(t1))
26
+ self.play(Transform(t1, t2))
27
+ self.wait(2)
28
+ ```
29
+
30
+ ## Alignement RTL
31
+ Pour gérer plusieurs lignes :
32
+
33
+ ```python
34
+ from manim_fa.layout import arrange_rtl
35
+ text_group = VGroup(line1, line2, line3)
36
+ arrange_rtl(text_group)
37
+ ```
@@ -0,0 +1,6 @@
1
+ from .text import create_fa_text
2
+ from .scenes import FaTextScene
3
+ from .translit import translit_to_fa
4
+ from .layout import arrange_rtl, justify_rtl_lines
5
+
6
+ __all__ = ["create_fa_text", "FaTextScene", "translit_to_fa", "arrange_rtl", "justify_rtl_lines"]
@@ -0,0 +1,24 @@
1
+ import os
2
+ import platform
3
+ from pathlib import Path
4
+
5
+ _DEFAULT_FONTS = ["IRLotus", "XB Niloofar", "Vazir", "Tahoma"]
6
+
7
+ def _font_installed(font_name: str) -> bool:
8
+ system = platform.system()
9
+ if system == "Windows":
10
+ font_dir = Path("C:/Windows/Fonts")
11
+ elif system == "Darwin":
12
+ font_dir = Path("/Library/Fonts")
13
+ else:
14
+ font_dir = Path("/usr/share/fonts")
15
+
16
+ return any(font_name.lower() in f.name.lower() for f in font_dir.glob("**/*"))
17
+
18
+ def get_persian_font(preferred: str | None = None) -> str:
19
+ candidates = [preferred] + _DEFAULT_FONTS if preferred else _DEFAULT_FONTS
20
+ for font in candidates:
21
+ if font and _font_installed(font):
22
+ return font
23
+ print("[manim-fa] ⚠️ Aucune police persane trouvée, utilisation de 'Arial'.")
24
+ return "Arial"
@@ -0,0 +1,11 @@
1
+ from manim import VGroup, RIGHT, LEFT, DOWN
2
+
3
+ def arrange_rtl(text_group: VGroup, spacing=0.3):
4
+ text_group.submobjects = list(reversed(text_group.submobjects))
5
+ text_group.arrange(RIGHT, buff=spacing)
6
+ return text_group
7
+
8
+ def justify_rtl_lines(lines: list, line_spacing=0.4):
9
+ group = VGroup(*lines)
10
+ group.arrange(LEFT, buff=line_spacing)
11
+ return group
@@ -0,0 +1,12 @@
1
+ from manim import Scene, VGroup, DOWN, UP, FadeIn, Write, ScaleInPlace, PI
2
+ from .text import create_fa_text
3
+
4
+ class FaTextScene(Scene):
5
+ def construct(self):
6
+ line1 = create_fa_text("اولین انیمیشن فارسی", color="BLUE", font_size=70)
7
+ line2 = create_fa_text("در حال ایجاد افزونه", translit=True, color="GREEN", font_size=70)
8
+ line3 = create_fa_text("این خط ایتالیک است", color="RED", font_size=70, slant="ITALIC")
9
+
10
+ text_group = VGroup(line1, line2, line3).arrange(DOWN).shift(UP)
11
+ self.play(FadeIn(text_group))
12
+ self.wait(2)
@@ -0,0 +1,31 @@
1
+ from manim import Text, VGroup
2
+ from .fonts import get_persian_font
3
+ from .translit import translit_to_fa
4
+ from .layout import arrange_rtl
5
+
6
+ def create_fa_text(
7
+ content,
8
+ font=None,
9
+ font_size=48,
10
+ color="WHITE",
11
+ weight=None,
12
+ slant=None,
13
+ translit=False,
14
+ rtl=True,
15
+ **kwargs
16
+ ):
17
+ if translit:
18
+ content = translit_to_fa(content)
19
+
20
+ font = get_persian_font(font)
21
+ text = Text(content, font=font, font_size=font_size, color=color, **kwargs)
22
+
23
+ if weight:
24
+ text.set_weight(weight)
25
+ if slant:
26
+ text.set_slant(slant)
27
+
28
+ if rtl:
29
+ text.submobjects.reverse()
30
+
31
+ return text
@@ -0,0 +1,13 @@
1
+ LATIN_TO_PERSIAN = {
2
+ "kh": "خ", "gh": "غ", "ch": "چ", "sh": "ش", "th": "ث",
3
+ "a": "ا", "b": "ب", "c": "ک", "d": "د", "e": "ِ", "f": "ف", "g": "گ",
4
+ "h": "ه", "i": "ی", "j": "ج", "k": "ک", "l": "ل", "m": "م", "n": "ن",
5
+ "o": "و", "p": "پ", "q": "ق", "r": "ر", "s": "س", "t": "ت", "u": "و",
6
+ "v": "و", "w": "و", "x": "کس", "y": "ی", "z": "ز",
7
+ }
8
+
9
+ def translit_to_fa(text: str) -> str:
10
+ result = text.lower()
11
+ for latin, persian in sorted(LATIN_TO_PERSIAN.items(), key=lambda x: -len(x[0])):
12
+ result = result.replace(latin, persian)
13
+ return result
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: manim-fa
3
+ Version: 0.1.0
4
+ Summary: Plugin Manim pour le texte persan (RTL) avec translittération
5
+ Author-email: Ton Nom <ton.email@example.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/tonpseudo/manim-fa
8
+ Project-URL: Repository, https://github.com/tonpseudo/manim-fa
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: manim
13
+ Dynamic: license-file
14
+
15
+ # manim-fa
16
+
17
+ Plugin Manim pour le texte persan (RTL) avec translittération automatique.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install manim-fa
23
+ ```
24
+
25
+ ## Utilisation
26
+
27
+ ```python
28
+ from manim import *
29
+ from manim_fa import create_fa_text
30
+
31
+ class Demo(Scene):
32
+ def construct(self):
33
+ # Texte persan direct
34
+ t1 = create_fa_text("سلام دنیا!", color="BLUE", font_size=70)
35
+
36
+ # Texte translittéré
37
+ t2 = create_fa_text("salam manim fa", translit=True, color="GREEN", font_size=70)
38
+
39
+ self.play(Write(t1))
40
+ self.play(Transform(t1, t2))
41
+ self.wait(2)
42
+ ```
43
+
44
+ ## Alignement RTL
45
+ Pour gérer plusieurs lignes :
46
+
47
+ ```python
48
+ from manim_fa.layout import arrange_rtl
49
+ text_group = VGroup(line1, line2, line3)
50
+ arrange_rtl(text_group)
51
+ ```
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ manim_fa/__init__.py
6
+ manim_fa/fonts.py
7
+ manim_fa/layout.py
8
+ manim_fa/scenes.py
9
+ manim_fa/text.py
10
+ manim_fa/translit.py
11
+ manim_fa.egg-info/PKG-INFO
12
+ manim_fa.egg-info/SOURCES.txt
13
+ manim_fa.egg-info/dependency_links.txt
14
+ manim_fa.egg-info/requires.txt
15
+ manim_fa.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ manim
@@ -0,0 +1 @@
1
+ manim_fa
@@ -0,0 +1,17 @@
1
+ [project]
2
+ name = "manim-fa"
3
+ version = "0.1.0"
4
+ description = "Plugin Manim pour le texte persan (RTL) avec translittération"
5
+ authors = [{name = "Ton Nom", email = "ton.email@example.com"}]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ requires-python = ">=3.9"
9
+ dependencies = ["manim"]
10
+
11
+ [project.urls]
12
+ Homepage = "https://github.com/tonpseudo/manim-fa"
13
+ Repository = "https://github.com/tonpseudo/manim-fa"
14
+
15
+ [build-system]
16
+ requires = ["setuptools>=61.0", "wheel", "twine"]
17
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+