manimpango 0.2.2__tar.gz → 0.2.4__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.
Files changed (32) hide show
  1. ManimPango-0.2.4/MANIFEST.in +4 -0
  2. {ManimPango-0.2.2 → ManimPango-0.2.4/ManimPango.egg-info}/PKG-INFO +2 -12
  3. ManimPango-0.2.4/ManimPango.egg-info/SOURCES.txt +28 -0
  4. {ManimPango-0.2.2/ManimPango.egg-info → ManimPango-0.2.4}/PKG-INFO +2 -12
  5. {ManimPango-0.2.2 → ManimPango-0.2.4}/README.md +1 -11
  6. {ManimPango-0.2.2 → ManimPango-0.2.4}/manimpango/__init__.py +2 -0
  7. {ManimPango-0.2.2 → ManimPango-0.2.4}/manimpango/_version.py +1 -1
  8. ManimPango-0.2.4/manimpango/cairo.pxd +27 -0
  9. ManimPango-0.2.4/manimpango/cmanimpango.pxd +3 -0
  10. ManimPango-0.2.4/manimpango/cmanimpango.pyx +227 -0
  11. ManimPango-0.2.4/manimpango/enums.pyx +92 -0
  12. ManimPango-0.2.4/manimpango/glib.pxd +8 -0
  13. ManimPango-0.2.2/manimpango/cmanimpango.pxd → ManimPango-0.2.4/manimpango/pango.pxd +2 -64
  14. ManimPango-0.2.4/manimpango/register_font.pxd +54 -0
  15. ManimPango-0.2.4/manimpango/register_font.pyx +216 -0
  16. ManimPango-0.2.4/manimpango/utils.py +57 -0
  17. {ManimPango-0.2.2 → ManimPango-0.2.4}/setup.py +11 -1
  18. ManimPango-0.2.4/tests/__init__.py +31 -0
  19. ManimPango-0.2.4/tests/test_fonts.py +79 -0
  20. ManimPango-0.2.4/tests/test_import.py +5 -0
  21. ManimPango-0.2.4/tests/test_list_fonts.py +26 -0
  22. ManimPango-0.2.4/tests/test_markup.py +24 -0
  23. ManimPango-0.2.4/tests/test_version.py +13 -0
  24. ManimPango-0.2.2/MANIFEST.in +0 -1
  25. ManimPango-0.2.2/ManimPango.egg-info/SOURCES.txt +0 -15
  26. ManimPango-0.2.2/manimpango/cmanimpango.pyx +0 -520
  27. {ManimPango-0.2.2 → ManimPango-0.2.4}/LICENSE +0 -0
  28. {ManimPango-0.2.2 → ManimPango-0.2.4}/ManimPango.egg-info/dependency_links.txt +0 -0
  29. {ManimPango-0.2.2 → ManimPango-0.2.4}/ManimPango.egg-info/not-zip-safe +0 -0
  30. {ManimPango-0.2.2 → ManimPango-0.2.4}/ManimPango.egg-info/top_level.txt +0 -0
  31. {ManimPango-0.2.2 → ManimPango-0.2.4}/pyproject.toml +0 -0
  32. {ManimPango-0.2.2 → ManimPango-0.2.4}/setup.cfg +0 -0
@@ -0,0 +1,4 @@
1
+ global-include *.pyx
2
+ recursive-include tests *.py
3
+ prune docs/_build
4
+ recursive-include docs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ManimPango
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Bindings for Pango for using with Manim.
5
5
  Home-page: https://manimpango.manim.community/
6
6
  Author: Naveen M K
@@ -35,17 +35,7 @@ Description: # ManimPango
35
35
  pip install manimpango
