Commit def1d000 authored by Akira TAGOH's avatar Akira TAGOH

Add reset-dirs element

This element removes all of fonts directories where added by
dir elements. it is useful to override fonts dirs from system
to their own dirs only.
parent 5e46f154
<?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>
......@@ -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 \
......
......@@ -358,6 +358,10 @@ as the path 'as-path' in cached information.
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
......
......@@ -8,6 +8,7 @@
include |
match |
remap-dir |
reset-dirs |
selectfont)* >
<!--
......@@ -120,6 +121,11 @@
prefix (default|xdg|relative|cwd) "default"
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
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
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