Lifetime of strings from FcPatternGetString

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


Hello all,

It’s not clear from the FC documentation how long we can expect a string returned from a pattern by FcPatternGetString to remain valid.

The doc does say that FcPatternGetString provides a pointer to the actual string within the pattern, but as in the code snippet below, the pattern is destroyed but I've observed that the returned filename value seems to remain usable.
Am I purely lucky that the memory is still valid, or are these strings “atoms” i.e. strings that remain valid for the entire lifetime of FontConfig? Is this documented anywhere?


const char* FindFileName(const char* family, bool isBold, bool isItalic)
                const char* filename = NULL;
                FcPattern* pattern = FcPatternBuild(NULL,
                                                                                                                FC_SCALABLE, FcTypeBool, true,
                                                                                                                FC_FAMILY, FcTypeString, family,
                                                                                                                FC_WEIGHT, FcTypeInteger, weight,
                                                                                                                FC_SLANT, FcTypeInteger, slant,
                if(pattern) {
                                FcConfigSubstitute(0, pattern, FcMatchPattern);
                                FcResult result;
                                FcPattern* match = FcFontMatch(0, pattern, &result);
                                if(match) {
                                                FcChar8* str = 0;
                                                if(FcPatternGetString(match, FC_FILE, 0, &str) == FcResultMatch) {
                                                                filename = (const char*)str;
                return filename;
_______________________________________________Fontconfig mailing listFontconfig@xxxxxxxxxxxxxxxxxxxxxxxxx://

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

  Powered by Linux