Does FcConfigDestroy also destroy pattern, objectset and fontset?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux