[Fontconfig] Does FcConfigDestroy also destroy pattern, objectset and fontset?

jeremie bergeron jeremiebergeron1515 at gmail.com
Fri Apr 28 01:36:19 UTC 2023


Hi,
Do I only need to call FcConfigDestroy to destroy the config, pattern,
objectset and the fontset or I need to call them all like I am currently
doing?
fonts_filename = set()

config = LinuxFonts._font_config.FcInitLoadConfigAndFonts()
pat = LinuxFonts._font_config.FcPatternCreate()
os = LinuxFonts._font_config.FcObjectSetBuild(b"file", b"fontformat", 0)
fs = LinuxFonts._font_config.FcFontList(config, pat, None)

for i in range(fs.contents.nfont):
    font = fs.contents.fonts[i]
    file_path_ptr = c_char_p()
    font_format_ptr = c_char_p()

    if (
        LinuxFonts._font_config.FcPatternGetString(font, b"fontformat", 0,
byref(font_format_ptr)) == FC_RESULT.FC_RESULT_MATCH
        and LinuxFonts._font_config.FcPatternGetString(font, b"file", 0,
byref(file_path_ptr)) == FC_RESULT.FC_RESULT_MATCH
    ):
        font_format = FT_FONT_FORMAT(font_format_ptr.value)

        if font_format in LinuxFonts.VALID_FONT_FORMATS:
            # Decode with utf-8 since FcChar8
            fonts_filename.add(file_path_ptr.value.decode())

# I am not 100% if we need to call all of these. We may only need to call
FcFontSetDestroy.
LinuxFonts._font_config.FcConfigDestroy(config)
LinuxFonts._font_config.FcPatternDestroy(pat)
LinuxFonts._font_config.FcObjectSetDestroy(os)
LinuxFonts._font_config.FcFontSetDestroy(fs)


The full code is available here <https://paste.pythondiscord.com/ijokojofif>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20230427/5e43a888/attachment.htm>


More information about the Fontconfig mailing list