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

Behdad Esfahbod behdad at behdad.org
Fri Apr 28 01:38:46 UTC 2023


You need to destroy them as you are currently doing.

behdad
http://behdad.org/


On Thu, Apr 27, 2023 at 7:36 PM jeremie bergeron <
jeremiebergeron1515 at gmail.com> wrote:

> 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/07641b0c/attachment.htm>


More information about the Fontconfig mailing list