36
36
  ```
37
37
 
38
- #### Note:
39
-
40
- For **Linux Users**, installing the binary wheel provided in PyPi may have unexpected side effects.
41
-
42
- For example, a folder named `fontconfig` might be created in the current working directory. That folder would then have a lot of cache files each time you run Manim. In order to avoid this, you will have to install **Manimpango** from source:.
43
-
44
- ```sh
45
- pip install manimpango --no-binary :all:
46
- ```
47
-
48
- Please note that for this kind of installation to work, you must have a C compiler as well as **Pango** and its dependencies along with the **Pango** development headers. See [BUILDING](#BUILDING ) for more information.
38
+ For **Linux Users**, there are no Wheels. You must have a C compiler as well as **Pango** and its dependencies along with the **Pango** development headers. See [BUILDING](#BUILDING) for more information.
49
39
 
50
40
  ## BUILDING
51
41
 
@@ -0,0 +1,28 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ setup.cfg
6
+ setup.py
7
+ ManimPango.egg-info/PKG-INFO
8
+ ManimPango.egg-info/SOURCES.txt
9
+ ManimPango.egg-info/dependency_links.txt
10
+ ManimPango.egg-info/not-zip-safe
11
+ ManimPango.egg-info/top_level.txt
12
+ manimpango/__init__.py
13
+ manimpango/_version.py
14
+ manimpango/cairo.pxd
15
+ manimpango/cmanimpango.pxd
16
+ manimpango/cmanimpango.pyx
17
+ manimpango/enums.pyx
18
+ manimpango/glib.pxd
19
+ manimpango/pango.pxd
20
+ manimpango/register_font.pxd
21
+ manimpango/register_font.pyx
22
+ manimpango/utils.py
23
+ tests/__init__.py
24
+ tests/test_fonts.py
25
+ tests/test_import.py
26
+ tests/test_list_fonts.py
27
+ tests/test_markup.py
28
+ tests/test_version.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ManimPango
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Bindings for Pango for using with Manim.
5
5
  Home-page: https://manimpango.manim.community/
6
6
  Author: Naveen M K
@@ -35,17 +35,7 @@ Description: # ManimPango
35
35
  pip install manimpango
36
36
  ```
37
37
 
