File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 11from pathlib import Path
22from pango cimport *
3- import copy
43import os
54
65cpdef bint fc_register_font(str font_path):
@@ -211,7 +210,7 @@ cpdef list list_fonts():
211210 :class:`list` :
212211 List of fonts sorted alphabetically.
213212 """
214- cdef PangoFontMap* fontmap= pango_cairo_font_map_new()
213+ cdef PangoFontMap* fontmap = pango_cairo_font_map_new()
215214 if fontmap == NULL :
216215 raise MemoryError (" Pango.FontMap can't be created." )
217216 cdef int n_families= 0
@@ -221,16 +220,16 @@ cpdef list list_fonts():
221220 & families,
222221 & n_families
223222 )
224- if families is NULL or n_families== 0 :
223+ if families is NULL or n_families == 0 :
225224 raise MemoryError (" Pango returned unexpected length on families." )
226- family_list= []
225+ family_list = []
227226 for i in range (n_families):
228- name = copy.deepcopy( pango_font_family_get_name(families[i]).decode( ' utf-8 ' ) )
227+ name = pango_font_family_get_name(families[i])
229228 # according to pango's docs, the `char *` returned from
230229 # `pango_font_family_get_name`is owned by pango, and python
231- # shouldn't interfere with it. So, rather we are making a
232- # deepcopy so that we don't worry about it.
233- family_list.append(name)
230+ # shouldn't interfere with it. I hope Cython handles it.
231+ # https://cython.readthedocs.io/en/stable/src/tutorial/strings.html#dealing-with-const
232+ family_list.append(name.decode() )
234233 g_free(families)
235234 g_object_unref(fontmap)
236235 family_list.sort()
You can’t perform that action at this time.
0 commit comments