From 8c255fb185d5651b57380b0a9443001e8051b29d Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Mon, 12 Mar 2012 19:18:19 +0900 Subject: Bug 20411 - fontconfig doesn't match FreeDesktop directories specs Allows reading configuration files, fonts and cache files from the directories where the XDG Base Directory Specification defines. the old directories are still in the configuration files for the backward compatibility. --- conf.d/50-user.conf | 7 +- doc/fontconfig-user.sgml | 37 ++--- fonts.conf.in | 4 + fonts.dtd | 10 +- src/fccfg.c | 78 ++++++++++- src/fcinit.c | 20 ++- src/fcint.h | 11 ++ src/fcstr.c | 5 +- src/fcxml.c | 344 ++++++++++++++++++++++++++++++----------------- 9 files changed, 366 insertions(+), 150 deletions(-) diff --git a/conf.d/50-user.conf b/conf.d/50-user.conf index 3f89012..2f10408 100644 --- a/conf.d/50-user.conf +++ b/conf.d/50-user.conf @@ -2,6 +2,9 @@ - ~/.fonts.conf.d - ~/.fonts.conf + fontconfig/conf.d + fontconfig/fonts.conf + + ~/.fonts.conf.d + ~/.fonts.conf diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml index 22d2ad3..5c9d362 100644 --- a/doc/fontconfig-user.sgml +++ b/doc/fontconfig-user.sgml @@ -37,6 +37,8 @@ &confdir;/fonts.conf &confdir;/fonts.dtd &confdir;/conf.d + $XDG_CONFIG_HOME/fontconfig/conf.d + $XDG_CONFIG_HOME/fontconfig/fonts.conf ~/.fonts.conf.d ~/.fonts.conf @@ -299,21 +301,22 @@ following structure: This is the top level element for a font configuration and can contain <dir>, <cachedir>, <include>, <match> and <alias> elements in any order. - <literal><dir></literal> + <literal><dir prefix="default"></literal> This element contains a directory name which will be scanned for font files -to include in the set of available fonts. +to include in the set of available fonts. If 'prefix' is set to "xdg", the value in the XDG_DATA_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. - <literal><cachedir></literal> + <literal><cachedir prefix="default"></literal> This element contains a directory name that is supposed to be stored or read the cache of font information. If multiple elements are specified in the configuration file, the directory that can be accessed first in the list will be used to store the cache files. If it starts with '~', it refers to -a directory in the users home directory. The default directory is ``~/.fontconfig'' -and it contains the cache files named ``<hash value>-<architecture>.cache-<version'', +a directory in the users home directory. If 'prefix' is set to "xdg", the value in the XDG_CACHE_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. +The default directory is ``$XDG_CACHE_HOME/fontconfig'' and it contains the cache files +named ``<hash value>-<architecture>.cache-<version'', where <version> is the font configureation file version number (currently 3). - <literal><include ignore_missing="no"></literal> + <literal><include ignore_missing="no" prefix="default"></literal> This element contains the name of an additional configuration file or directory. If a directory, every file within that directory starting with an ASCII digit (U+0030 - U+0039) and ending with the string ``.conf'' will be processed in sorted order. When @@ -321,7 +324,7 @@ the XML datatype is traversed by FcConfigParse, the contents of the file(s) will also be incorporated into the configuration by passing the filename(s) to FcConfigLoadAndParse. If 'ignore_missing' is set to "yes" instead of the default "no", a missing file or directory will elicit no warning message from -the library. +the library. If 'prefix' is set to "xdg", the value in the XDG_CONFIG_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. <literal><config></literal> This element provides a place to consolidate additional configuration @@ -577,7 +580,7 @@ This is an example of a system-wide configuration file Load per-user customization file, but don't complain if it doesn't exist --> -<include ignore_missing="yes">~/.fonts.conf</include> +<include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include> <!-- Load local customization files, but don't complain @@ -630,18 +633,18 @@ This is an example of a system-wide configuration file User configuration file This is an example of a per-user configuration file that lives in -~/.fonts.conf +$XDG_CONFIG_HOME/fontconfig/fonts.conf <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> -<!-- ~/.fonts.conf for per-user font configuration --> +<!-- $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configuration --> <fontconfig> <!-- Private font directory --> -<dir>~/.fonts</dir> +<dir prefix="xdg">fonts</dir> <!-- use rgb sub-pixel ordering to improve glyph appearance on @@ -677,20 +680,20 @@ format. The master fonts.conf file references this directory in an is a DTD that describes the format of the configuration files. -~/.fonts.conf.d +$XDG_CONFIG_HOME/fontconfig/conf.d and ~/.fonts.conf.d is the conventional name for a per-user directory of (typically auto-generated) configuration files, although the -actual location is specified in the global fonts.conf file. +actual location is specified in the global fonts.conf file. please note that ~/.fonts.conf.d is deprecated now. it will not be read by default in the future version. -~/.fonts.conf +$XDG_CONFIG_HOME/fontconfig/fonts.conf and ~/.fonts.conf is the conventional location for per-user font configuration, although the -actual location is specified in the global fonts.conf file. +actual location is specified in the global fonts.conf file. please note that ~/.fonts.conf is deprecated now. it will not be read by default in the future version. - ~/.fontconfig/*.cache-* +$XDG_CACHE_HOME/fontconfig/*.cache-* and ~/.fontconfig/*.cache-* is the conventional repository of font information that isn't found in the -per-directory caches. This file is automatically maintained by fontconfig. +per-directory caches. This file is automatically maintained by fontconfig. please note that ~/.fontconfig/*.cache-* is deprecated now. it will not be read by default in the future version. Environment variables diff --git a/fonts.conf.in b/fonts.conf.in index 8f9fb88..6a8753d 100644 --- a/fonts.conf.in +++ b/fonts.conf.in @@ -25,6 +25,8 @@ @FC_DEFAULT_FONTS@ @FC_FONTPATH@ + fonts + ~/.fonts @FC_CACHEDIR@ + fontconfig + ~/.fontconfig diff --git a/fonts.dtd b/fonts.dtd index 255367c..782e592 100644 --- a/fonts.dtd +++ b/fonts.dtd @@ -12,7 +12,9 @@ Add a directory that provides fonts --> - + - +