38
- #### Note:
39
-
40
- For **Linux Users**, installing the binary wheel provided in PyPi may have unexpected side effects.
41
-
42
- For example, a folder named `fontconfig` might be created in the current working directory. That folder would then have a lot of cache files each time you run Manim. In order to avoid this, you will have to install **Manimpango** from source:.
43
-
44
- ```sh
45
- pip install manimpango --no-binary :all:
46
- ```
47
-
48
- Please note that for this kind of installation to work, you must have a C compiler as well as **Pango** and its dependencies along with the **Pango** development headers. See [BUILDING](#BUILDING ) for more information.
38
+ For **Linux Users**, there are no Wheels. You must have a C compiler as well as **Pango** and its dependencies along with the **Pango** development headers. See [BUILDING](#BUILDING) for more information.
49
39
 
50
40
  ## BUILDING
51
41
 
@@ -23,17 +23,7 @@ Installing **ManimPango** is super easy, just use `pip`. It is [`manimpango`](ht
23
23
  pip install manimpango
24
24
  ```
25
25
 
26
- #### Note:
27
-
28
- For **Linux Users**, installing the binary wheel provided in PyPi may have unexpected side effects.
29
-
30
- For example, a folder named `fontconfig` might be created in the current working directory. That folder would then have a lot of cache files each time you run Manim. In order to avoid this, you will have to install **Manimpango** from source:.
31
-
32
- ```sh
33
- pip install manimpango --no-binary :all:
34
- ```
35
-
36
- Please note that for this kind of installation to work, you must have a C compiler as well as **Pango** and its dependencies along with the **Pango** development headers. See [BUILDING](#BUILDING ) for more information.
26
+ For **Linux Users**, there are no Wheels. You must have a C compiler as well as **Pango** and its dependencies along with the **Pango** development headers. See [BUILDING](#BUILDING) for more information.
37
27
 
38
28
  ## BUILDING
39
29
 
@@ -11,5 +11,7 @@ if os.name == "nt":
11
11
  )
12
12
  try:
13
13
  from .cmanimpango import * # noqa: F403,F401
14
+ from .enums import * # noqa: F403,F401
15
+ from .register_font import * # noqa: F403,F401
14
16
  except ImportError:
15
17
  raise ImportError("Couldn't load the necessary Shared Libraries.")
@@ -1,2 +1,2 @@
1
1
  # -*- coding: utf-8 -*-
2
- __version__ = "0.2.2"
2
+ __version__ = "0.2.4"
@@ -0,0 +1,27 @@
1
+ cdef extern from "cairo.h":
2
+ ctypedef struct cairo_surface_t:
3
+ pass
4
+ ctypedef struct cairo_t:
5
+ pass
6
+ ctypedef enum cairo_status_t:
7
+ CAIRO_STATUS_SUCCESS
8
+ CAIRO_STATUS_NO_MEMORY
9
+ cairo_t* cairo_create(cairo_surface_t* target)
10
+ void cairo_move_to(
11
+ cairo_t* cr,
12
+ double x,
13
+ double y
14
+ )
15
+ void cairo_destroy(cairo_t* cr)
16
+ void cairo_surface_destroy(cairo_surface_t* surface)
17
+
18
+ cairo_status_t cairo_status(cairo_t *cr)
19
+ const char* cairo_status_to_string(cairo_status_t status)
20
+ const char* cairo_version_string()
21
+
22
+ cdef extern from "cairo-svg.h":
23
+ cairo_surface_t* cairo_svg_surface_create(
24
+ const char* filename,
25
+ double width_in_points,
26
+ double height_in_points
27
+ )
@@ -0,0 +1,3 @@
1
+ from glib cimport *
2
+ from cairo cimport *
3
+ from pango cimport *
@@ -0,0 +1,227 @@
1
+ from xml.sax.saxutils import escape
2
+ from .utils import *
3
+
4
+ class TextSetting:
5
+ """Formatting for slices of a :class:`manim.mobject.svg.text_mobject.Text` object."""
6
+ def __init__(
7
+ self,
8
+ start:int,
9
+ end:int,
10
+ font:str,
11
+ slant,
12
+ weight,
13
+ line_num=-1
14
+ ):
15
+ self.start = start
16
+ self.end = end
17
+ self.font = font.encode('utf-8')
18
+ self.slant = slant
19
+ self.weight = weight
20
+ self.line_num = line_num
21
+
22
+ def text2svg(
23
+ settings:list,
24
+ size:int,
25
+ line_spacing:int,
26
+ disable_liga:bool,
27
+ file_name:str,
28
+ START_X:int,
29
+ START_Y:int,
30
+ width:int,
31
+ height:int,
32
+ orig_text:str
33
+ ) -> int:
34
+ """Render an SVG file from a :class:`manim.mobject.svg.text_mobject.Text` object."""
35
+ cdef cairo_surface_t* surface
36
+ cdef cairo_t* cr
37
+ cdef PangoFontDescription* font_desc
38
+ cdef PangoLayout* layout
39
+ cdef double width_layout = width
40
+ cdef double font_size_c = size
41
+ cdef cairo_status_t status
42
+ cdef int temp_width
43
+
44
+ file_name_bytes = file_name.encode("utf-8")
45
+ surface = cairo_svg_surface_create(file_name_bytes,width,height)
46
+
47
+ if surface == NULL:
48
+ raise MemoryError("Cairo.SVGSurface can't be created.")
49
+
50
+ cr = cairo_create(surface)
51
+ status = cairo_status(cr)
52
+
53
+ if cr == NULL or status == CAIRO_STATUS_NO_MEMORY:
54
+ cairo_destroy(cr)
55
+ cairo_surface_destroy(surface)
56
+ raise MemoryError("Cairo.Context can't be created.")
57
+ elif status != CAIRO_STATUS_SUCCESS:
58
+ cairo_destroy(cr)
59
+ cairo_surface_destroy(surface)
60
+ raise Exception(cairo_status_to_string(status))
61
+
62
+ cairo_move_to(cr,START_X,START_Y)
63
+ offset_x = 0
64
+ last_line_num = 0
65
+
66
+ layout = pango_cairo_create_layout(cr)
67
+
68
+ if layout==NULL:
69
+ cairo_destroy(cr)
70
+ cairo_surface_destroy(surface)
71
+ raise MemoryError("Pango.Layout can't be created from Cairo Context.")
72
+
73
+ pango_layout_set_width(layout, pango_units_from_double(width_layout))
74
+ for setting in settings:
75
+ family = setting.font
76
+ style = PangoUtils.str2style(setting.slant)
77
+ weight = PangoUtils.str2weight(setting.weight)
78
+ text_str = orig_text[setting.start : setting.end].replace("\n", " ")
79
+ text = text_str.encode('utf-8')
80
+ font_desc = pango_font_description_new()
81
+ if font_desc==NULL:
82
+ cairo_destroy(cr)
83
+ cairo_surface_destroy(surface)
84
+ g_object_unref(layout)
85
+ raise MemoryError("Pango.FontDesc can't be created.")
86
+ pango_font_description_set_size(font_desc, pango_units_from_double(font_size_c))
87
+ if family:
88
+ pango_font_description_set_family(font_desc, family)
89
+ pango_font_description_set_style(font_desc, style.value)
90
+ pango_font_description_set_weight(font_desc, weight.value)
91
+ pango_layout_set_font_description(layout, font_desc)
92
+ pango_font_description_free(font_desc)
93
+ if setting.line_num != last_line_num:
94
+ offset_x = 0
95
+ last_line_num = setting.line_num
96
+ cairo_move_to(cr,START_X + offset_x,START_Y + line_spacing * setting.line_num)
97
+
98
+ pango_cairo_update_layout(cr,layout)
99
+ if disable_liga:
100
+ text_bytes = escape(text.decode('utf-8'))
101
+ markup = f"<span font_features='liga=0,dlig=0,clig=0,hlig=0'>{text_bytes}</span>"
102
+ markup_bytes = markup.encode('utf-8')
103
+ pango_layout_set_markup(layout, markup_bytes, -1)
104
+ else:
105
+ pango_layout_set_text(layout,text,-1)
106
+ pango_cairo_show_layout(cr, layout)
107
+ pango_layout_get_size(layout,&temp_width,NULL)
108
+ offset_x += pango_units_to_double(temp_width)
109
+
110
+ status = cairo_status(cr)
111
+
112
+ if cr == NULL or status == CAIRO_STATUS_NO_MEMORY:
113
+ cairo_destroy(cr)
114
+ cairo_surface_destroy(surface)
115
+ g_object_unref(layout)
116
+ raise MemoryError("Cairo.Context can't be created.")
117
+ elif status != CAIRO_STATUS_SUCCESS:
118
+ cairo_destroy(cr)
119
+ cairo_surface_destroy(surface)
120
+ g_object_unref(layout)
121
+ raise Exception(cairo_status_to_string(status).decode())
122
+
123
+ cairo_destroy(cr)
124
+ cairo_surface_destroy(surface)
125
+ g_object_unref(layout)
126
+ return file_name
127
+
128
+ class MarkupUtils:
129
+ @staticmethod
130
+ def validate(text: str) -> bool:
131
+ text_bytes = text.encode("utf-8")
132
+ return pango_parse_markup(text_bytes, -1, 0, NULL, NULL, NULL, NULL)
133
+
134
+ @staticmethod
135
+ def text2svg(
136
+ text: str,
137
+ font: str,
138
+ slant: str,
139
+ weight: str,
140
+ size: int,
141
+ line_spacing: int,
142
+ disable_liga: bool,
143
+ file_name: str,
144
+ START_X: int,
145
+ START_Y: int,
146
+ width: int,
147
+ height: int,
148
+ ) -> int:
149
+ """Render an SVG file from a :class:`manim.mobject.svg.text_mobject.MarkupText` object."""
150
+ cdef cairo_surface_t* surface
151
+ cdef cairo_t* context
152
+ cdef PangoFontDescription* font_desc
153
+ cdef PangoLayout* layout
154
+ cdef cairo_status_t status
155
+ cdef double width_layout = width
156
+ cdef double font_size = size
157
+
158
+ file_name_bytes = file_name.encode("utf-8")
159
+
160
+ if disable_liga:
161
+ text_bytes = f"<span font_features='liga=0,dlig=0,clig=0,hlig=0'>{text}</span>".encode("utf-8")
162
+ else:
163
+ text_bytes = text.encode("utf-8")
164
+
165
+ surface = cairo_svg_surface_create(file_name_bytes,width,height)
166
+ if surface == NULL:
167
+ raise MemoryError("Cairo.SVGSurface can't be created.")
168
+ context = cairo_create(surface)
169
+ status = cairo_status(context)
170
+ if context == NULL or status == CAIRO_STATUS_NO_MEMORY:
171
+ cairo_destroy(context)
172
+ cairo_surface_destroy(surface)
173
+ raise MemoryError("Cairo.Context can't be created.")
174
+ elif status != CAIRO_STATUS_SUCCESS:
175
+ cairo_destroy(context)
176
+ cairo_surface_destroy(surface)
177
+ raise Exception(cairo_status_to_string(status))
178
+
179
+ cairo_move_to(context,START_X,START_Y)
180
+ layout = pango_cairo_create_layout(context)
181
+ if layout==NULL:
182
+ cairo_destroy(context)
183
+ cairo_surface_destroy(surface)
184
+ raise MemoryError("Pango.Layout can't be created from Cairo Context.")
185
+ pango_layout_set_width(layout, pango_units_from_double(width_layout))
186
+
187
+ font_desc = pango_font_description_new()
188
+ if font_desc==NULL:
189
+ cairo_destroy(context)
190
+ cairo_surface_destroy(surface)
191
+ g_object_unref(layout)
192
+ raise MemoryError("Pango.FontDesc can't be created.")
193
+ pango_font_description_set_size(font_desc, pango_units_from_double(font_size))
194
+ if font is not None and len(font) != 0:
195
+ pango_font_description_set_family(font_desc, font.encode("utf-8"))
196
+ pango_font_description_set_style(font_desc, PangoUtils.str2style(slant).value)
197
+ pango_font_description_set_weight(font_desc, PangoUtils.str2weight(weight).value)
198
+ pango_layout_set_font_description(layout, font_desc)
199
+ pango_font_description_free(font_desc)
200
+
201
+ cairo_move_to(context,START_X,START_Y)
202
+ pango_cairo_update_layout(context,layout)
203
+ pango_layout_set_markup(layout,text_bytes,-1)
204
+ pango_cairo_show_layout(context, layout)
205
+
206
+ status = cairo_status(context)
207
+ if context == NULL or status == CAIRO_STATUS_NO_MEMORY:
208
+ cairo_destroy(context)
209
+ cairo_surface_destroy(surface)
210
+ g_object_unref(layout)
211
+ raise MemoryError("Cairo.Context can't be created.")
212
+ elif status != CAIRO_STATUS_SUCCESS:
213
+ cairo_destroy(context)
214
+ cairo_surface_destroy(surface)
215
+ g_object_unref(layout)
216
+ raise Exception(cairo_status_to_string(status).decode())
217
+
218
+ cairo_destroy(context)
219
+ cairo_surface_destroy(surface)
220
+ g_object_unref(layout)
221
+ return file_name
222
+
223
+ cpdef str pango_version():
224
+ return pango_version_string().decode('utf-8')
225
+
226
+ cpdef str cairo_version():
227
+ return cairo_version_string().decode('utf-8')
@@ -0,0 +1,92 @@
1
+ from enum import Enum
2
+ from pango cimport *
3
+ class Style(Enum):
4
+ """
5
+ An enumeration specifying the various slant styles possible for a font.
6
+
7
+ Attributes
8
+ ----------
9
+
10
+ NORMAL :
11
+ the font is upright.
12
+
13
+ ITALIC :
14
+ the font is slanted, but in a roman style.
15
+
16
+ OBLIQUE:
17
+ the font is slanted in an italic style.
18
+ """
19
+ NORMAL = PANGO_STYLE_NORMAL
20
+ ITALIC = PANGO_STYLE_ITALIC
21
+ OBLIQUE = PANGO_STYLE_OBLIQUE
22
+
23
+ class Weight(Enum):
24
+ """
25
+ An enumeration specifying the weight (boldness) of a font.
26
+ This is a numerical value ranging from 100 to 1000, but there are some predefined values
27
+ Using numerical value other then that defined here is not supported.
28
+
29
+ Attributes
30
+ ----------
31
+
32
+ NORMAL :
33
+ the default weight (= 400)
34
+
35
+ BOLD :
36
+ the bold weight( = 700)
37
+
38
+ THIN :
39
+ the thin weight( = 100; Since: 1.24)
40
+
41
+ ULTRALIGHT :
42
+ the ultralight weight( = 200)
43
+
44
+ LIGHT :
45
+ the light weight( = 300)
46
+
47
+ BOOK :
48
+ the book weight( = 380; Since: 1.24)
49
+
50
+ MEDIUM :
51
+ the normal weight( = 500; Since: 1.24)
52
+
53
+ SEMIBOLD :
54
+ the semibold weight( = 600)
55
+
56
+ ULTRABOLD :
57
+ the ultrabold weight( = 800)
58
+
59
+ HEAVY :
60
+ the heavy weight( = 900)
61
+
62
+ ULTRAHEAVY :
63
+ the ultraheavy weight( = 1000; Since: 1.24)
64
+ """
65
+ NORMAL = PANGO_WEIGHT_NORMAL
66
+ BOLD = PANGO_WEIGHT_BOLD
67
+ THIN = PANGO_WEIGHT_THIN
68
+ ULTRALIGHT = PANGO_WEIGHT_ULTRALIGHT
69
+ LIGHT = PANGO_WEIGHT_LIGHT
70
+ BOOK = PANGO_WEIGHT_BOOK
71
+ MEDIUM = PANGO_WEIGHT_MEDIUM
72
+ SEMIBOLD = PANGO_WEIGHT_SEMIBOLD
73
+ ULTRABOLD = PANGO_WEIGHT_ULTRABOLD
74
+ HEAVY = PANGO_WEIGHT_HEAVY
75
+ ULTRAHEAVY = PANGO_WEIGHT_ULTRAHEAVY
76
+
77
+ class Variant(Enum):
78
+ """
79
+ An enumeration specifying capitalization variant of the font.
80
+
81
+ Attributes
82
+ ----------
83
+
84
+ NORMAL :
85
+ A normal font.
86
+
87
+ SMALL_CAPS :
88
+ A font with the lower case characters replaced by smaller variants
89
+ of the capital characters.
90
+ """
91
+ NORMAL = PANGO_VARIANT_NORMAL
92
+ SMALL_CAPS = PANGO_VARIANT_SMALL_CAPS
@@ -0,0 +1,8 @@
1
+ cdef extern from "glib.h":
2
+ ctypedef void* gpointer
3
+ ctypedef int gint
4
+ ctypedef unsigned int guint
5
+ ctypedef gint gboolean
6
+ ctypedef unsigned short guint16
7
+ void g_object_unref(gpointer object)
8
+ void g_free(gpointer mem)
@@ -1,40 +1,5 @@
1
- cdef extern from "glib.h":
2
- ctypedef void* gpointer
3
- ctypedef int gint
4
- ctypedef unsigned int guint
5
- ctypedef gint gboolean
6
- ctypedef unsigned short guint16
7
- void g_object_unref(gpointer object)
8
- void g_free(gpointer mem)
9
-
10
- cdef extern from "cairo.h":
11
- ctypedef struct cairo_surface_t:
12
- pass
13
- ctypedef struct cairo_t:
14
- pass
15
- ctypedef enum cairo_status_t:
16
- CAIRO_STATUS_SUCCESS
17
- CAIRO_STATUS_NO_MEMORY
18
- cairo_t* cairo_create(cairo_surface_t* target)
19
- void cairo_move_to(
20
- cairo_t* cr,
21
- double x,
22
- double y
23
- )
24
- void cairo_destroy(cairo_t* cr)
25
- void cairo_surface_destroy (cairo_surface_t* surface)
26
-
27
- cairo_status_t cairo_status (cairo_t *cr)
28
- const char* cairo_status_to_string (cairo_status_t status)
29
- const char* cairo_version_string()
30
-
31
- cdef extern from "cairo-svg.h":
32
- cairo_surface_t* cairo_svg_surface_create(
33
- const char* filename,
34
- double width_in_points,
35
- double height_in_points
36
- )
37
-
1
+ from glib cimport *
2
+ from cairo cimport *
38
3
  cdef extern from "pango/pangocairo.h":
39
4
  int PANGO_SCALE
40
5
  int pango_units_from_double(double d)
@@ -156,30 +121,3 @@ cdef extern from "pango/pangocairo.h":
156
121
  const char* pango_font_family_get_name(
157
122
  PangoFontFamily *family
158
123
  )
159
- IF UNAME_SYSNAME == "Linux":
160
- cdef extern from "fontconfig/fontconfig.h":
161
- ctypedef int FcBool
162
- ctypedef struct FcConfig:
163
- pass
164
- FcBool FcConfigAppFontAddFile(
165
- FcConfig* config,
166
- const unsigned char* file_name
167
- )
168
- FcConfig* FcConfigGetCurrent()
169
- void FcConfigAppFontClear(void*)
170
- ELIF UNAME_SYSNAME == "Windows":
171
- cdef extern from "windows.h":
172
- ctypedef Py_UNICODE WCHAR
173
- ctypedef const WCHAR* LPCWSTR
174
- ctypedef enum DWORD:
175
- FR_PRIVATE
176
- int AddFontResourceExW(
177
- LPCWSTR name,
178
- DWORD fl,
179
- unsigned int res
180
- )
181
- bint RemoveFontResourceExW(
182
- LPCWSTR name,
183
- DWORD fl,
184
- unsigned int pdv
185
- )
@@ -0,0 +1,54 @@
1
+ IF UNAME_SYSNAME == "Linux":
2
+ cdef extern from "fontconfig/fontconfig.h":
3
+ ctypedef int FcBool
4
+ ctypedef struct FcConfig:
5
+ pass
6
+ FcBool FcConfigAppFontAddFile(
7
+ FcConfig* config,
8
+ const unsigned char* file_name
9
+ )
10
+ FcConfig* FcConfigGetCurrent()
11
+ void FcConfigAppFontClear(void *)
12
+ ELIF UNAME_SYSNAME == "Windows":
13
+ cdef extern from "windows.h":
14
+ ctypedef Py_UNICODE WCHAR
15
+ ctypedef const WCHAR* LPCWSTR
16
+ ctypedef enum DWORD:
17
+ FR_PRIVATE
18
+ int AddFontResourceExW(
19
+ LPCWSTR name,
20
+ DWORD fl,
21
+ unsigned int res
22
+ )
23
+ bint RemoveFontResourceExW(
24
+ LPCWSTR name,
25
+ DWORD fl,
26
+ unsigned int pdv
27
+ )
28
+ ELIF UNAME_SYSNAME == "Darwin":
29
+ cdef extern from "Carbon/Carbon.h":
30
+ ctypedef struct CFURLRef:
31
+ pass
32
+ ctypedef enum CTFontManagerScope:
33
+ kCTFontManagerScopeProcess
34
+ ctypedef unsigned int UInt8
35
+ ctypedef long CFIndex
36
+ ctypedef unsigned int UInt32
37
+ ctypedef UInt32 CFStringEncoding
38
+ CFURLRef CFURLCreateWithBytes(
39
+ void*,
40
+ unsigned char *URLBytes,
41
+ CFIndex length,
42
+ CFStringEncoding encoding,
43
+ void*
44
+ )
45
+ bint CTFontManagerRegisterFontsForURL(
46
+ CFURLRef fontURL,
47
+ CTFontManagerScope scope,
48
+ void* error
49
+ )
50
+ bint CTFontManagerUnregisterFontsForURL(
51
+ CFURLRef fontURL,
52
+ CTFontManagerScope scope,
53
+ void* error
54
+ )