@@ -37,6 +37,14 @@ class FcFontSet(Structure):
3737 ]
3838
3939
40+ def string_to_cstring (string : str ) -> c_char_p :
41+ return c_char_p (bytes (ord (c ) for c in string ))
42+
43+
44+ FC_FONTFORMAT = string_to_cstring ("fontformat" )
45+ FC_FILE = string_to_cstring ("file" )
46+
47+
4048class LinuxFonts (SystemFonts ):
4149 _font_config = None
4250 VALID_FONT_FORMATS = [
@@ -57,7 +65,7 @@ def get_system_fonts_filename() -> Set[str]:
5765
5866 config = LinuxFonts ._font_config .FcInitLoadConfigAndFonts ()
5967 pat = LinuxFonts ._font_config .FcPatternCreate ()
60- os = LinuxFonts ._font_config .FcObjectSetBuild (b"file" , b"fontformat" , 0 )
68+ os = LinuxFonts ._font_config .FcObjectSetBuild (FC_FILE , FC_FONTFORMAT , 0 )
6169 fs = LinuxFonts ._font_config .FcFontList (config , pat , os )
6270
6371 for i in range (fs .contents .nfont ):
@@ -66,8 +74,8 @@ def get_system_fonts_filename() -> Set[str]:
6674 font_format_ptr = c_char_p ()
6775
6876 if (
69- LinuxFonts ._font_config .FcPatternGetString (font , b"fontformat" , 0 , byref (font_format_ptr )) == FC_RESULT .FC_RESULT_MATCH
70- and LinuxFonts ._font_config .FcPatternGetString (font , b"file" , 0 , byref (file_path_ptr )) == FC_RESULT .FC_RESULT_MATCH
77+ LinuxFonts ._font_config .FcPatternGetString (font , FC_FONTFORMAT , 0 , byref (font_format_ptr )) == FC_RESULT .FC_RESULT_MATCH
78+ and LinuxFonts ._font_config .FcPatternGetString (font , FC_FILE , 0 , byref (file_path_ptr )) == FC_RESULT .FC_RESULT_MATCH
7179 ):
7280 font_format = FC_FONT_FORMAT (font_format_ptr .value )
7381
0 commit comments