src/fcxml.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) New commits: commit 1aa8b700c3f09a31c78e7834e0db373f80b5e226 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Tue Oct 2 09:32:03 2018 +0000 Add more prefix support in <dir> element Added two prefix modes: "relative" that makes the relative path be relative to current file "cwd" for relative to current working directory which implies current behavior. Resolves: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/15 diff --git a/src/fcxml.c b/src/fcxml.c index 7797502..9d75249 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -2073,16 +2073,36 @@ FcParseDir (FcConfigParse *parse) #endif attr = FcConfigGetAttribute (parse, "prefix"); - if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0) + data = FcStrBufDoneStatic (&parse->pstack->str); + if (attr) { - prefix = FcConfigXdgDataHome (); - /* home directory might be disabled. - * simply ignore this element. - */ - if (!prefix) - goto bail; + if (FcStrCmp (attr, (const FcChar8 *)"xdg") == 0) + { + prefix = FcConfigXdgDataHome (); + /* home directory might be disabled. + * simply ignore this element. + */ + if (!prefix) + goto bail; + } + else if (FcStrCmp (attr, (const FcChar8 *)"cwd") == 0) + { + } + else if (FcStrCmp (attr, (const FcChar8 *)"relative") == 0) + { + prefix = FcStrDirname (parse->name); + if (!prefix) + goto bail; + } } - data = FcStrBufDoneStatic (&parse->pstack->str); +#ifndef _WIN32 + /* For Win32, check this later for dealing with special cases */ + else + { + if (!FcStrIsAbsoluteFilename (data) && data[0] != '~') + FcConfigMessage (parse, FcSevereWarning, "Use of ambiguous <dir> element. please add prefix=\"cwd\" if current behavior is desired."); + } +#endif if (!data) { FcConfigMessage (parse, FcSevereError, "out of memory"); @@ -2153,6 +2173,11 @@ FcParseDir (FcConfigParse *parse) strcat ((char *) data, "\\"); strcat ((char *) data, "fonts"); } + else if (!attr) + { + if (!FcStrIsAbsoluteFilename (data) && data[0] != '~') + FcConfigMessage (parse, FcSevereWarning, "Use of ambiguous <dir> element. please add prefix=\"cwd\" if current behavior is desired."); + } #endif if (strlen ((char *) data) == 0) FcConfigMessage (parse, FcSevereWarning, "empty font directory name ignored"); _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/fontconfig