summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf.d/05-reset-dirs-sample.conf9
-rw-r--r--conf.d/Makefile.am1
-rw-r--r--doc/fontconfig-user.sgml4
-rw-r--r--fonts.dtd6
-rw-r--r--src/fccfg.c6
-rw-r--r--src/fcint.h6
-rw-r--r--src/fcstr.c16
-rw-r--r--src/fcxml.c15
8 files changed, 63 insertions, 0 deletions
diff --git a/conf.d/05-reset-dirs-sample.conf b/conf.d/05-reset-dirs-sample.conf
new file mode 100644
index 0000000..80bb6fb
--- /dev/null
+++ b/conf.d/05-reset-dirs-sample.conf
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <description>Re-define fonts dirs sample</description>
+
+ <reset-dirs />
+ <dir prefix="xdg">fonts</dir>
+
+</fontconfig>
diff --git a/conf.d/Makefile.am b/conf.d/Makefile.am
index ff03fb2..d0f3f26 100644
--- a/conf.d/Makefile.am
+++ b/conf.d/Makefile.am
@@ -52,6 +52,7 @@ config_DATA = $(DOC_FILES)
templatedir = $(TEMPLATEDIR)
template_DATA = \
+ 05-reset-dirs-sample.conf \
10-autohint.conf \
10-hinting-full.conf \
10-hinting-medium.conf \
diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml
index f083394..f30b4f0 100644
--- a/doc/fontconfig-user.sgml
+++ b/doc/fontconfig-user.sgml
@@ -359,6 +359,10 @@ This is useful if the directory name is an alias
(via a bind mount or symlink) to another directory in the system for
which cached font information is likely to exist.
</para></refsect2>
+ <refsect2><title><literal>&lt;reset-dirs /&gt;</literal></title><para>
+This element removes all of fonts directories where added by <literal>&lt;dir&gt;</literal> elements.
+This is useful to override fonts directories from system to own fonts directories only.
+ </para></refsect2>
<refsect2><title><literal>&lt;rescan&gt;</literal></title><para>
The <literal>&lt;rescan&gt;</literal> element holds an <literal>&lt;int&gt;</literal> element which indicates the default
interval between automatic checks for font configuration changes.
diff --git a/fonts.dtd b/fonts.dtd
index d0e1700..f8c9f2c 100644
--- a/fonts.dtd
+++ b/fonts.dtd
@@ -8,6 +8,7 @@
include |
match |
remap-dir |
+ reset-dirs |
selectfont)* >
<!--
@@ -121,6 +122,11 @@
xml:space (default|preserve) "preserve">
<!--
+ Reset the list of fonts directories
+-->
+<!ELEMENT reset-dirs >
+
+<!--
Periodically rescan the font configuration and
directories to synch internal state with filesystem
-->
diff --git a/src/fccfg.c b/src/fccfg.c
index b2e2ce1..422608c 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -545,6 +545,12 @@ FcConfigAddFontDir (FcConfig *config,
return FcStrSetAddFilenamePair (config->fontDirs, d, m);
}
+FcBool
+FcConfigResetFontDirs (FcConfig *config)
+{
+ return FcStrSetDeleteAll (config->fontDirs);
+}
+
FcStrList *
FcConfigGetFontDirs (FcConfig *config)
{
diff --git a/src/fcint.h b/src/fcint.h
index 593b100..5cfdcc3 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -662,6 +662,9 @@ FcConfigAddFontDir (FcConfig *config,
const FcChar8 *d,
const FcChar8 *m);
+FcPrivate FcBool
+FcConfigResetFontDirs (FcConfig *config);
+
FcPrivate FcChar8 *
FcConfigMapFontPath(FcConfig *config,
const FcChar8 *path);
@@ -1250,6 +1253,9 @@ FcStrPairSecond (FcChar8 *s);
FcPrivate FcBool
FcStrSetAddFilenamePair (FcStrSet *strs, const FcChar8 *d, const FcChar8 *m);
+FcPrivate FcBool
+FcStrSetDeleteAll (FcStrSet *set);
+
FcPrivate void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
diff --git a/src/fcstr.c b/src/fcstr.c
index 4e0a2b6..53cd1f7 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -1388,6 +1388,22 @@ FcStrSetDel (FcStrSet *set, const FcChar8 *s)
return FcFalse;
}
+FcBool
+FcStrSetDeleteAll (FcStrSet *set)
+{
+ int i;
+
+ if (FcRefIsConst (&set->ref))
+ return FcFalse;
+
+ for (i = set->num; i > 0; i--)
+ {
+ FcStrFree (set->strs[i - 1]);
+ set->num--;
+ }
+ return FcTrue;
+}
+
/* TODO Make public */
static FcStrSet *
FcStrSetReference (FcStrSet *set)
diff --git a/src/fcxml.c b/src/fcxml.c
index 856400f..955a2b0 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -359,6 +359,7 @@ typedef enum _FcElement {
FcElementAlias,
FcElementDescription,
FcElementRemapDir,
+ FcElementResetDirs,
FcElementRescan,
@@ -423,6 +424,7 @@ static const struct {
{ "alias", FcElementAlias },
{ "description", FcElementDescription },
{ "remap-dir", FcElementRemapDir },
+ { "reset-dirs", FcElementResetDirs },
{ "rescan", FcElementRescan },
@@ -2085,6 +2087,16 @@ FcParseRemapDir (FcConfigParse *parse)
FcStrFree (prefix);
}
+static void
+FcParseResetDirs (FcConfigParse *parse)
+{
+ if (!parse->scanOnly)
+ {
+ if (!FcConfigResetFontDirs (parse->config))
+ FcConfigMessage (parse, FcSevereError, "Unable to reset fonts dirs");
+ }
+}
+
static FcExpr *
FcPopExpr (FcConfigParse *parse)
{
@@ -3065,6 +3077,9 @@ FcEndElement(void *userData, const XML_Char *name FC_UNUSED)
case FcElementRemapDir:
FcParseRemapDir (parse);
break;
+ case FcElementResetDirs:
+ FcParseResetDirs (parse);
+ break;
case FcElementRescan:
FcParseRescan (parse);