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.
This commit is contained in:
parent
5e46f15451
commit
def1d00036
|
@ -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>
|
|
@ -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><reset-dirs /></literal></title><para>
|
||||
This element removes all of fonts directories where added by <literal><dir></literal> elements.
|
||||
This is useful to override fonts directories from system to own fonts directories only.
|
||||
</para></refsect2>
|
||||
<refsect2><title><literal><rescan></literal></title><para>
|
||||
The <literal><rescan></literal> element holds an <literal><int></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);
|
||||
|
||||
|
|
16
src/fcstr.c
16
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)
|
||||
|
|
15
src/fcxml.c
15
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);
|
||||
|
|
Loading…
Reference in New Issue