ManimPango 0.4.3__cp38-cp38-win32.whl → 1.0.0a2__cp38-cp38-win32.whl
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.
- {ManimPango-0.4.3.dist-info → ManimPango-1.0.0a2.dist-info}/METADATA +2 -2
- ManimPango-1.0.0a2.dist-info/RECORD +85 -0
- {ManimPango-0.4.3.dist-info → ManimPango-1.0.0a2.dist-info}/WHEEL +1 -1
- manimpango/__init__.py +5 -7
- manimpango/_distributor_init.py +36 -0
- manimpango/_version.py +1 -1
- manimpango/attributes/__init__.py +324 -0
- manimpango/attributes/attributes.pxi +219 -0
- manimpango/buffer.pxi +15 -0
- manimpango/cmanimpango.c +10025 -0
- manimpango/cmanimpango.cp38-win32.pyd +0 -0
- manimpango/enums.c +3721 -0
- manimpango/enums.cp38-win32.pyd +0 -0
- manimpango/enums.pyx +1 -10
- manimpango/exceptions.py +5 -0
- manimpango/fonts/__init__.py +153 -0
- manimpango/fonts/_font_desc.c +7576 -0
- manimpango/fonts/_font_desc.cp38-win32.pyd +0 -0
- manimpango/fonts/_font_desc.pxd +5 -0
- manimpango/fonts/_font_desc.pyi +25 -0
- manimpango/fonts/_font_desc.pyx +114 -0
- manimpango/fonts/enums.c +3628 -0
- manimpango/fonts/enums.cp38-win32.pyd +0 -0
- manimpango/fonts/enums.pyi +23 -0
- manimpango/fonts/enums.pyx +84 -0
- manimpango/{cairo.pxd → include/cairo.pxd} +21 -0
- manimpango/include/glib.pxd +36 -0
- manimpango/{pango.pxd → include/pango.pxd} +61 -0
- manimpango/include/pango_attributes.pxd +184 -0
- manimpango/layout/__init__.py +266 -0
- manimpango/layout/_layout.c +8630 -0
- manimpango/layout/_layout.cp38-win32.pyd +0 -0
- manimpango/layout/_layout.pyx +60 -0
- manimpango/layout/layout.pxi +52 -0
- manimpango/register_font.c +5016 -0
- manimpango/register_font.cp38-win32.pyd +0 -0
- manimpango/renderer/__init__.py +5 -0
- manimpango/renderer/cairo_utils.pxi +72 -0
- manimpango/renderer/image_renderer.c +12319 -0
- manimpango/renderer/image_renderer.cp38-win32.pyd +0 -0
- manimpango/renderer/image_renderer.pxd +23 -0
- manimpango/renderer/image_renderer.pyi +21 -0
- manimpango/renderer/image_renderer.pyx +219 -0
- manimpango/renderer/svg_renderer.c +10671 -0
- manimpango/renderer/svg_renderer.cp38-win32.pyd +0 -0
- manimpango/renderer/svg_renderer.pxd +23 -0
- manimpango/renderer/svg_renderer.pyi +17 -0
- manimpango/renderer/svg_renderer.pyx +174 -0
- manimpango/utils/__init__.py +3 -0
- manimpango/utils/_utils.cp38-win32.pyd +0 -0
- manimpango/utils/_utils.pyi +2 -0
- manimpango/utils/utils.c +3533 -0
- manimpango/{utils.py → utils/utils.py} +3 -1
- manimpango/utils/utils.pyx +27 -0
- ManimPango-0.4.3.dist-info/RECORD +0 -44
- manimpango/glib.pxd +0 -13
- {ManimPango-0.4.3.dist-info → ManimPango-1.0.0a2.dist-info}/LICENSE +0 -0
- {ManimPango-0.4.3.dist-info → ManimPango-1.0.0a2.dist-info}/LICENSE.win32 +0 -0
- {ManimPango-0.4.3.dist-info → ManimPango-1.0.0a2.dist-info}/top_level.txt +0 -0
- /manimpango/{CORE_MANIM_cairo-2.dll → .libs/CORE_MANIM_cairo-2.dll} +0 -0
- /manimpango/{CORE_MANIM_cairo-gobject-2.dll → .libs/CORE_MANIM_cairo-gobject-2.dll} +0 -0
- /manimpango/{CORE_MANIM_cairo-script-interpreter-2.dll → .libs/CORE_MANIM_cairo-script-interpreter-2.dll} +0 -0
- /manimpango/{CORE_MANIM_expat.dll → .libs/CORE_MANIM_expat.dll} +0 -0
- /manimpango/{CORE_MANIM_ffi-7.dll → .libs/CORE_MANIM_ffi-7.dll} +0 -0
- /manimpango/{CORE_MANIM_fontconfig-1.dll → .libs/CORE_MANIM_fontconfig-1.dll} +0 -0
- /manimpango/{CORE_MANIM_freetype-6.dll → .libs/CORE_MANIM_freetype-6.dll} +0 -0
- /manimpango/{CORE_MANIM_fribidi-0.dll → .libs/CORE_MANIM_fribidi-0.dll} +0 -0
- /manimpango/{CORE_MANIM_gio-2.0-0.dll → .libs/CORE_MANIM_gio-2.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_glib-2.0-0.dll → .libs/CORE_MANIM_glib-2.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_gmodule-2.0-0.dll → .libs/CORE_MANIM_gmodule-2.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_gobject-2.0-0.dll → .libs/CORE_MANIM_gobject-2.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_gthread-2.0-0.dll → .libs/CORE_MANIM_gthread-2.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_harfbuzz-gobject.dll → .libs/CORE_MANIM_harfbuzz-gobject.dll} +0 -0
- /manimpango/{CORE_MANIM_harfbuzz-subset.dll → .libs/CORE_MANIM_harfbuzz-subset.dll} +0 -0
- /manimpango/{CORE_MANIM_harfbuzz.dll → .libs/CORE_MANIM_harfbuzz.dll} +0 -0
- /manimpango/{CORE_MANIM_intl-8.dll → .libs/CORE_MANIM_intl-8.dll} +0 -0
- /manimpango/{CORE_MANIM_pango-1.0-0.dll → .libs/CORE_MANIM_pango-1.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_pangocairo-1.0-0.dll → .libs/CORE_MANIM_pangocairo-1.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_pangoft2-1.0-0.dll → .libs/CORE_MANIM_pangoft2-1.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_pangowin32-1.0-0.dll → .libs/CORE_MANIM_pangowin32-1.0-0.dll} +0 -0
- /manimpango/{CORE_MANIM_pixman-1-0.dll → .libs/CORE_MANIM_pixman-1-0.dll} +0 -0
- /manimpango/{CORE_MANIM_png16-16.dll → .libs/CORE_MANIM_png16-16.dll} +0 -0
- /manimpango/{CORE_MANIM_z.dll → .libs/CORE_MANIM_z.dll} +0 -0
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
from cairo cimport *
|
2
|
+
from glib cimport *
|
3
|
+
from pango cimport *
|
4
|
+
|
5
|
+
from ..fonts import FontDescription
|
6
|
+
from ..layout import Layout
|
7
|
+
|
8
|
+
|
9
|
+
cdef class SVGRenderer:
|
10
|
+
cdef cairo_surface_t* cairo_surface
|
11
|
+
cdef cairo_t* cairo_context
|
12
|
+
cdef PangoLayout* pango_layout
|
13
|
+
cdef PangoFontDescription* pango_font_desc
|
14
|
+
cdef PangoAttrList* pango_attr_list
|
15
|
+
|
16
|
+
cdef str _file_name
|
17
|
+
cdef float _width
|
18
|
+
cdef float _height
|
19
|
+
cdef object py_layout
|
20
|
+
cdef object py_font_desc
|
21
|
+
|
22
|
+
cdef bint start_renderering(self)
|
23
|
+
cpdef bint render(self)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from ..layout import Layout
|
2
|
+
|
3
|
+
class SVGRenderer:
|
4
|
+
def __init__(
|
5
|
+
self,
|
6
|
+
width: int,
|
7
|
+
height: int,
|
8
|
+
layout: Layout,
|
9
|
+
file_name: str,
|
10
|
+
): ...
|
11
|
+
@property
|
12
|
+
def file_name(self) -> str: ...
|
13
|
+
@property
|
14
|
+
def width(self) -> float: ...
|
15
|
+
def height(self) -> float: ...
|
16
|
+
def render(self) -> bool: ...
|
17
|
+
def save(self, file_name: str = None) -> str: ...
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import typing as T
|
2
|
+
|
3
|
+
from ..layout import Layout
|
4
|
+
|
5
|
+
include "cairo_utils.pxi"
|
6
|
+
|
7
|
+
cdef class SVGRenderer:
|
8
|
+
""":class:`SVGRenderer` is a renderer which renders the
|
9
|
+
:class:`~.Layout` to an SVG file. Note that unlike other renderers
|
10
|
+
the :attr:`file_name` is a required parameter.
|
11
|
+
|
12
|
+
The :attr:`file_name` is opened when the class is initialised
|
13
|
+
and only closed when the renderer is destroyed.
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
==========
|
17
|
+
width: :class:`float`
|
18
|
+
The width of the SVG.
|
19
|
+
height: :class:`float`
|
20
|
+
The height of the SVG.
|
21
|
+
layout: :class:`Layout`
|
22
|
+
The :class:`~.Layout` that needs to be rendered.
|
23
|
+
file_name: :class:`str`
|
24
|
+
The path to SVG file.
|
25
|
+
|
26
|
+
Example
|
27
|
+
=======
|
28
|
+
>>> import manimpango as mp
|
29
|
+
>>> a = mp.SVGRenderer(100, 100, mp.Layout('hello'), 'test.svg')
|
30
|
+
>>> a
|
31
|
+
<SVGRenderer file_name='test.svg' width=100.0 height=100.0 layout=<Layout text='hello' markup=None>
|
32
|
+
>>> a.render()
|
33
|
+
True
|
34
|
+
>>> a.save()
|
35
|
+
'test.svg'
|
36
|
+
|
37
|
+
Raises
|
38
|
+
======
|
39
|
+
Exception
|
40
|
+
Any error reported by cairo.
|
41
|
+
"""
|
42
|
+
def __cinit__(
|
43
|
+
self,
|
44
|
+
width: float,
|
45
|
+
height: float,
|
46
|
+
layout: Layout,
|
47
|
+
file_name: str,
|
48
|
+
):
|
49
|
+
surface = cairo_svg_surface_create(
|
50
|
+
file_name.encode("utf-8"),
|
51
|
+
width,
|
52
|
+
height
|
53
|
+
)
|
54
|
+
if surface == NULL:
|
55
|
+
raise MemoryError("Cairo.SVGSurface can't be created.")
|
56
|
+
self.cairo_surface = surface
|
57
|
+
self.cairo_context = create_cairo_context_from_surface(surface)
|
58
|
+
self.pango_layout = create_pango_layout(self.cairo_context)
|
59
|
+
self.pango_font_desc = create_font_desc()
|
60
|
+
self.pango_attr_list = create_attr_list()
|
61
|
+
|
62
|
+
def __init__(
|
63
|
+
self,
|
64
|
+
width: float,
|
65
|
+
height: float,
|
66
|
+
layout: Layout,
|
67
|
+
file_name: str,
|
68
|
+
):
|
69
|
+
self._file_name = file_name
|
70
|
+
self._width = width
|
71
|
+
self._height = height
|
72
|
+
self.py_layout = layout
|
73
|
+
self.py_font_desc = layout.font_desc
|
74
|
+
|
75
|
+
cdef bint start_renderering(self):
|
76
|
+
pylayout_to_pango_layout(
|
77
|
+
self.pango_layout,
|
78
|
+
self.py_layout,
|
79
|
+
self.pango_attr_list
|
80
|
+
)
|
81
|
+
|
82
|
+
pyfontdesc_to_pango_font_desc(self.pango_font_desc, self.py_font_desc)
|
83
|
+
pango_layout_set_font_description(
|
84
|
+
self.pango_layout,
|
85
|
+
self.pango_font_desc
|
86
|
+
)
|
87
|
+
# Check if the context is fine
|
88
|
+
_err = is_context_fine(self.cairo_context)
|
89
|
+
if _err != "":
|
90
|
+
raise Exception(_err)
|
91
|
+
|
92
|
+
# Assign the font description to the layout
|
93
|
+
pango_layout_set_font_description(self.pango_layout,
|
94
|
+
self.pango_font_desc)
|
95
|
+
|
96
|
+
# Render the actual layout into the cairo context
|
97
|
+
pango_cairo_show_layout(self.cairo_context,
|
98
|
+
self.pango_layout)
|
99
|
+
|
100
|
+
# Check if the context is fine again
|
101
|
+
_err = is_context_fine(self.cairo_context)
|
102
|
+
if _err != "":
|
103
|
+
raise Exception(_err)
|
104
|
+
return 1
|
105
|
+
|
106
|
+
cpdef bint render(self):
|
107
|
+
""":meth:`render` actually does the rendering.
|
108
|
+
Any error reported by Cairo is reported as an exception.
|
109
|
+
If this method suceeds you can expect an valid SVG file at
|
110
|
+
:attr:`file_name`.
|
111
|
+
|
112
|
+
Returns
|
113
|
+
=======
|
114
|
+
bool
|
115
|
+
``True`` if the function worked, else ``False``.
|
116
|
+
"""
|
117
|
+
return self.start_renderering()
|
118
|
+
|
119
|
+
def save(self, file_name: T.Optional[str] = None) -> str:
|
120
|
+
"""This method save's the SVG file. Note that this method
|
121
|
+
is provided for compatibility with other renderers and does
|
122
|
+
nothing.
|
123
|
+
|
124
|
+
Parameters
|
125
|
+
==========
|
126
|
+
file_name:
|
127
|
+
The filename to save the file. Note that this is not used
|
128
|
+
and instead only :attr:`file_name` is used
|
129
|
+
|
130
|
+
Returns
|
131
|
+
=======
|
132
|
+
str
|
133
|
+
The filename of the rendered SVG file.
|
134
|
+
"""
|
135
|
+
return self.file_name
|
136
|
+
|
137
|
+
def __repr__(self) -> str:
|
138
|
+
return (f"<SVGRenderer file_name={repr(self.file_name)}"
|
139
|
+
f" width={repr(self.width)}"
|
140
|
+
f" height={repr(self.height)}"
|
141
|
+
f" layout={repr(self.layout)}")
|
142
|
+
|
143
|
+
def __dealloc__(self):
|
144
|
+
if self.pango_attr_list:
|
145
|
+
pango_attr_list_unref(self.pango_attr_list)
|
146
|
+
if self.pango_layout:
|
147
|
+
g_object_unref(self.pango_layout)
|
148
|
+
if self.cairo_context:
|
149
|
+
cairo_destroy(self.cairo_context)
|
150
|
+
if self.cairo_surface:
|
151
|
+
cairo_surface_destroy(self.cairo_surface)
|
152
|
+
if self.pango_font_desc:
|
153
|
+
pango_font_description_free(self.pango_font_desc)
|
154
|
+
|
155
|
+
@property
|
156
|
+
def file_name(self) -> str:
|
157
|
+
"""The file_name where the file is rendered onto"""
|
158
|
+
return self._file_name
|
159
|
+
|
160
|
+
@property
|
161
|
+
def width(self) -> float:
|
162
|
+
"""The width of the SVG."""
|
163
|
+
return self._width
|
164
|
+
|
165
|
+
@property
|
166
|
+
def height(self) -> float:
|
167
|
+
"""The height of the SVG."""
|
168
|
+
return self._height
|
169
|
+
|
170
|
+
@property
|
171
|
+
def layout(self) -> Layout:
|
172
|
+
"""The :class:`~.Layout` which is being rendered.
|
173
|
+
"""
|
174
|
+
return self.py_layout
|
Binary file
|