Commit 1aa8b700 authored by Akira TAGOH's avatar Akira TAGOH

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: #15
parent f0aae445
Pipeline #5176 passed with stage
in 7 minutes and 11 seconds
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment