diff options
author | Akira TAGOH <akira@tagoh.org> | 2018-10-02 09:32:03 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2018-10-02 10:12:14 +0000 |
commit | 1aa8b700c3f09a31c78e7834e0db373f80b5e226 (patch) | |
tree | bcad398393e22c08aa7e61620378c9efa031b8c0 /src/fcxml.c | |
parent | f0aae4455ed43ac323821f8c8aa2fa9ffe274977 (diff) | |
download | fontconfig-1aa8b700c3f09a31c78e7834e0db373f80b5e226.tar.gz |
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
Diffstat (limited to 'src/fcxml.c')
-rw-r--r-- | src/fcxml.c | 41 |
1 files changed, 33 insertions, 8 deletions
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"); |