diff options
author | Ondrej Balaz <blami@blami.net> | 2023-01-25 05:00:57 +0900 |
---|---|---|
committer | Ondrej Balaz <blami@blami.net> | 2023-01-25 06:14:54 +0900 |
commit | da1e3f35e61597fbf58c9c550ceba6d44abb1563 (patch) | |
tree | 3507534afd66408228ffc6948ef09dba2f34a478 | |
parent | f7091cd17b33e8e6023a69a95e0665959ce0104e (diff) | |
download | fontconfig-da1e3f35e61597fbf58c9c550ceba6d44abb1563.tar.gz |
Expand ~ in glob
Allow ~ home directory expansion in acceptfont and rejectfont globs.
Fixes: #347
-rw-r--r-- | doc/fontconfig-user.sgml | 3 | ||||
-rw-r--r-- | src/fccfg.c | 7 | ||||
-rw-r--r-- | src/fcxml.c | 5 |
3 files changed, 12 insertions, 3 deletions
diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml index 16e98aa..0f18fce 100644 --- a/doc/fontconfig-user.sgml +++ b/doc/fontconfig-user.sgml @@ -396,7 +396,8 @@ pattern elements which are used to match fonts. </para></refsect2> <refsect2><title><literal><glob></literal></title><para> Glob elements hold shell-style filename matching patterns (including ? and -*) which match fonts based on their complete pathnames. This can be used to +*) which match fonts based on their complete pathnames. If it starts with '~', +it refers to a directory in the users home directory. This can be used to exclude a set of directories (/usr/share/fonts/uglyfont*), or particular font file types (*.pcf.gz), but the latter mechanism relies rather heavily on filenaming conventions which can't be relied upon. Note that globs diff --git a/src/fccfg.c b/src/fccfg.c index 29124f5..f62e228 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -2923,8 +2923,13 @@ FcConfigGlobAdd (FcConfig *config, FcBool accept) { FcStrSet *set = accept ? config->acceptGlobs : config->rejectGlobs; + FcChar8 *realglob = FcStrCopyFilename(glob); + if (!realglob) + return FcFalse; - return FcStrSetAdd (set, glob); + FcBool ret = FcStrSetAdd (set, realglob); + FcStrFree(realglob); + return ret; } static FcBool diff --git a/src/fcxml.c b/src/fcxml.c index 74c892d..c700f64 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -2960,7 +2960,10 @@ FcParseAcceptRejectFont (FcConfigParse *parse, FcElement element) vstack->u.string, element == FcElementAcceptfont)) { - FcConfigMessage (parse, FcSevereError, "out of memory"); + if (FcStrUsesHome(vstack->u.string) && FcConfigHome() == NULL) + FcConfigMessage (parse, FcSevereWarning, "Home is disabled"); + else + FcConfigMessage (parse, FcSevereError, "out of memory"); } else { |