diff options
69 files changed, 1916 insertions, 449 deletions
diff --git a/Makefile.am b/Makefile.am index c081f672..5e004148 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,8 +22,9 @@ # PERFORMANCE OF THIS SOFTWARE. SUBDIRS=fontconfig fc-case fc-lang src \ - fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \ - fc-validate conf.d test + fc-cache fc-cat fc-conflist fc-list fc-match \ + fc-pattern fc-query fc-scan fc-validate conf.d \ + po po-conf test if ENABLE_DOCS SUBDIRS += doc endif @@ -31,11 +32,12 @@ endif ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = \ - fontconfig.pc.in \ - fonts.conf.in \ + config.rpath \ + fontconfig.pc.in \ + fonts.conf.in \ fonts.dtd \ - fontconfig.spec.in \ - fontconfig.spec \ + fontconfig.spec.in \ + fontconfig.spec \ fontconfig-zip.in \ config-fixups.h CLEANFILES = fonts.conf @@ -49,6 +49,8 @@ AUTOCONF=${AUTOCONF-autoconf} GPERF=${GPERF-gperf} PYTHON=${PYTHON-python} LIBTOOLIZE_FLAGS="--copy --force" +GETTEXTIZE=${GETTEXTIZE-gettextize} +GETTEXTIZE_FLAGS="--force" DIE=0 @@ -84,7 +86,13 @@ if $have_libtool ; then : ; else echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 fi - +($GETTEXTIZE --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have gettext installed to compile $PROJECT." + echo "Install the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} ($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || { echo echo "You must have autoconf installed to compile $PROJECT." @@ -133,6 +141,9 @@ if test -z "$AUTOGEN_SUBDIR_MODE" -a -z "$NOCONFIGURE"; then fi fi +echo Running $GETTEXTIZE $GETTEXTIZE_FLAGS +$GETTEXTIZE $GETTEXTIZE_FLAGS + echo Running $ACLOCAL $ACLOCAL_FLAGS $ACLOCAL $ACLOCAL_FLAGS diff --git a/conf.d/10-autohint.conf b/conf.d/10-autohint.conf index f9032ba3..50ec3b44 100644 --- a/conf.d/10-autohint.conf +++ b/conf.d/10-autohint.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Enable autohinter</description> <!-- Use the Autohinter --> <match target="pattern"> <!-- diff --git a/conf.d/10-hinting-full.conf b/conf.d/10-hinting-full.conf index 27d82291..aff79766 100644 --- a/conf.d/10-hinting-full.conf +++ b/conf.d/10-hinting-full.conf @@ -1,6 +1,12 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set hintfull to hintstyle</description> + <match target="pattern"> <!-- This configuration is available on the major desktop environments. diff --git a/conf.d/10-hinting-medium.conf b/conf.d/10-hinting-medium.conf index e34ab5b3..1d49f3a8 100644 --- a/conf.d/10-hinting-medium.conf +++ b/conf.d/10-hinting-medium.conf @@ -1,6 +1,12 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set hintmedium to hintstyle</description> + <match target="pattern"> <!-- This configuration is available on the major desktop environments. diff --git a/conf.d/10-hinting-none.conf b/conf.d/10-hinting-none.conf index 0b3810d9..a134ed8d 100644 --- a/conf.d/10-hinting-none.conf +++ b/conf.d/10-hinting-none.conf @@ -1,6 +1,12 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set hintnone to hintstyle</description> + <match target="pattern"> <!-- This configuration is available on the major desktop environments. diff --git a/conf.d/10-hinting-slight.conf b/conf.d/10-hinting-slight.conf index c244ac0b..f00bcd39 100644 --- a/conf.d/10-hinting-slight.conf +++ b/conf.d/10-hinting-slight.conf @@ -1,6 +1,12 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set hintslight to hintstyle</description> + <match target="pattern"> <!-- This configuration is available on the major desktop environments. diff --git a/conf.d/10-no-sub-pixel.conf b/conf.d/10-no-sub-pixel.conf index 635847c4..4fd1776d 100644 --- a/conf.d/10-no-sub-pixel.conf +++ b/conf.d/10-no-sub-pixel.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Disable sub-pixel rendering</description> <!-- Disable sub-pixel rendering --> <match target="pattern"> <!-- diff --git a/conf.d/10-scale-bitmap-fonts.conf b/conf.d/10-scale-bitmap-fonts.conf index b4e9cb4f..ebb6c7b5 100644 --- a/conf.d/10-scale-bitmap-fonts.conf +++ b/conf.d/10-scale-bitmap-fonts.conf @@ -1,7 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <description>Bitmap scaling</description> <!-- If font is bitmap, calculate scale factor. Note that color bitmap fonts have scalable=true, while diff --git a/conf.d/10-sub-pixel-bgr.conf b/conf.d/10-sub-pixel-bgr.conf index 1378195d..241e589d 100644 --- a/conf.d/10-sub-pixel-bgr.conf +++ b/conf.d/10-sub-pixel-bgr.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Enable sub-pixel rendering with the BGR stripes layout</description> <!-- Enable sub-pixel rendering --> <match target="pattern"> <!-- diff --git a/conf.d/10-sub-pixel-rgb.conf b/conf.d/10-sub-pixel-rgb.conf index 757c3b6a..1cb103db 100644 --- a/conf.d/10-sub-pixel-rgb.conf +++ b/conf.d/10-sub-pixel-rgb.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Enable sub-pixel rendering with the RGB stripes layout</description> <!-- Enable sub-pixel rendering --> <match target="pattern"> <!-- diff --git a/conf.d/10-sub-pixel-vbgr.conf b/conf.d/10-sub-pixel-vbgr.conf index c807e5c0..1a0690af 100644 --- a/conf.d/10-sub-pixel-vbgr.conf +++ b/conf.d/10-sub-pixel-vbgr.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Enable sub-pixel rendering with the vertical BGR stripes layout</description> <!-- Enable sub-pixel rendering --> <match target="pattern"> <!-- diff --git a/conf.d/10-sub-pixel-vrgb.conf b/conf.d/10-sub-pixel-vrgb.conf index b5985e03..61bc6632 100644 --- a/conf.d/10-sub-pixel-vrgb.conf +++ b/conf.d/10-sub-pixel-vrgb.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Enable sub-pixel rendering with the vertical RGB stripes layout</description> <!-- Enable sub-pixel rendering --> <match target="pattern"> <!-- diff --git a/conf.d/10-unhinted.conf b/conf.d/10-unhinted.conf index a25e3b1d..f92df0c6 100644 --- a/conf.d/10-unhinted.conf +++ b/conf.d/10-unhinted.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Disable hinting</description> <!-- Disable hinting --> <match target="pattern"> <!-- diff --git a/conf.d/11-lcdfilter-default.conf b/conf.d/11-lcdfilter-default.conf index 9d7d11f9..929caaa2 100644 --- a/conf.d/11-lcdfilter-default.conf +++ b/conf.d/11-lcdfilter-default.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Use lcddefault as default for LCD filter</description> <!-- Use lcddefault as default for LCD filter --> <match target="pattern"> <!-- diff --git a/conf.d/11-lcdfilter-legacy.conf b/conf.d/11-lcdfilter-legacy.conf index 7e2b2567..25c36351 100644 --- a/conf.d/11-lcdfilter-legacy.conf +++ b/conf.d/11-lcdfilter-legacy.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Use lcdlegacy as default for LCD filter</description> <!-- Use lcdlegacy as default for LCD filter --> <match target="pattern"> <!-- diff --git a/conf.d/11-lcdfilter-light.conf b/conf.d/11-lcdfilter-light.conf index 0dd0a900..6f1eb3de 100644 --- a/conf.d/11-lcdfilter-light.conf +++ b/conf.d/11-lcdfilter-light.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Use lcdlight as default for LCD filter</description> <!-- Use lcdlight as default for LCD filter --> <match target="pattern"> <!-- diff --git a/conf.d/20-unhint-small-vera.conf b/conf.d/20-unhint-small-vera.conf index c9505ca8..7b3d7bdf 100644 --- a/conf.d/20-unhint-small-vera.conf +++ b/conf.d/20-unhint-small-vera.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Disable hinting for Bitstream Vera fonts when the size is less than 8ppem</description> <!-- The Bitstream Vera fonts have GASP entries suggesting that hinting be disabled below 8 ppem, but FreeType ignores those, preferring to use diff --git a/conf.d/25-unhint-nonlatin.conf b/conf.d/25-unhint-nonlatin.conf index 9adffa71..78cc7a3c 100644 --- a/conf.d/25-unhint-nonlatin.conf +++ b/conf.d/25-unhint-nonlatin.conf @@ -1,7 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <description>Disable hinting for CJK fonts</description> <!-- We can't hint CJK fonts well, so turn off hinting for CJK fonts. --> <match target="font"> diff --git a/conf.d/30-metric-aliases.conf b/conf.d/30-metric-aliases.conf index c755c5e9..147fde6b 100644 --- a/conf.d/30-metric-aliases.conf +++ b/conf.d/30-metric-aliases.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set substitutions for similar/metric-compatible families</description> <!-- diff --git a/conf.d/40-nonlatin.conf b/conf.d/40-nonlatin.conf index c900fd4e..0af8832f 100644 --- a/conf.d/40-nonlatin.conf +++ b/conf.d/40-nonlatin.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set substitutions for non-Latin fonts</description> <!-- Mark common families with their generics so we'll get something reasonable diff --git a/conf.d/45-generic.conf b/conf.d/45-generic.conf index 791d12dd..e8d19789 100644 --- a/conf.d/45-generic.conf +++ b/conf.d/45-generic.conf @@ -1,6 +1,12 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set substitutions for emoji/math fonts</description> + <!-- Keep in sync with 60-generic.conf --> <!-- Emoji --> diff --git a/conf.d/45-latin.conf b/conf.d/45-latin.conf index c6696f8d..a9240b94 100644 --- a/conf.d/45-latin.conf +++ b/conf.d/45-latin.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set substitutions for Latin fonts</description> <!-- Mark common families with their generics so we'll get something reasonable diff --git a/conf.d/49-sansserif.conf b/conf.d/49-sansserif.conf index c6209a7d..8b587b00 100644 --- a/conf.d/49-sansserif.conf +++ b/conf.d/49-sansserif.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Add sans-serif to the family when no generic name</description> <!-- If the font still has no generic name, add sans-serif --> diff --git a/conf.d/50-user.conf b/conf.d/50-user.conf index 07c9182e..681ed6da 100644 --- a/conf.d/50-user.conf +++ b/conf.d/50-user.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Load per-user customization files</description> <!-- Load per-user customization files where stored on XDG Base Directory specification compliant places. it should be usually: diff --git a/conf.d/51-local.conf b/conf.d/51-local.conf index ca9fbe19..885c3576 100644 --- a/conf.d/51-local.conf +++ b/conf.d/51-local.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Load local customization file</description> <!-- Load local system customization file --> <include ignore_missing="yes">local.conf</include> </fontconfig> diff --git a/conf.d/60-generic.conf b/conf.d/60-generic.conf index 7985ce91..be7b52b3 100644 --- a/conf.d/60-generic.conf +++ b/conf.d/60-generic.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set preferable fonts for emoji/math fonts</description> <!-- Keep in sync with 45-generic.conf --> <!-- Emoji --> diff --git a/conf.d/60-latin.conf b/conf.d/60-latin.conf index 23ee91b2..5be5d6a0 100644 --- a/conf.d/60-latin.conf +++ b/conf.d/60-latin.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set preferable fonts for Latin</description> <alias> <family>serif</family> <prefer> diff --git a/conf.d/65-fonts-persian.conf b/conf.d/65-fonts-persian.conf index ea006612..5591486e 100644 --- a/conf.d/65-fonts-persian.conf +++ b/conf.d/65-fonts-persian.conf @@ -31,6 +31,10 @@ 2008 Behdad Esfahbod: Cleanup. Add fantasy and cursive. --> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <!-- Deprecated fonts are discouraged --> diff --git a/conf.d/65-khmer.conf b/conf.d/65-khmer.conf index f9d06f2a..8985c0de 100644 --- a/conf.d/65-khmer.conf +++ b/conf.d/65-khmer.conf @@ -1,6 +1,10 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <alias> <family>serif</family> <prefer> diff --git a/conf.d/65-nonlatin.conf b/conf.d/65-nonlatin.conf index 7cedf3bd..dcbb6770 100644 --- a/conf.d/65-nonlatin.conf +++ b/conf.d/65-nonlatin.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Set preferable fonts for non-Latin</description> <alias> <family>serif</family> <prefer> diff --git a/conf.d/69-unifont.conf b/conf.d/69-unifont.conf index 177dec5d..a3586f29 100644 --- a/conf.d/69-unifont.conf +++ b/conf.d/69-unifont.conf @@ -1,6 +1,10 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <alias> <family>serif</family> <prefer> diff --git a/conf.d/70-no-bitmaps.conf b/conf.d/70-no-bitmaps.conf index 6b506e82..efb1bc00 100644 --- a/conf.d/70-no-bitmaps.conf +++ b/conf.d/70-no-bitmaps.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Reject bitmap fonts</description> <!-- Reject bitmap fonts --> <selectfont> <rejectfont> diff --git a/conf.d/70-yes-bitmaps.conf b/conf.d/70-yes-bitmaps.conf index c153aebd..0c70a534 100644 --- a/conf.d/70-yes-bitmaps.conf +++ b/conf.d/70-yes-bitmaps.conf @@ -1,6 +1,11 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Accept bitmap fonts</description> <!-- Accept bitmap fonts --> <selectfont> <acceptfont> diff --git a/conf.d/80-delicious.conf b/conf.d/80-delicious.conf index 845647be..8cd01f98 100644 --- a/conf.d/80-delicious.conf +++ b/conf.d/80-delicious.conf @@ -1,6 +1,10 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <!-- Fix-ups for Delicious family --> <!-- Delicious 'heavy' variant says its Medium weight --> diff --git a/conf.d/90-synthetic.conf b/conf.d/90-synthetic.conf index 7cd25cf4..e344e4a5 100644 --- a/conf.d/90-synthetic.conf +++ b/conf.d/90-synthetic.conf @@ -1,6 +1,10 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + <!-- Artificial oblique for fonts without an italic or oblique version --> diff --git a/configure.ac b/configure.ac index 2b9b036f..816cb38d 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,20 @@ PKGCONFIG_REQUIRES= PKGCONFIG_REQUIRES_PRIVATELY= dnl ========================================================================== +dnl gettext stuff +dnl ========================================================================== +GETTEXT_PACKAGE=$PACKAGE +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package]) + +AM_GNU_GETTEXT([external]) + +AC_PATH_PROG(ITSTOOL, [itstool]) +if test -z "$ITSTOOL"; then + AC_MSG_ERROR([The itstool were not found. Please install itstool.]) +fi + +dnl ========================================================================== case "$host" in *-*-mingw*) @@ -732,6 +746,7 @@ src/Makefile conf.d/Makefile fc-cache/Makefile fc-cat/Makefile +fc-conflist/Makefile fc-list/Makefile fc-match/Makefile fc-pattern/Makefile @@ -740,6 +755,8 @@ fc-scan/Makefile fc-validate/Makefile doc/Makefile doc/version.sgml +po/Makefile.in +po-conf/Makefile.in test/Makefile fontconfig.spec fontconfig.pc diff --git a/doc/fcconfig.fncs b/doc/fcconfig.fncs index 80f9b58c..de7a5d79 100644 --- a/doc/fcconfig.fncs +++ b/doc/fcconfig.fncs @@ -410,3 +410,38 @@ this function calls FcConfigSetCurrent() internally. @SINCE@ 2.10.92 @@ +@RET@ void +@FUNC@ FcConfigFileInfoIterInit +@TYPE1@ FcConfig * @ARG1@ config +@TYPE2@ FcConfigFileInfoIter * @ARG2@ iter +@PURPOSE@ Initialize the iterator +@DESC@ +Initialize 'iter' with the first iterator in the config file information list. +@SINCE@ 2.12.91 +@@ + +@RET@ FcBool +@FUNC@ FcConfigFileInfoIterNext +@TYPE1@ FcConfig * @ARG1@ config +@TYPE2@ FcConfigFileInfoIter * @ARG2@ iter +@PURPOSE@ Set the iterator to point to the next list +@DESC@ +Set 'iter' to point to the next node in the config file information list. +If there is no next node, FcFalse is returned. +@SINCE@ 2.12.91 +@@ + +@RET@ FcBool +@FUNC@ FcConfigFileInfoIterGet +@TYPE1@ FcConfig * @ARG1@ config +@TYPE2@ FcConfigFileInfoIter * @ARG2@ iter +@TYPE3@ FcChar8 ** @ARG3@ name +@TYPE4@ FcChar8 ** @ARG4@ description +@TYPE5@ FcBool * @ARG5@ enabled +@PURPOSE@ Obtain the configuration file information +@DESC@ +Obtain the filename, the description and the flag whether it is enabled or not +for 'iter' where points to current configuration file information. +If the iterator is invalid, FcFalse is returned. +@SINCE@ 2.12.91 +@@ diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c index 0336073a..80cc8204 100644 --- a/fc-cache/fc-cache.c +++ b/fc-cache/fc-cache.c @@ -49,6 +49,14 @@ #undef STRICT #endif +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -87,34 +95,34 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [--error-on-no-fonts] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n", + fprintf (file, _("usage: %s [-EfrsvVh] [-y SYSROOT] [--error-on-no-fonts] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n"), program); #else - fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [dirs]\n", + fprintf (file, _("usage: %s [-EfrsvVh] [-y SYSROOT] [dirs]\n"), program); #endif - fprintf (file, "Build font information caches in [dirs]\n" - "(all directories in font configuration by default).\n"); + fprintf (file, _("Build font information caches in [dirs]\n" + "(all directories in font configuration by default).\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -E, --error-on-no-fonts raise an error if no fonts in a directory\n"); - fprintf (file, " -f, --force scan directories with apparently valid caches\n"); - fprintf (file, " -r, --really-force erase all existing caches, then rescan\n"); - fprintf (file, " -s, --system-only scan system-wide directories only\n"); - fprintf (file, " -y, --sysroot=SYSROOT prepend SYSROOT to all paths for scanning\n"); - fprintf (file, " -v, --verbose display status information while busy\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -E, --error-on-no-fonts raise an error if no fonts in a directory\n")); + fprintf (file, _(" -f, --force scan directories with apparently valid caches\n")); + fprintf (file, _(" -r, --really-force erase all existing caches, then rescan\n")); + fprintf (file, _(" -s, --system-only scan system-wide directories only\n")); + fprintf (file, _(" -y, --sysroot=SYSROOT prepend SYSROOT to all paths for scanning\n")); + fprintf (file, _(" -v, --verbose display status information while busy\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -E (error-on-no-fonts)\n"); - fprintf (file, " raise an error if no fonts in a directory\n"); - fprintf (file, " -f (force) scan directories with apparently valid caches\n"); - fprintf (file, " -r, (really force) erase all existing caches, then rescan\n"); - fprintf (file, " -s (system) scan system-wide directories only\n"); - fprintf (file, " -y SYSROOT (sysroot) prepend SYSROOT to all paths for scanning\n"); - fprintf (file, " -v (verbose) display status information while busy\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, " -E (error-on-no-fonts)\n")); + fprintf (file, _(" raise an error if no fonts in a directory\n")); + fprintf (file, _(" -f (force) scan directories with apparently valid caches\n")); + fprintf (file, _(" -r, (really force) erase all existing caches, then rescan\n")); + fprintf (file, _(" -s (system) scan system-wide directories only\n")); + fprintf (file, _(" -y SYSROOT (sysroot) prepend SYSROOT to all paths for scanning\n")); + fprintf (file, _(" -v (verbose) display status information while busy\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -151,7 +159,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, if (FcStrSetMember (processed_dirs, dir)) { if (verbose) - printf ("skipping, looped directory detected\n"); + printf (_("skipping, looped directory detected\n")); continue; } @@ -161,7 +169,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, case ENOENT: case ENOTDIR: if (verbose) - printf ("skipping, no such directory\n"); + printf (_("skipping, no such directory\n")); break; default: fprintf (stderr, "\"%s\": ", dir); @@ -174,7 +182,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, if (!S_ISDIR (statb.st_mode)) { - fprintf (stderr, "\"%s\": not a directory, skipping\n", dir); + fprintf (stderr, _("\"%s\": not a directory, skipping\n"), dir); continue; } was_processed = FcTrue; @@ -196,7 +204,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, cache = FcDirCacheRead (dir, FcTrue, config); if (!cache) { - fprintf (stderr, "%s: error scanning\n", dir); + fprintf (stderr, _("\"%s\": scanning error\n"), dir); ret++; continue; } @@ -205,18 +213,18 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, if (was_valid) { if (verbose) - printf ("skipping, existing cache is valid: %d fonts, %d dirs\n", + printf (_("skipping, existing cache is valid: %d fonts, %d dirs\n"), FcCacheNumFont (cache), FcCacheNumSubdir (cache)); } else { if (verbose) - printf ("caching, new cache contents: %d fonts, %d dirs\n", + printf (_("caching, new cache contents: %d fonts, %d dirs\n"), FcCacheNumFont (cache), FcCacheNumSubdir (cache)); if (!FcDirCacheValid (dir)) { - fprintf (stderr, "%s: failed to write cache\n", dir); + fprintf (stderr, _("%s: failed to write cache\n"), dir); (void) FcDirCacheUnlink (dir, config); ret++; } @@ -225,7 +233,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, subdirs = FcStrSetCreate (); if (!subdirs) { - fprintf (stderr, "%s: Can't create subdir set\n", dir); + fprintf (stderr, _("%s: Can't create subdir set\n"), dir); ret++; FcDirCacheUnload (cache); continue; @@ -239,7 +247,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcStrSetDestroy (subdirs); if (!sublist) { - fprintf (stderr, "%s: Can't create subdir list\n", dir); + fprintf (stderr, _("%s: Can't create subdir list\n"), dir); ret++; continue; } @@ -314,7 +322,7 @@ main (int argc, char **argv) sysroot = FcStrCopy ((const FcChar8 *)optarg); break; case 'V': - fprintf (stderr, "fontconfig version %d.%d.%d\n", + fprintf (stderr, "fontconfig version %d.%d.%d\n", FC_MAJOR, FC_MINOR, FC_REVISION); exit (0); case 'v': @@ -345,7 +353,7 @@ main (int argc, char **argv) } if (!config) { - fprintf (stderr, "%s: Can't init font config library\n", argv[0]); + fprintf (stderr, _("%s: Can't initialize font config library\n"), argv[0]); return 1; } FcConfigSetCurrent (config); @@ -355,7 +363,7 @@ main (int argc, char **argv) dirs = FcStrSetCreate (); if (!dirs) { - fprintf (stderr, "%s: Can't create list of directories\n", + fprintf (stderr, _("%s: Can't create list of directories\n"), argv[0]); return 1; } @@ -363,7 +371,7 @@ main (int argc, char **argv) { if (!FcStrSetAddFilename (dirs, (FcChar8 *) argv[i])) { - fprintf (stderr, "%s: Can't add directory\n", argv[0]); + fprintf (stderr, _("%s: Can't add directory\n"), argv[0]); return 1; } i++; @@ -375,7 +383,7 @@ main (int argc, char **argv) list = FcConfigGetConfigDirs (config); if ((processed_dirs = FcStrSetCreate()) == NULL) { - fprintf(stderr, "Cannot malloc\n"); + fprintf(stderr, _("Out of Memory\n")); return 1; } @@ -407,6 +415,6 @@ main (int argc, char **argv) if (changed) sleep (2); if (verbose) - printf ("%s: %s\n", argv[0], ret ? "failed" : "succeeded"); + printf ("%s: %s\n", argv[0], ret ? _("failed") : _("succeeded")); return ret; } diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c index a1dc848b..dfe30d76 100644 --- a/fc-cat/fc-cat.c +++ b/fc-cat/fc-cat.c @@ -41,6 +41,14 @@ #include <sys/stat.h> #include <errno.h> +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -148,27 +156,27 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-rv] [--recurse] [--verbose] [*-%s" FC_CACHE_SUFFIX "|directory]...\n", + fprintf (file, _("usage: %s [-rv] [--recurse] [--verbose] [*-%s" FC_CACHE_SUFFIX "|directory]...\n"), program, FC_ARCHITECTURE); fprintf (file, " %s [-Vh] [--version] [--help]\n", program); #else - fprintf (file, "usage: %s [-rvVh] [*-%s" FC_CACHE_SUFFIX "|directory]...\n", + fprintf (file, _("usage: %s [-rvVh] [*-%s" FC_CACHE_SUFFIX "|directory]...\n"), program, FC_ARCHITECTURE); #endif - fprintf (file, "Reads font information cache from:\n"); - fprintf (file, " 1) specified fontconfig cache file\n"); - fprintf (file, " 2) related to a particular font directory\n"); + fprintf (file, _("Reads font information cache from:\n")); + fprintf (file, _(" 1) specified fontconfig cache file\n")); + fprintf (file, _(" 2) related to a particular font directory\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -r, --recurse recurse into subdirectories\n"); - fprintf (file, " -v, --verbose be verbose\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -r, --recurse recurse into subdirectories\n")); + fprintf (file, _(" -v, --verbose be verbose\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -r (recurse) recurse into subdirectories\n"); - fprintf (file, " -v (verbose) be verbose\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -r (recurse) recurse into subdirectories\n")); + fprintf (file, _(" -v (verbose) be verbose\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -294,7 +302,7 @@ main (int argc, char **argv) config = FcInitLoadConfig (); if (!config) { - fprintf (stderr, "%s: Can't init font config library\n", argv[0]); + fprintf (stderr, _("%s: Can't initialize font config library\n"), argv[0]); return 1; } FcConfigSetCurrent (config); @@ -303,7 +311,7 @@ main (int argc, char **argv) args = FcStrSetCreate (); if (!args) { - fprintf (stderr, "%s: malloc failure\n", argv[0]); + fprintf (stderr, _("%s: malloc failure\n"), argv[0]); return 1; } if (i < argc) @@ -312,7 +320,7 @@ main (int argc, char **argv) { if (!FcStrSetAddFilename (args, (const FcChar8 *) argv[i])) { - fprintf (stderr, "%s: malloc failure\n", argv[0]); + fprintf (stderr, _("%s: malloc failure\n"), argv[0]); return 1; } } @@ -324,7 +332,7 @@ main (int argc, char **argv) while ((arg = FcStrListNext (arglist))) if (!FcStrSetAdd (args, arg)) { - fprintf (stderr, "%s: malloc failure\n", argv[0]); + fprintf (stderr, _("%s: malloc failure\n"), argv[0]); return 1; } FcStrListDone (arglist); @@ -332,7 +340,7 @@ main (int argc, char **argv) arglist = FcStrListCreate (args); if (!arglist) { - fprintf (stderr, "%s: malloc failure\n", argv[0]); + fprintf (stderr, _("%s: malloc failure\n"), argv[0]); return 1; } FcStrSetDestroy (args); @@ -372,7 +380,7 @@ main (int argc, char **argv) { if (!first) printf ("\n"); - printf ("Directory: %s\nCache: %s\n--------\n", + printf (_("Directory: %s\nCache: %s\n--------\n"), FcCacheDir(cache), cache_file ? cache_file : arg); first = FcFalse; } diff --git a/fc-conflist/Makefile.am b/fc-conflist/Makefile.am new file mode 100644 index 00000000..6938ca7f --- /dev/null +++ b/fc-conflist/Makefile.am @@ -0,0 +1,60 @@ +# +# fontconfig/fc-conflist/Makefile.am +# +# Copyright © 2003 Keith Packard +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of the author(s) not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. The authors make no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS=fc-conflist + +DOC2MAN = docbook2man + +FC_VALIDATE_SRC=${top_srcdir}/fc-conflist + +SGML = ${FC_VALIDATE_SRC}/fc-conflist.sgml + +AM_CPPFLAGS=-I${top_srcdir} $(FREETYPE_CFLAGS) $(WARN_CFLAGS) + +BUILT_MANS=fc-conflist.1 + +if ENABLE_DOCS +man_MANS=${BUILT_MANS} +endif + +EXTRA_DIST=fc-conflist.sgml $(BUILT_MANS) + +CLEANFILES = + +fc_conflist_LDADD = ${top_builddir}/src/libfontconfig.la $(FREETYPE_LIBS) + +if USEDOCBOOK + +${man_MANS}: ${SGML} + $(AM_V_GEN) $(RM) $@; \ + $(DOC2MAN) ${SGML}; \ + $(RM) manpage.* + +all-local: $(man_MANS) + +CLEANFILES += $(man_MANS) +else +all-local: +endif + +-include $(top_srcdir)/git.mk diff --git a/fc-conflist/fc-conflist.c b/fc-conflist/fc-conflist.c new file mode 100644 index 00000000..d02273b7 --- /dev/null +++ b/fc-conflist/fc-conflist.c @@ -0,0 +1,142 @@ +/* + * fontconfig/fc-conflist/fc-conflist.c + * + * Copyright © 2003 Keith Packard + * Copyright © 2014 Red Hat, Inc. + * Red Hat Author(s): Akira TAGOH + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#else +#ifdef linux +#define HAVE_GETOPT_LONG 1 +#endif +#define HAVE_GETOPT 1 +#endif + +#include <fontconfig/fontconfig.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + +#ifndef HAVE_GETOPT +#define HAVE_GETOPT 0 +#endif +#ifndef HAVE_GETOPT_LONG +#define HAVE_GETOPT_LONG 0 +#endif + +#if HAVE_GETOPT_LONG +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include <getopt.h> +static const struct option longopts[] = { + {"version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {NULL,0,0,0}, +}; +#else +#if HAVE_GETOPT +extern char *optarg; +extern int optind, opterr, optopt; +#endif +#endif + +static void +usage (char *program, int error) +{ + FILE *file = error ? stderr : stdout; +#if HAVE_GETOPT_LONG + fprintf (file, _("usage: %s [-Vh] [--version] [--help]\n"), + program); +#else + fprintf (file, _("usage: %s [-Vh]\n"), + program); +#endif + fprintf (file, _("Show the ruleset files information on the system\n")); + fprintf (file, "\n"); +#if HAVE_GETOPT_LONG + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); +#else + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); +#endif + exit (error); +} + +int +main (int argc, char **argv) +{ + FcConfig *config; + FcConfigFileInfoIter iter; + +#if HAVE_GETOPT_LONG || HAVE_GETOPT + int c; + +#if HAVE_GETOPT_LONG + while ((c = getopt_long (argc, argv, "Vh", longopts, NULL)) != -1) +#else + while ((c = getopt (argc, argv, "Vh")) != -1) +#endif + { + switch (c) { + case 'V': + fprintf (stderr, "fontconfig version %d.%d.%d\n", + FC_MAJOR, FC_MINOR, FC_REVISION); + exit (0); + case 'h': + usage (argv[0], 0); + default: + usage (argv[0], 1); + } + } +#endif + + config = FcConfigGetCurrent (); + FcConfigFileInfoIterInit (config, &iter); + do + { + FcChar8 *name, *desc; + FcBool enabled; + + if (FcConfigFileInfoIterGet (config, &iter, &name, &desc, &enabled)) + { + printf ("%c %s: %s\n", enabled ? '+' : '-', name, desc); + FcStrFree (name); + FcStrFree (desc); + } + } while (FcConfigFileInfoIterNext (config, &iter)); + + FcFini (); + + return 0; +} diff --git a/fc-conflist/fc-conflist.sgml b/fc-conflist/fc-conflist.sgml new file mode 100644 index 00000000..a82dd1cc --- /dev/null +++ b/fc-conflist/fc-conflist.sgml @@ -0,0 +1,135 @@ +<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [ + +<!-- Process this file with docbook-to-man to generate an nroff manual + page: `docbook-to-man manpage.sgml > manpage.1'. You may view + the manual page with: `docbook-to-man manpage.sgml | nroff -man | + less'. A typical entry in a Makefile or Makefile.am is: + +manpage.1: manpage.sgml + docbook-to-man $< > $@ + + + The docbook-to-man binary is found in the docbook-to-man package. + Please remember that if you create the nroff version in one of the + debian/rules file targets (such as build), you will need to include + docbook-to-man in your Build-Depends control field. + + --> + + <!-- Fill in your name for FIRSTNAME and SURNAME. --> + <!ENTITY dhfirstname "<firstname>Akira</firstname>"> + <!ENTITY dhsurname "<surname>TAGOH</surname>"> + <!-- Please adjust the date whenever revising the manpage. --> + <!ENTITY dhdate "<date>Apr 1, 2014</date>"> + <!-- SECTION should be 1-8, maybe w/ subsection other parameters are + allowed: see man(7), man(1). --> + <!ENTITY dhsection "<manvolnum>1</manvolnum>"> + <!ENTITY dhemail "<email>akira@tagoh.org</email>"> + <!ENTITY dhusername "Akira TAGOH"> + <!ENTITY dhucpackage "<refentrytitle>fc-conflist</refentrytitle>"> + <!ENTITY dhpackage "fc-conflist"> + + <!ENTITY gnu "<acronym>GNU</acronym>"> + <!ENTITY gpl "&gnu; <acronym>GPL</acronym>"> +]> + +<refentry> + <refentryinfo> + <address> + &dhemail; + </address> + <author> + &dhfirstname; + &dhsurname; + </author> + <copyright> + <year>2014</year> + <holder>&dhusername;</holder> + </copyright> + &dhdate; + </refentryinfo> + <refmeta> + &dhucpackage; + + &dhsection; + </refmeta> + <refnamediv> + <refname>&dhpackage;</refname> + + <refpurpose>Show the ruleset files information on the system</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>&dhpackage;</command> + + <arg><option>-Vh</option></arg> + <sbr> + <arg><option>--version</option></arg> + <arg><option>--help</option></arg> + + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>DESCRIPTION</title> + + <para><command>&dhpackage;</command> shows the ruleset files' information + being installed on the system.</para> + + </refsect1> + <refsect1> + <title>OPTIONS</title> + + <para>This program follows the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below.</para> + + <variablelist> + <varlistentry> + <term><option>-V</option> + <option>--version</option> + </term> + <listitem> + <para>Show version of the program and exit.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-h</option> + <option>--help</option> + </term> + <listitem> + <para>Show summary of options.</para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>RETURN CODES</title> + <para><command>fc-conflist</command> returns error code 0 for successful parsing, + or 1 if any errors occured or if at least one font face could not be opened.</para> + </refsect1> + + <refsect1> + <title>AUTHOR</title> + + <para>This manual page was updated by &dhusername; &dhemail;.</para> + + </refsect1> +</refentry> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:2 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:nil +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +--> diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c index 95963e79..5cded50b 100644 --- a/fc-list/fc-list.c +++ b/fc-list/fc-list.c @@ -36,6 +36,14 @@ #define HAVE_GETOPT 1 #endif +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -68,28 +76,28 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-vbqVh] [-f FORMAT] [--verbose] [--brief] [--format=FORMAT] [--quiet] [--version] [--help] [pattern] {element ...} \n", + fprintf (file, _("usage: %s [-vbqVh] [-f FORMAT] [--verbose] [--brief] [--format=FORMAT] [--quiet] [--version] [--help] [pattern] {element ...} \n"), program); #else - fprintf (file, "usage: %s [-vbqVh] [-f FORMAT] [pattern] {element ...} \n", + fprintf (file, _("usage: %s [-vbqVh] [-f FORMAT] [pattern] {element ...} \n"), program); #endif - fprintf (file, "List fonts matching [pattern]\n"); + fprintf (file, _("List fonts matching [pattern]\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -v, --verbose display entire font pattern verbosely\n"); - fprintf (file, " -b, --brief display entire font pattern briefly\n"); - fprintf (file, " -f, --format=FORMAT use the given output format\n"); - fprintf (file, " -q, --quiet suppress all normal output, exit 1 if no fonts matched\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -v, --verbose display entire font pattern verbosely\n")); + fprintf (file, _(" -b, --brief display entire font pattern briefly\n")); + fprintf (file, _(" -f, --format=FORMAT use the given output format\n")); + fprintf (file, _(" -q, --quiet suppress all normal output, exit 1 if no fonts matched\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -v (verbose) display entire font pattern verbosely\n"); - fprintf (file, " -b (brief) display entire font pattern briefly\n"); - fprintf (file, " -f FORMAT (format) use the given output format\n"); - fprintf (file, " -q, (quiet) suppress all normal output, exit 1 if no fonts matched\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -v (verbose) display entire font pattern verbosely\n")); + fprintf (file, _(" -b (brief) display entire font pattern briefly\n")); + fprintf (file, _(" -f FORMAT (format) use the given output format\n")); + fprintf (file, _(" -q, (quiet) suppress all normal output, exit 1 if no fonts matched\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -148,7 +156,7 @@ main (int argc, char **argv) pat = FcNameParse ((FcChar8 *) argv[i]); if (!pat) { - fputs ("Unable to parse the pattern\n", stderr); + fprintf (stderr, _("Unable to parse the pattern\n")); return 1; } while (argv[++i]) diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c index 88f4ac8d..79027079 100644 --- a/fc-match/fc-match.c +++ b/fc-match/fc-match.c @@ -37,6 +37,14 @@ #include <stdlib.h> #include <string.h> +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -70,30 +78,30 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-savbVh] [-f FORMAT] [--sort] [--all] [--verbose] [--brief] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n", + fprintf (file, _("usage: %s [-savbVh] [-f FORMAT] [--sort] [--all] [--verbose] [--brief] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n"), program); #else - fprintf (file, "usage: %s [-savVh] [-f FORMAT] [pattern] {element...}\n", + fprintf (file, _("usage: %s [-savVh] [-f FORMAT] [pattern] {element...}\n"), program); #endif - fprintf (file, "List best font matching [pattern]\n"); + fprintf (file, _("List best font matching [pattern]\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -s, --sort display sorted list of matches\n"); - fprintf (file, " -a, --all display unpruned sorted list of matches\n"); - fprintf (file, " -v, --verbose display entire font pattern verbosely\n"); - fprintf (file, " -b, --brief display entire font pattern briefly\n"); - fprintf (file, " -f, --format=FORMAT use the given output format\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -s, --sort display sorted list of matches\n")); + fprintf (file, _(" -a, --all display unpruned sorted list of matches\n")); + fprintf (file, _(" -v, --verbose display entire font pattern verbosely\n")); + fprintf (file, _(" -b, --brief display entire font pattern briefly\n")); + fprintf (file, _(" -f, --format=FORMAT use the given output format\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -s, (sort) display sorted list of matches\n"); - fprintf (file, " -a (all) display unpruned sorted list of matches\n"); - fprintf (file, " -v (verbose) display entire font pattern verbosely\n"); - fprintf (file, " -b (brief) display entire font pattern briefly\n"); - fprintf (file, " -f FORMAT (format) use the given output format\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -s, (sort) display sorted list of matches\n")); + fprintf (file, _(" -a (all) display unpruned sorted list of matches\n")); + fprintf (file, _(" -v (verbose) display entire font pattern verbosely\n")); + fprintf (file, _(" -b (brief) display entire font pattern briefly\n")); + fprintf (file, _(" -f FORMAT (format) use the given output format\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -155,7 +163,7 @@ main (int argc, char **argv) pat = FcNameParse ((FcChar8 *) argv[i]); if (!pat) { - fputs ("Unable to parse the pattern\n", stderr); + fprintf (stderr, _("Unable to parse the pattern\n")); return 1; } while (argv[++i]) @@ -184,7 +192,7 @@ main (int argc, char **argv) if (!font_patterns || font_patterns->nfont == 0) { - fputs("No fonts installed on the system\n", stderr); + fprintf (stderr, _("No fonts installed on the system\n")); return 1; } for (j = 0; j < font_patterns->nfont; j++) diff --git a/fc-pattern/fc-pattern.c b/fc-pattern/fc-pattern.c index d2279cb3..37c5ccfc 100644 --- a/fc-pattern/fc-pattern.c +++ b/fc-pattern/fc-pattern.c @@ -37,6 +37,14 @@ #include <stdlib.h> #include <string.h> +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -68,26 +76,26 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-cdVh] [-f FORMAT] [--config] [--default] [--verbose] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n", + fprintf (file, _("usage: %s [-cdVh] [-f FORMAT] [--config] [--default] [--verbose] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n"), program); #else - fprintf (file, "usage: %s [-cdVh] [-f FORMAT] [pattern] {element...}\n", + fprintf (file, _("usage: %s [-cdVh] [-f FORMAT] [pattern] {element...}\n"), program); #endif - fprintf (file, "List best font matching [pattern]\n"); + fprintf (file, _("List best font matching [pattern]\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -c, --config perform config substitution on pattern\n"); - fprintf (file, " -d, -default perform default substitution on pattern\n"); - fprintf (file, " -f, --format=FORMAT use the given output format\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -c, --config perform config substitution on pattern\n")); + fprintf (file, _(" -d, -default perform default substitution on pattern\n")); + fprintf (file, _(" -f, --format=FORMAT use the given output format\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -c, (config) perform config substitution on pattern\n"); - fprintf (file, " -d, (default) perform default substitution on pattern\n"); - fprintf (file, " -f FORMAT (format) use the given output format\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -c, (config) perform config substitution on pattern\n")); + fprintf (file, _(" -d, (default) perform default substitution on pattern\n")); + fprintf (file, _(" -f FORMAT (format) use the given output format\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -139,7 +147,7 @@ main (int argc, char **argv) pat = FcNameParse ((FcChar8 *) argv[i]); if (!pat) { - fputs ("Unable to parse the pattern\n", stderr); + fprintf (stderr, _("Unable to parse the pattern\n")); return 1; } while (argv[++i]) diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c index 8a96da0b..9da090df 100644 --- a/fc-query/fc-query.c +++ b/fc-query/fc-query.c @@ -40,6 +40,14 @@ #include <stdlib.h> #include <string.h> +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -71,26 +79,26 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-bVh] [-i index] [-f FORMAT] [--index index] [--brief] [--format FORMAT] [--version] [--help] font-file...\n", + fprintf (file, _("usage: %s [-bVh] [-i index] [-f FORMAT] [--index index] [--brief] [--format FORMAT] [--version] [--help] font-file...\n"), program); #else - fprintf (file, "usage: %s [-bVh] [-i index] [-f FORMAT] font-file...\n", + fprintf (file, _("usage: %s [-bVh] [-i index] [-f FORMAT] font-file...\n"), program); #endif - fprintf (file, "Query font files and print resulting pattern(s)\n"); + fprintf (file, _("Query font files and print resulting pattern(s)\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\n"); - fprintf (file, " -b, --brief display font pattern briefly\n"); - fprintf (file, " -f, --format=FORMAT use the given output format\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -i, --index INDEX display the INDEX face of each font file only\n")); + fprintf (file, _(" -b, --brief display font pattern briefly\n")); + fprintf (file, _(" -f, --format=FORMAT use the given output format\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n"); - fprintf (file, " -b (brief) display font pattern briefly\n"); - fprintf (file, " -f FORMAT (format) use the given output format\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -i INDEX (index) display the INDEX face of each font file only\n")); + fprintf (file, _(" -b (brief) display font pattern briefly\n")); + fprintf (file, _(" -f FORMAT (format) use the given output format\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -147,7 +155,7 @@ main (int argc, char **argv) { if (!FcFreeTypeQueryAll ((FcChar8*) argv[i], id, NULL, NULL, fs)) { - fprintf (stderr, "Can't query face %u of font file %s\n", id, argv[i]); + fprintf (stderr, _("Can't query face %u of font file %s\n"), id, argv[i]); err = 1; } } diff --git a/fc-scan/fc-scan.c b/fc-scan/fc-scan.c index 41bd2606..edb967c7 100644 --- a/fc-scan/fc-scan.c +++ b/fc-scan/fc-scan.c @@ -40,6 +40,14 @@ #include <stdlib.h> #include <string.h> +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -70,24 +78,24 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-bVh] [-f FORMAT] [--brief] [--format FORMAT] [--version] [--help] font-file...\n", + fprintf (file, _("usage: %s [-bVh] [-f FORMAT] [--brief] [--format FORMAT] [--version] [--help] font-file...\n"), program); #else - fprintf (file, "usage: %s [-bVh] [-f FORMAT] font-file...\n", + fprintf (file, _("usage: %s [-bVh] [-f FORMAT] font-file...\n"), program); #endif - fprintf (file, "Scan font files and directories, and print resulting pattern(s)\n"); + fprintf (file, _("Scan font files and directories, and print resulting pattern(s)\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -b, --brief display font pattern briefly\n"); - fprintf (file, " -f, --format=FORMAT use the given output format\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -b, --brief display font pattern briefly\n")); + fprintf (file, _(" -f, --format=FORMAT use the given output format\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -b (brief) display font pattern briefly\n"); - fprintf (file, " -f FORMAT (format) use the given output format\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -b (brief) display font pattern briefly\n")); + fprintf (file, _(" -f FORMAT (format) use the given output format\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } diff --git a/fc-validate/Makefile.am b/fc-validate/Makefile.am index 782ceadb..c485aa51 100644 --- a/fc-validate/Makefile.am +++ b/fc-validate/Makefile.am @@ -1,5 +1,5 @@ # -# fontconfig/fc-query/Makefile.am +# fontconfig/fc-validate/Makefile.am # # Copyright © 2003 Keith Packard # diff --git a/fc-validate/fc-validate.c b/fc-validate/fc-validate.c index 6ecff367..2ceee202 100644 --- a/fc-validate/fc-validate.c +++ b/fc-validate/fc-validate.c @@ -41,6 +41,14 @@ #include <string.h> #include <locale.h> +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -72,26 +80,26 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-Vhv] [-i index] [-l LANG] [--index index] [--lang LANG] [--verbose] [--version] [--help] font-file...\n", + fprintf (file, _("usage: %s [-Vhv] [-i index] [-l LANG] [--index index] [--lang LANG] [--verbose] [--version] [--help] font-file...\n"), program); #else - fprintf (file, "usage: %s [-Vhv] [-i index] [-l LANG] font-file...\n", + fprintf (file, _("usage: %s [-Vhv] [-i index] [-l LANG] font-file...\n"), program); #endif - fprintf (file, "Validate font files and print result\n"); + fprintf (file, _("Validate font files and print result\n")); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\n"); - fprintf (file, " -l, --lang=LANG set LANG instead of current locale\n"); - fprintf (file, " -v, --verbose show more detailed information\n"); - fprintf (file, " -V, --version display font config version and exit\n"); - fprintf (file, " -h, --help display this help and exit\n"); + fprintf (file, _(" -i, --index INDEX display the INDEX face of each font file only\n")); + fprintf (file, _(" -l, --lang=LANG set LANG instead of current locale\n")); + fprintf (file, _(" -v, --verbose show more detailed information\n")); + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); #else - fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n"); - fprintf (file, " -l LANG (lang) set LANG instead of current locale\n"); - fprintf (file, " -v (verbose) show more detailed information\n"); - fprintf (file, " -V (version) display font config version and exit\n"); - fprintf (file, " -h (help) display this help and exit\n"); + fprintf (file, _(" -i INDEX (index) display the INDEX face of each font file only\n")); + fprintf (file, _(" -l LANG (lang) set LANG instead of current locale\n")); + fprintf (file, _(" -v (verbose) show more detailed information\n")); + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); #endif exit (error); } @@ -156,7 +164,7 @@ main (int argc, char **argv) if (FT_Init_FreeType (&ftlib)) { - fprintf (stderr, "Can't initalize FreeType library\n"); + fprintf (stderr, _("Can't initalize FreeType library\n")); return 1; } @@ -174,7 +182,7 @@ main (int argc, char **argv) { if (!index_set && index > 0) break; - fprintf (stderr, "Unable to open %s\n", argv[i]); + fprintf (stderr, _("Unable to open %s\n"), argv[i]); err = 1; } else @@ -189,7 +197,7 @@ main (int argc, char **argv) { FcChar32 ucs4, pos, map[FC_CHARSET_MAP_SIZE]; - printf ("%s:%d Missing %d glyph(s) to satisfy the coverage for %s language\n", + printf (_("%s:%d Missing %d glyph(s) to satisfy the coverage for %s language\n"), argv[i], index, count, lang); if (verbose) @@ -219,7 +227,7 @@ main (int argc, char **argv) } else { - printf ("%s:%d Satisfy the coverage for %s language\n", argv[i], index, lang); + printf (_("%s:%d Satisfy the coverage for %s language\n"), argv[i], index, lang); } FcCharSetDestroy (fcs); diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 4d902792..6ceabc35 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -280,7 +280,9 @@ typedef struct _FcObjectSet { } FcObjectSet; typedef enum _FcMatchKind { - FcMatchPattern, FcMatchFont, FcMatchScan + FcMatchPattern, FcMatchFont, FcMatchScan, + FcMatchKindEnd, + FcMatchKindBegin = FcMatchPattern } FcMatchKind; typedef enum _FcLangResult { @@ -295,6 +297,12 @@ typedef enum _FcSetName { FcSetApplication = 1 } FcSetName; +typedef struct _FcConfigFileInfoIter { + void *dummy1; + void *dummy2; + void *dummy3; +} FcConfigFileInfoIter; + typedef struct _FcAtomic FcAtomic; #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */ @@ -451,6 +459,21 @@ FcPublic void FcConfigSetSysRoot (FcConfig *config, const FcChar8 *sysroot); +FcPublic void +FcConfigFileInfoIterInit (FcConfig *config, + FcConfigFileInfoIter *iter); + +FcPublic FcBool +FcConfigFileInfoIterNext (FcConfig *config, + FcConfigFileInfoIter *iter); + +FcPublic FcBool +FcConfigFileInfoIterGet (FcConfig *config, + FcConfigFileInfoIter *iter, + FcChar8 **name, + FcChar8 **description, + FcBool *enabled); + /* fccharset.c */ FcPublic FcCharSet* FcCharSetCreate (void); diff --git a/fonts.conf.in b/fonts.conf.in index 7c16a707..2019923d 100644 --- a/fonts.conf.in +++ b/fonts.conf.in @@ -2,6 +2,11 @@ <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <!-- /etc/fonts/fonts.conf file to configure system font access --> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>Default configuration file</description> <!-- DO NOT EDIT THIS FILE. @@ -145,15 +145,30 @@ $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk po/Makefile \ po/POTFILES \ po/stamp-it \ + po/stamp-po \ po/.intltool-merge-cache \ "po/*.gmo" \ "po/*.mo" \ + "po/*.sed" \ po/$(GETTEXT_PACKAGE).pot \ intltool-extract.in \ intltool-merge.in \ intltool-update.in \ ; do echo /$$x; done; \ fi; \ + if test -f $(srcdir)/po-conf/Makefile.in.in; then \ + for x in \ + po-conf/Makefile.in \ + po-conf/Makefile \ + po-conf/POTFILES \ + po-conf/stamp-it \ + po-conf/stamp-po \ + "po-conf/*.gmo" \ + "po-conf/*.mo" \ + "po-conf/*.sed" \ + po-conf/$(GETTEXT_PACKAGE)-conf.pot \ + ; do echo /$$x; done; \ + fi; \ if test -f $(srcdir)/configure; then \ for x in \ autom4te.cache \ @@ -2,6 +2,11 @@ <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <!-- /etc/fonts/local.conf file for local customizations --> <fontconfig> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/> + </its:rules> + + <description>local customizations</description> <!-- Enable sub-pixel rendering <match target="font"> diff --git a/po-conf/ChangeLog b/po-conf/ChangeLog new file mode 100644 index 00000000..9b7898ab --- /dev/null +++ b/po-conf/ChangeLog @@ -0,0 +1,12 @@ +2015-01-28 gettextize <bug-gnu-gettext@gnu.org> + + * Makefile.in.in: New file, from gettext-0.19.4. + * Rules-quot: New file, from gettext-0.19.4. + * boldquot.sed: New file, from gettext-0.19.4. + * en@boldquot.header: New file, from gettext-0.19.4. + * en@quot.header: New file, from gettext-0.19.4. + * insert-header.sin: New file, from gettext-0.19.4. + * quot.sed: New file, from gettext-0.19.4. + * remove-potcdate.sin: New file, from gettext-0.19.4. + * POTFILES.in: New file. + diff --git a/po-conf/LINGUAS b/po-conf/LINGUAS new file mode 100644 index 00000000..e7604c12 --- /dev/null +++ b/po-conf/LINGUAS @@ -0,0 +1 @@ +# Please keep this list sorted alphabetically. diff --git a/po-conf/Makevars b/po-conf/Makevars new file mode 100644 index 00000000..b3cf99a8 --- /dev/null +++ b/po-conf/Makevars @@ -0,0 +1,78 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE)-conf + +# These two variables depend on the location of this directory. +subdir = po-conf +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Free Software Foundation, Inc. + +# This tells whether or not to prepend "GNU " prefix to the package +# name that gets inserted into the header of the $(DOMAIN).pot file. +# Possible values are "yes", "no", or empty. If it is empty, try to +# detect it automatically by scanning the files in $(top_srcdir) for +# "GNU packagename" string. +PACKAGE_GNU = no + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = + +# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' +# context. Possible values are "yes" and "no". Set this to yes if the +# package uses functions taking also a message context, like pgettext(), or +# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. +USE_MSGCTXT = no + +# These options get passed to msgmerge. +# Useful options are in particular: +# --previous to keep previous msgids of translated messages, +# --quiet to reduce the verbosity. +MSGMERGE_OPTIONS = + +# These options get passed to msginit. +# If you want to disable line wrapping when writing PO files, add +# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and +# MSGINIT_OPTIONS. +MSGINIT_OPTIONS = + +# This tells whether or not to regenerate a PO file when $(DOMAIN).pot +# has changed. Possible values are "yes" and "no". Set this to no if +# the POT file is checked in the repository and the version control +# program ignores timestamps. +PO_DEPENDS_ON_POT = yes + +# This tells whether or not to forcibly update $(DOMAIN).pot and +# regenerate PO files on "make dist". Possible values are "yes" and +# "no". Set this to no if the POT file and PO files are maintained +# externally. +DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/po-conf/POTFILES.in b/po-conf/POTFILES.in new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/po-conf/POTFILES.in diff --git a/po/ChangeLog b/po/ChangeLog new file mode 100644 index 00000000..9b7898ab --- /dev/null +++ b/po/ChangeLog @@ -0,0 +1,12 @@ +2015-01-28 gettextize <bug-gnu-gettext@gnu.org> + + * Makefile.in.in: New file, from gettext-0.19.4. + * Rules-quot: New file, from gettext-0.19.4. + * boldquot.sed: New file, from gettext-0.19.4. + * en@boldquot.header: New file, from gettext-0.19.4. + * en@quot.header: New file, from gettext-0.19.4. + * insert-header.sin: New file, from gettext-0.19.4. + * quot.sed: New file, from gettext-0.19.4. + * remove-potcdate.sin: New file, from gettext-0.19.4. + * POTFILES.in: New file. + diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 00000000..e7604c12 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +# Please keep this list sorted alphabetically. diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 00000000..0d699cc9 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,78 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Free Software Foundation, Inc. + +# This tells whether or not to prepend "GNU " prefix to the package +# name that gets inserted into the header of the $(DOMAIN).pot file. +# Possible values are "yes", "no", or empty. If it is empty, try to +# detect it automatically by scanning the files in $(top_srcdir) for +# "GNU packagename" string. +PACKAGE_GNU = no + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = + +# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' +# context. Possible values are "yes" and "no". Set this to yes if the +# package uses functions taking also a message context, like pgettext(), or +# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. +USE_MSGCTXT = no + +# These options get passed to msgmerge. +# Useful options are in particular: +# --previous to keep previous msgids of translated messages, +# --quiet to reduce the verbosity. +MSGMERGE_OPTIONS = + +# These options get passed to msginit. +# If you want to disable line wrapping when writing PO files, add +# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and +# MSGINIT_OPTIONS. +MSGINIT_OPTIONS = + +# This tells whether or not to regenerate a PO file when $(DOMAIN).pot +# has changed. Possible values are "yes" and "no". Set this to no if +# the POT file is checked in the repository and the version control +# program ignores timestamps. +PO_DEPENDS_ON_POT = yes + +# This tells whether or not to forcibly update $(DOMAIN).pot and +# regenerate PO files on "make dist". Possible values are "yes" and +# "no". Set this to no if the POT file and PO files are maintained +# externally. +DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 00000000..3b4697ea --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,11 @@ +# List of source files which contain translatable strings. +fc-cache/fc-cache.c +fc-cat/fc-cat.c +fc-conflist/fc-conflist.c +fc-list/fc-list.c +fc-match/fc-match.c +fc-pattern/fc-pattern.c +fc-query/fc-query.c +fc-scan/fc-scan.c +fc-validate/fc-validate.c +src/fccfg.c diff --git a/src/Makefile.am b/src/Makefile.am index 40a40f2b..b273ff32 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -79,7 +79,8 @@ AM_CPPFLAGS = \ $(EXPAT_CFLAGS) \ $(WARN_CFLAGS) \ -DFC_CACHEDIR='"$(FC_CACHEDIR)"' \ - -DFONTCONFIG_PATH='"$(BASECONFIGDIR)"' + -DFONTCONFIG_PATH='"$(BASECONFIGDIR)"' \ + -DFC_TEMPLATEDIR='"$(TEMPLATEDIR)"' EXTRA_DIST += makealias @@ -137,6 +138,7 @@ libfontconfig_la_SOURCES = \ fcformat.c \ fcfreetype.c \ fcfs.c \ + fcptrlist.c \ fcinit.c \ fclang.c \ fclist.c \ diff --git a/src/fccfg.c b/src/fccfg.c index 4b22d48d..e297a23e 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -26,6 +26,7 @@ #include "fcint.h" #include <dirent.h> +#include <locale.h> #include <sys/types.h> #if defined (_WIN32) && !defined (R_OK) @@ -38,7 +39,19 @@ static FcConfig * FcConfigEnsure (void) { FcConfig *config; -retry: + FcBool is_locale_initialized; + static void *static_is_locale_initialized; +retry_locale: + is_locale_initialized = (intptr_t) fc_atomic_ptr_get (&static_is_locale_initialized); + if (!is_locale_initialized) + { + is_locale_initialized = FcTrue; + if (!fc_atomic_ptr_cmpexch (&static_is_locale_initialized, NULL, + (void *)(long) is_locale_initialized)) + goto retry_locale; + setlocale (LC_ALL, ""); + } +retry_config: config = fc_atomic_ptr_get (&_fcConfig); if (!config) { @@ -46,7 +59,7 @@ retry: if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) { FcConfigDestroy (config); - goto retry; + goto retry_config; } } return config; @@ -72,6 +85,8 @@ FcConfigCreate (void) { FcSetName set; FcConfig *config; + FcMatchKind k; + FcBool err = FcFalse; config = malloc (sizeof (FcConfig)); if (!config) @@ -109,9 +124,15 @@ FcConfigCreate (void) if (!config->cacheDirs) goto bail8; - config->substPattern = 0; - config->substFont = 0; - config->substScan = 0; + for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++) + { + config->subst[k] = FcPtrListCreate ((FcDestroyFunc) FcRuleSetDestroy); + if (!config->subst[k]) + err = FcTrue; + } + if (err) + goto bail9; + config->maxObjects = 0; for (set = FcSetSystem; set <= FcSetApplication; set++) config->fonts[set] = 0; @@ -123,10 +144,24 @@ FcConfigCreate (void) config->sysRoot = NULL; + config->rulesetList = FcPtrListCreate ((FcDestroyFunc) FcRuleSetDestroy); + if (!config->rulesetList) + goto bail9; + config->availConfigFiles = FcStrSetCreate (); + if (!config->availConfigFiles) + goto bail10; + FcRefInit (&config->ref, 1); return config; +bail10: + FcPtrListDestroy (config->rulesetList); +bail9: + for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++) + if (config->subst[k]) + FcPtrListDestroy (config->subst[k]); + FcStrSetDestroy (config->cacheDirs); bail8: FcFontSetDestroy (config->rejectPatterns); bail7: @@ -204,21 +239,6 @@ FcConfigUptoDate (FcConfig *config) return FcTrue; } -static void -FcSubstDestroy (FcSubst *s) -{ - FcSubst *n; - - while (s) - { - n = s->next; - if (s->rule) - FcRuleDestroy (s->rule); - free (s); - s = n; - } -} - FcExpr * FcConfigAllocExpr (FcConfig *config) { @@ -258,6 +278,7 @@ FcConfigDestroy (FcConfig *config) { FcSetName set; FcExprPage *page; + FcMatchKind k; if (FcRefDec (&config->ref) != 1) return; @@ -273,9 +294,10 @@ FcConfigDestroy (FcConfig *config) FcFontSetDestroy (config->acceptPatterns); FcFontSetDestroy (config->rejectPatterns); - FcSubstDestroy (config->substPattern); - FcSubstDestroy (config->substFont); - FcSubstDestroy (config->substScan); + for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++) + FcPtrListDestroy (config->subst[k]); + FcPtrListDestroy (config->rulesetList); + FcStrSetDestroy (config->availConfigFiles); for (set = FcSetSystem; set <= FcSetApplication; set++) if (config->fonts[set]) FcFontSetDestroy (config->fonts[set]); @@ -652,61 +674,8 @@ FcConfigAddRule (FcConfig *config, FcRule *rule, FcMatchKind kind) { - FcSubst *subst, **prev; - FcRule *r; - int n = 0; - - if (!rule) - return FcFalse; - switch (kind) { - case FcMatchPattern: - prev = &config->substPattern; - break; - case FcMatchFont: - prev = &config->substFont; - break; - case FcMatchScan: - prev = &config->substScan; - break; - default: - return FcFalse; - } - subst = (FcSubst *) malloc (sizeof (FcSubst)); - if (!subst) - return FcFalse; - for (; *prev; prev = &(*prev)->next); - *prev = subst; - subst->next = NULL; - subst->rule = rule; - for (r = rule; r; r = r->next) - { - switch (r->type) - { - case FcRuleTest: - if (r->u.test && - r->u.test->kind == FcMatchDefault) - r->u.test->kind = kind; - - if (n < r->u.test->object) - n = r->u.test->object; - break; - case FcRuleEdit: - if (n < r->u.edit->object) - n = r->u.edit->object; - break; - default: - break; - } - } - n = FC_OBJ_ID (n) - FC_MAX_BASE_OBJECT; - if (config->maxObjects < n) - config->maxObjects = n; - if (FcDebug () & FC_DBG_EDIT) - { - printf ("Add Subst "); - FcSubstPrint (subst); - } - return FcTrue; + /* deprecated */ + return FcFalse; } static FcValue @@ -1536,8 +1505,10 @@ FcConfigSubstituteWithPat (FcConfig *config, FcMatchKind kind) { FcValue v; - FcSubst *s; + FcPtrList *s; + FcPtrListIter iter, iter2; FcRule *r; + FcRuleSet *rs; FcValueList *l, **value = NULL, *vl; FcPattern *m; FcStrSet *strs; @@ -1554,9 +1525,11 @@ FcConfigSubstituteWithPat (FcConfig *config, return FcFalse; } - switch (kind) { - case FcMatchPattern: - s = config->substPattern; + if (kind < FcMatchKindBegin || kind >= FcMatchKindEnd) + return FcFalse; + s = config->subst[kind]; + if (kind == FcMatchPattern) + { strs = FcGetDefaultLangs (); if (strs) { @@ -1616,15 +1589,6 @@ FcConfigSubstituteWithPat (FcConfig *config, if (prgname) FcPatternObjectAddString (p, FC_PRGNAME_OBJECT, prgname); } - break; - case FcMatchFont: - s = config->substFont; - break; - case FcMatchScan: - s = config->substScan; - break; - default: - return FcFalse; } nobjs = FC_MAX_BASE_OBJECT + config->maxObjects + 2; @@ -1652,186 +1616,192 @@ FcConfigSubstituteWithPat (FcConfig *config, printf ("FcConfigSubstitute "); FcPatternPrint (p); } - for (; s; s = s->next) + FcPtrListIterInit (s, &iter); + for (; FcPtrListIterIsValid (s, &iter); FcPtrListIterNext (s, &iter)) { - r = s->rule; - for (i = 0; i < nobjs; i++) - { - elt[i] = NULL; - value[i] = NULL; - tst[i] = NULL; - } - for (; r; r = r->next) + rs = (FcRuleSet *) FcPtrListIterGetValue (s, &iter); + FcPtrListIterInit (rs->subst[kind], &iter2); + for (; FcPtrListIterIsValid (rs->subst[kind], &iter2); FcPtrListIterNext (rs->subst[kind], &iter2)) { - switch (r->type) { - case FcRuleUnknown: - /* shouldn't be reached */ - break; - case FcRuleTest: - object = FC_OBJ_ID (r->u.test->object); - /* - * Check the tests to see if - * they all match the pattern - */ - if (FcDebug () & FC_DBG_EDIT) - { - printf ("FcConfigSubstitute test "); - FcTestPrint (r->u.test); - } - if (kind == FcMatchFont && r->u.test->kind == FcMatchPattern) - m = p_pat; - else - m = p; - if (m) - e = FcPatternObjectFindElt (m, r->u.test->object); - else - e = NULL; - /* different 'kind' won't be the target of edit */ - if (!elt[object] && kind == r->u.test->kind) - { - elt[object] = e; - tst[object] = r->u.test; - } - /* - * If there's no such field in the font, - * then FcQualAll matches while FcQualAny does not - */ - if (!e) - { - if (r->u.test->qual == FcQualAll) + r = (FcRule *) FcPtrListIterGetValue (rs->subst[kind], &iter2); + for (i = 0; i < nobjs; i++) + { + elt[i] = NULL; + value[i] = NULL; + tst[i] = NULL; + } + for (; r; r = r->next) + { + switch (r->type) { + case FcRuleUnknown: + /* shouldn't be reached */ + break; + case FcRuleTest: + object = FC_OBJ_ID (r->u.test->object); + /* + * Check the tests to see if + * they all match the pattern + */ + if (FcDebug () & FC_DBG_EDIT) { - value[object] = NULL; - continue; + printf ("FcConfigSubstitute test "); + FcTestPrint (r->u.test); } + if (kind == FcMatchFont && r->u.test->kind == FcMatchPattern) + m = p_pat; else + m = p; + if (m) + e = FcPatternObjectFindElt (m, r->u.test->object); + else + e = NULL; + /* different 'kind' won't be the target of edit */ + if (!elt[object] && kind == r->u.test->kind) + { + elt[object] = e; + tst[object] = r->u.test; + } + /* + * If there's no such field in the font, + * then FcQualAll matches while FcQualAny does not + */ + if (!e) + { + if (r->u.test->qual == FcQualAll) + { + value[object] = NULL; + continue; + } + else + { + if (FcDebug () & FC_DBG_EDIT) + printf ("No match\n"); + goto bail; + } + } + /* + * Check to see if there is a match, mark the location + * to apply match-relative edits + */ + vl = FcConfigMatchValueList (m, p_pat, kind, r->u.test, e->values); + /* different 'kind' won't be the target of edit */ + if (!value[object] && kind == r->u.test->kind) + value[object] = vl; + if (!vl || + (r->u.test->qual == FcQualFirst && vl != e->values) || + (r->u.test->qual == FcQualNotFirst && vl == e->values)) { if (FcDebug () & FC_DBG_EDIT) printf ("No match\n"); goto bail; } - } - /* - * Check to see if there is a match, mark the location - * to apply match-relative edits - */ - vl = FcConfigMatchValueList (m, p_pat, kind, r->u.test, e->values); - /* different 'kind' won't be the target of edit */ - if (!value[object] && kind == r->u.test->kind) - value[object] = vl; - if (!vl || - (r->u.test->qual == FcQualFirst && vl != e->values) || - (r->u.test->qual == FcQualNotFirst && vl == e->values)) - { + break; + case FcRuleEdit: + object = FC_OBJ_ID (r->u.edit->object); if (FcDebug () & FC_DBG_EDIT) - printf ("No match\n"); - goto bail; - } - break; - case FcRuleEdit: - object = FC_OBJ_ID (r->u.edit->object); - if (FcDebug () & FC_DBG_EDIT) - { - printf ("Substitute "); - FcEditPrint (r->u.edit); - printf ("\n\n"); - } - /* - * Evaluate the list of expressions - */ - l = FcConfigValues (p, p_pat,kind, r->u.edit->expr, r->u.edit->binding); - if (tst[object] && (tst[object]->kind == FcMatchFont || kind == FcMatchPattern)) - elt[object] = FcPatternObjectFindElt (p, tst[object]->object); - - switch (FC_OP_GET_OP (r->u.edit->op)) { - case FcOpAssign: + { + printf ("Substitute "); + FcEditPrint (r->u.edit); + printf ("\n\n"); + } /* - * If there was a test, then replace the matched - * value with the new list of values + * Evaluate the list of expressions */ - if (value[object]) - { - FcValueList *thisValue = value[object]; - FcValueList *nextValue = l; + l = FcConfigValues (p, p_pat,kind, r->u.edit->expr, r->u.edit->binding); + if (tst[object] && (tst[object]->kind == FcMatchFont || kind == FcMatchPattern)) + elt[object] = FcPatternObjectFindElt (p, tst[object]->object); + switch (FC_OP_GET_OP (r->u.edit->op)) { + case FcOpAssign: /* - * Append the new list of values after the current value + * If there was a test, then replace the matched + * value with the new list of values */ - FcConfigAdd (&elt[object]->values, thisValue, FcTrue, l, r->u.edit->object); + if (value[object]) + { + FcValueList *thisValue = value[object]; + FcValueList *nextValue = l; + + /* + * Append the new list of values after the current value + */ + FcConfigAdd (&elt[object]->values, thisValue, FcTrue, l, r->u.edit->object); + /* + * Delete the marked value + */ + if (thisValue) + FcConfigDel (&elt[object]->values, thisValue); + /* + * Adjust a pointer into the value list to ensure + * future edits occur at the same place + */ + value[object] = nextValue; + break; + } + /* fall through ... */ + case FcOpAssignReplace: /* - * Delete the marked value + * Delete all of the values and insert + * the new set */ - if (thisValue) - FcConfigDel (&elt[object]->values, thisValue); + FcConfigPatternDel (p, r->u.edit->object); + FcConfigPatternAdd (p, r->u.edit->object, l, FcTrue); /* - * Adjust a pointer into the value list to ensure - * future edits occur at the same place + * Adjust a pointer into the value list as they no + * longer point to anything valid */ - value[object] = nextValue; + value[object] = NULL; break; - } - /* fall through ... */ - case FcOpAssignReplace: - /* - * Delete all of the values and insert - * the new set - */ - FcConfigPatternDel (p, r->u.edit->object); - FcConfigPatternAdd (p, r->u.edit->object, l, FcTrue); - /* - * Adjust a pointer into the value list as they no - * longer point to anything valid - */ - value[object] = NULL; - break; - case FcOpPrepend: - if (value[object]) - { - FcConfigAdd (&elt[object]->values, value[object], FcFalse, l, r->u.edit->object); + case FcOpPrepend: + if (value[object]) + { + FcConfigAdd (&elt[object]->values, value[object], FcFalse, l, r->u.edit->object); + break; + } + /* fall through ... */ + case FcOpPrependFirst: + FcConfigPatternAdd (p, r->u.edit->object, l, FcFalse); break; - } - /* fall through ... */ - case FcOpPrependFirst: - FcConfigPatternAdd (p, r->u.edit->object, l, FcFalse); - break; - case FcOpAppend: - if (value[object]) - { - FcConfigAdd (&elt[object]->values, value[object], FcTrue, l, r->u.edit->object); + case FcOpAppend: + if (value[object]) + { + FcConfigAdd (&elt[object]->values, value[object], FcTrue, l, r->u.edit->object); + break; + } + /* fall through ... */ + case FcOpAppendLast: + FcConfigPatternAdd (p, r->u.edit->object, l, FcTrue); + break; + case FcOpDelete: + if (value[object]) + { + FcConfigDel (&elt[object]->values, value[object]); + break; + } + /* fall through ... */ + case FcOpDeleteAll: + FcConfigPatternDel (p, r->u.edit->object); + break; + default: + FcValueListDestroy (l); break; } - /* fall through ... */ - case FcOpAppendLast: - FcConfigPatternAdd (p, r->u.edit->object, l, FcTrue); - break; - case FcOpDelete: - if (value[object]) + /* + * Now go through the pattern and eliminate + * any properties without data + */ + FcConfigPatternCanon (p, r->u.edit->object); + + if (FcDebug () & FC_DBG_EDIT) { - FcConfigDel (&elt[object]->values, value[object]); - break; + printf ("FcConfigSubstitute edit"); + FcPatternPrint (p); } - /* fall through ... */ - case FcOpDeleteAll: - FcConfigPatternDel (p, r->u.edit->object); - break; - default: - FcValueListDestroy (l); break; } - /* - * Now go through the pattern and eliminate - * any properties without data - */ - FcConfigPatternCanon (p, r->u.edit->object); - - if (FcDebug () & FC_DBG_EDIT) - { - printf ("FcConfigSubstitute edit"); - FcPatternPrint (p); - } - break; } + bail:; } - bail:; } if (FcDebug () & FC_DBG_EDIT) { @@ -2204,6 +2174,36 @@ FcConfigFilename (const FcChar8 *url) return file; } +FcChar8 * +FcConfigRealFilename (FcConfig *config, + const FcChar8 *url) +{ + const FcChar8 *sysroot = FcConfigGetSysRoot (config); + FcChar8 *n = FcConfigFilename (url); + FcChar8 *nn = NULL; + + if (n) + { + char buf[PATH_MAX]; + ssize_t len; + + if (sysroot) + nn = FcStrBuildFilename (sysroot, n, NULL); + else + nn = FcStrdup (n); + FcStrFree (n); + + if ((len = readlink ((const char *) nn, buf, sizeof (buf) - 1)) != -1) + { + buf[len] = 0; + FcStrFree (nn); + nn = FcStrdup (buf); + } + } + + return nn; +} + /* * Manage the application-specific fonts */ @@ -2444,6 +2444,199 @@ FcConfigSetSysRoot (FcConfig *config, } } +FcRuleSet * +FcRuleSetCreate (const FcChar8 *name) +{ + FcRuleSet *ret = (FcRuleSet *) malloc (sizeof (FcRuleSet)); + FcMatchKind k; + const FcChar8 *p; + + if (!name) + p = (const FcChar8 *)""; + else + p = name; + + if (ret) + { + ret->name = FcStrdup (p); + ret->description = NULL; + ret->domain = NULL; + for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++) + ret->subst[k] = FcPtrListCreate ((FcDestroyFunc) FcRuleDestroy); + FcRefInit (&ret->ref, 1); + } + + return ret; +} + +void +FcRuleSetDestroy (FcRuleSet *rs) +{ + FcMatchKind k; + + if (!rs) + return; + if (FcRefDec (&rs->ref) != 1) + return; + + if (rs->name) + FcStrFree (rs->name); + if (rs->description) + FcStrFree (rs->description); + if (rs->domain) + FcStrFree (rs->domain); + for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++) + FcPtrListDestroy (rs->subst[k]); + + free (rs); +} + +void +FcRuleSetReference (FcRuleSet *rs) +{ + if (!FcRefIsConst (&rs->ref)) + FcRefInc (&rs->ref); +} + +void +FcRuleSetEnable (FcRuleSet *rs, + FcBool flag) +{ + if (rs) + { + rs->enabled = flag; + /* XXX: we may want to provide a feature + * to enable/disable rulesets through API + * in the future? + */ + } +} + +void +FcRuleSetAddDescription (FcRuleSet *rs, + const FcChar8 *domain, + const FcChar8 *description) +{ + if (rs->domain) + FcStrFree (rs->domain); + if (rs->description) + FcStrFree (rs->description); + + rs->domain = domain ? FcStrdup (domain) : NULL; + rs->description = FcStrdup (description); +} + +int +FcRuleSetAdd (FcRuleSet *rs, + FcRule *rule, + FcMatchKind kind) +{ + FcPtrListIter iter; + FcRule *r; + int n = 0, ret; + + if (!rs || + kind < FcMatchKindBegin || kind >= FcMatchKindEnd) + return -1; + FcPtrListIterInitAtLast (rs->subst[kind], &iter); + if (!FcPtrListIterAdd (rs->subst[kind], &iter, rule)) + return -1; + + for (r = rule; r; r = r->next) + { + switch (r->type) + { + case FcRuleTest: + if (r->u.test && + r->u.test->kind == FcMatchDefault) + r->u.test->kind = kind; + + if (n < r->u.test->object) + n = r->u.test->object; + break; + case FcRuleEdit: + if (n < r->u.edit->object) + n = r->u.edit->object; + break; + default: + break; + } + } + if (FcDebug () & FC_DBG_EDIT) + { + printf ("Add Rule "); + FcRulePrint (rule); + } + ret = FC_OBJ_ID (n) - FC_MAX_BASE_OBJECT; + + return ret < 0 ? 0 : ret; +} + +void +FcConfigFileInfoIterInit (FcConfig *config, + FcConfigFileInfoIter *iter) +{ + FcConfig *c; + FcPtrListIter *i = (FcPtrListIter *)iter; + + if (!config) + c = FcConfigGetCurrent (); + else + c = config; + FcPtrListIterInit (c->rulesetList, i); +} + +FcBool +FcConfigFileInfoIterNext (FcConfig *config, + FcConfigFileInfoIter *iter) +{ + FcConfig *c; + FcPtrListIter *i = (FcPtrListIter *)iter; + + if (!config) + c = FcConfigGetCurrent (); + else + c = config; + if (FcPtrListIterIsValid (c->rulesetList, i)) + { + FcPtrListIterNext (c->rulesetList, i); + } + else + return FcFalse; + + return FcTrue; +} + +FcBool +FcConfigFileInfoIterGet (FcConfig *config, + FcConfigFileInfoIter *iter, + FcChar8 **name, + FcChar8 **description, + FcBool *enabled) +{ + FcConfig *c; + FcRuleSet *r; + FcPtrListIter *i = (FcPtrListIter *)iter; + + if (!config) + c = FcConfigGetCurrent (); + else + c = config; + if (!FcPtrListIterIsValid (c->rulesetList, i)) + return FcFalse; + r = FcPtrListIterGetValue (c->rulesetList, i); + if (name) + *name = FcStrdup (r->name && r->name[0] ? r->name : (const FcChar8 *) "fonts.conf"); + if (description) + *description = FcStrdup (!r->description ? _("No description") : + dgettext (r->domain ? (const char *) r->domain : GETTEXT_PACKAGE "-conf", + (const char *) r->description)); + if (enabled) + *enabled = r->enabled; + + return FcTrue; +} + #define __fccfg__ #include "fcaliastail.h" #undef __fccfg__ diff --git a/src/fcdbg.c b/src/fcdbg.c index e0c78b72..2e16a312 100644 --- a/src/fcdbg.c +++ b/src/fcdbg.c @@ -479,6 +479,9 @@ FcTestPrint (const FcTest *test) case FcMatchScan: printf ("scan "); break; + case FcMatchKindEnd: + /* shouldn't be reached */ + return; } switch (test->qual) { case FcQualAny: @@ -511,13 +514,12 @@ FcEditPrint (const FcEdit *edit) } void -FcSubstPrint (const FcSubst *subst) +FcRulePrint (const FcRule *rule) { - FcRule *r; FcRuleType last_type = FcRuleUnknown; + const FcRule *r; - printf ("match\n"); - for (r = subst->rule; r; r = r->next) + for (r = rule; r; r = r->next) { if (last_type != r->type) { diff --git a/src/fcinit.c b/src/fcinit.c index 5e7c2f15..8bb0fd4f 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -86,6 +86,7 @@ FcInitLoadOwnConfig (FcConfig *config) return fallback; } + (void) FcConfigParseOnly (config, (const FcChar8 *)FC_TEMPLATEDIR, FcFalse); if (config->cacheDirs && config->cacheDirs->num == 0) { diff --git a/src/fcint.h b/src/fcint.h index 0869e9ec..2a6ec276 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -113,6 +113,17 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA; #define FcPrivate #endif +/* NLS */ +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + +#define N_(x) x + FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int)); #define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s))) @@ -303,6 +314,16 @@ typedef struct _FcEdit { FcValueBinding binding; } FcEdit; +typedef void (* FcDestroyFunc) (void *data); + +typedef struct _FcPtrList FcPtrList; +/* need to sync with FcConfigFileInfoIter at fontconfig.h */ +typedef struct _FcPtrListIter { + void *dummy1; + void *dummy2; + void *dummy3; +} FcPtrListIter; + typedef enum _FcRuleType { FcRuleUnknown, FcRuleTest, FcRuleEdit } FcRuleType; @@ -316,10 +337,14 @@ typedef struct _FcRule { } u; } FcRule; -typedef struct _FcSubst { - struct _FcSubst *next; - FcRule *rule; -} FcSubst; +typedef struct _FcRuleSet { + FcRef ref; + FcChar8 *name; + FcChar8 *description; + FcChar8 *domain; + FcBool enabled; + FcPtrList *subst[FcMatchKindEnd]; +} FcRuleSet; typedef struct _FcCharLeaf { FcChar32 map[256/32]; @@ -496,10 +521,12 @@ struct _FcConfig { * Substitution instructions for patterns and fonts; * maxObjects is used to allocate appropriate intermediate storage * while performing a whole set of substitutions + * + * 0.. substitutions for patterns + * 1.. substitutions for fonts + * 2.. substitutions for scanned fonts */ - FcSubst *substPattern; /* substitutions for patterns */ - FcSubst *substFont; /* substitutions for fonts */ - FcSubst *substScan; /* substitutions for scanned fonts */ + FcPtrList *subst[FcMatchKindEnd]; int maxObjects; /* maximum number of tests in all substs */ /* * List of patterns used to control font file selection @@ -529,6 +556,8 @@ struct _FcConfig { FcExprPage *expr_pool; /* pool of FcExpr's */ FcChar8 *sysRoot; /* override the system root directory */ + FcStrSet *availConfigFiles; /* config files available */ + FcPtrList *rulesetList; /* List of rulesets being installed */ }; typedef struct _FcFileTime { @@ -676,6 +705,29 @@ FcPrivate FcBool FcConfigAddCache (FcConfig *config, FcCache *cache, FcSetName set, FcStrSet *dirSet); +FcPrivate FcRuleSet * +FcRuleSetCreate (const FcChar8 *name); + +FcPrivate void +FcRuleSetDestroy (FcRuleSet *rs); + +FcPrivate void +FcRuleSetReference (FcRuleSet *rs); + +FcPrivate void +FcRuleSetEnable (FcRuleSet *rs, + FcBool flag); + +FcPrivate void +FcRuleSetAddDescription (FcRuleSet *rs, + const FcChar8 *domain, + const FcChar8 *description); + +FcPrivate int +FcRuleSetAdd (FcRuleSet *rs, + FcRule *rule, + FcMatchKind kind); + /* fcserialize.c */ FcPrivate intptr_t FcAlignSize (intptr_t size); @@ -791,7 +843,7 @@ FcPrivate void FcEditPrint (const FcEdit *edit); FcPrivate void -FcSubstPrint (const FcSubst *subst); +FcRulePrint (const FcRule *rule); FcPrivate void FcCharSetPrint (const FcCharSet *c); @@ -852,6 +904,42 @@ FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s); FcPrivate FcFontSet * FcFontSetDeserialize (const FcFontSet *set); +/* fcplist.c */ +FcPrivate FcPtrList * +FcPtrListCreate (FcDestroyFunc func); + +FcPrivate void +FcPtrListDestroy (FcPtrList *list); + +FcPrivate void +FcPtrListIterInit (const FcPtrList *list, + FcPtrListIter *iter); + +FcPrivate void +FcPtrListIterInitAtLast (FcPtrList *list, + FcPtrListIter *iter); + +FcPrivate FcBool +FcPtrListIterNext (const FcPtrList *list, + FcPtrListIter *iter); + +FcPrivate FcBool +FcPtrListIterIsValid (const FcPtrList *list, + const FcPtrListIter *iter); + +FcPrivate void * +FcPtrListIterGetValue (const FcPtrList *list, + const FcPtrListIter *iter); + +FcPrivate FcBool +FcPtrListIterAdd (FcPtrList *list, + FcPtrListIter *iter, + void *data); + +FcPrivate FcBool +FcPtrListIterRemove (FcPtrList *list, + FcPtrListIter *iter); + /* fcinit.c */ FcPrivate FcConfig * FcInitLoadOwnConfig (FcConfig *config); @@ -892,6 +980,15 @@ FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls); FcPrivate FcChar8 * FcNameUnparseEscaped (FcPattern *pat, FcBool escape); +FcPrivate FcBool +FcConfigParseOnly (FcConfig *config, + const FcChar8 *name, + FcBool complain); + +FcPrivate FcChar8 * +FcConfigRealFilename (FcConfig *config, + const FcChar8 *url); + /* fclist.c */ FcPrivate FcBool diff --git a/src/fcptrlist.c b/src/fcptrlist.c new file mode 100644 index 00000000..a0688dda --- /dev/null +++ b/src/fcptrlist.c @@ -0,0 +1,198 @@ +/* + * fontconfig/src/fcptrlist.c + * + * Copyright © 2000 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "fcint.h" + +typedef struct _FcPtrListEntry { + struct _FcPtrListEntry *next; + void *data; +} FcPtrListEntry; +struct _FcPtrList { + FcDestroyFunc destroy_func; + FcPtrListEntry *list; +}; +typedef struct _FcPtrListIterPrivate { + const FcPtrList *list; + FcPtrListEntry *entry; + FcPtrListEntry *prev; +} FcPtrListIterPrivate; + +FcPtrList * +FcPtrListCreate (FcDestroyFunc func) +{ + FcPtrList *ret = (FcPtrList *) malloc (sizeof (FcPtrList)); + + if (ret) + { + ret->destroy_func = func; + ret->list = NULL; + } + + return ret; +} + +void +FcPtrListDestroy (FcPtrList *list) +{ + FcPtrListIter iter; + + FcPtrListIterInit (list, &iter); + do + { + if (FcPtrListIterGetValue (list, &iter)) + list->destroy_func (FcPtrListIterGetValue (list, &iter)); + FcPtrListIterRemove (list, &iter); + } while (FcPtrListIterIsValid (list, &iter)); + + free (list); +} + +void +FcPtrListIterInit (const FcPtrList *list, + FcPtrListIter *iter) +{ + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + + priv->list = list; + priv->entry = list->list; + priv->prev = NULL; +} + +void +FcPtrListIterInitAtLast (FcPtrList *list, + FcPtrListIter *iter) +{ + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + FcPtrListEntry **e, **p; + + e = &list->list; + p = e; + for (; *e; p = e, e = &(*e)->next); + + priv->list = list; + priv->entry = *e; + priv->prev = *p; +} + +FcBool +FcPtrListIterNext (const FcPtrList *list, + FcPtrListIter *iter) +{ + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + + if (list != priv->list) + return FcFalse; + priv->prev = priv->entry; + priv->entry = priv->entry->next; + + return priv->entry != NULL; +} + +FcBool +FcPtrListIterIsValid (const FcPtrList *list, + const FcPtrListIter *iter) +{ + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + + return list == priv->list && priv->entry; +} + +void * +FcPtrListIterGetValue (const FcPtrList *list, + const FcPtrListIter *iter) +{ + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + + if (list != priv->list || + !priv->entry) + return NULL; + + return priv->entry->data; +} + +FcBool +FcPtrListIterAdd (FcPtrList *list, + FcPtrListIter *iter, + void *data) +{ + FcPtrListEntry *e; + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + + if (list != priv->list) + return FcFalse; + + e = (FcPtrListEntry *) malloc (sizeof (FcPtrListEntry)); + e->data = data; + + if (priv->entry) + { + e->next = priv->entry->next; + priv->entry->next = e; + } + else + { + e->next = NULL; + if (priv->prev) + { + priv->prev->next = e; + priv->entry = priv->prev; + } + else + { + list->list = e; + priv->entry = e; + + return FcTrue; + } + } + + return FcPtrListIterNext (list, iter); +} + +FcBool +FcPtrListIterRemove (FcPtrList *list, + FcPtrListIter *iter) +{ + FcPtrListIterPrivate *priv = (FcPtrListIterPrivate *) iter; + FcPtrListEntry *e; + + if (list != priv->list) + return FcFalse; + if (!priv->entry) + return FcTrue; + + if (list->list == priv->entry) + list->list = list->list->next; + e = priv->entry; + if (priv->prev) + priv->prev->next = priv->entry->next; + priv->entry = priv->entry->next; + free (e); + + return FcTrue; +} + +#define __fcplist__ +#include "fcaliastail.h" +#undef __fcplist__ diff --git a/src/fcxml.c b/src/fcxml.c index 0cf6ee54..9b1552ac 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -351,6 +351,7 @@ typedef enum _FcElement { FcElementConfig, FcElementMatch, FcElementAlias, + FcElementDescription, FcElementRescan, @@ -413,6 +414,7 @@ static const struct { { "config", FcElementConfig }, { "match", FcElementMatch }, { "alias", FcElementAlias }, + { "description", FcElementDescription }, { "rescan", FcElementRescan }, @@ -463,6 +465,11 @@ static const struct { }; #define NUM_ELEMENT_MAPS (int) (sizeof fcElementMap / sizeof fcElementMap[0]) +static const char *fcElementIgnoreName[16] = { + "its:", + NULL +}; + static FcElement FcElementMap (const XML_Char *name) { @@ -471,6 +478,9 @@ FcElementMap (const XML_Char *name) for (i = 0; i < NUM_ELEMENT_MAPS; i++) if (!strcmp ((char *) name, fcElementMap[i].name)) return fcElementMap[i].element; + for (i = 0; fcElementIgnoreName[i] != NULL; i++) + if (!strncmp ((char *) name, fcElementIgnoreName[i], strlen (fcElementIgnoreName[i]))) + return FcElementNone; return FcElementUnknown; } @@ -541,6 +551,7 @@ typedef struct _FcConfigParse { FcBool error; const FcChar8 *name; FcConfig *config; + FcRuleSet *ruleset; XML_Parser parser; unsigned int pstack_static_used; FcPStack pstack_static[8]; @@ -1163,7 +1174,9 @@ FcPStackPop (FcConfigParse *parse) return FcFalse; } - if (parse->pstack->attr) + /* Don't check the attributes for FcElementNone */ + if (parse->pstack->element != FcElementNone && + parse->pstack->attr) { /* Warn about unused attrs. */ FcChar8 **attrs = parse->pstack->attr; @@ -1193,7 +1206,11 @@ FcPStackPop (FcConfigParse *parse) } static FcBool -FcConfigParseInit (FcConfigParse *parse, const FcChar8 *name, FcConfig *config, XML_Parser parser) +FcConfigParseInit (FcConfigParse *parse, + const FcChar8 *name, + FcConfig *config, + XML_Parser parser, + FcBool enabled) { parse->pstack = 0; parse->pstack_static_used = 0; @@ -1202,7 +1219,10 @@ FcConfigParseInit (FcConfigParse *parse, const FcChar8 *name, FcConfig *config, parse->error = FcFalse; parse->name = name; parse->config = config; + parse->ruleset = FcRuleSetCreate (name); parse->parser = parser; + FcRuleSetEnable (parse->ruleset, enabled); + return FcTrue; } @@ -1211,6 +1231,8 @@ FcConfigCleanup (FcConfigParse *parse) { while (parse->pstack) FcPStackPop (parse); + FcRuleSetDestroy (parse->ruleset); + parse->ruleset = NULL; } static const FcChar8 * @@ -1727,6 +1749,7 @@ FcParseAlias (FcConfigParse *parse) FcVStack *vstack; FcRule *rule = NULL, *r; FcValueBinding binding; + int n; if (!FcConfigLexBinding (parse, FcConfigGetAttribute (parse, "binding"), &binding)) return; @@ -1869,8 +1892,29 @@ FcParseAlias (FcConfigParse *parse) r = r->next; } } - if (!FcConfigAddRule (parse->config, rule, FcMatchPattern)) + if ((n = FcRuleSetAdd (parse->ruleset, rule, FcMatchPattern)) == -1) FcRuleDestroy (rule); + else + if (parse->config->maxObjects < n) + parse->config->maxObjects = n; +} + +static void +FcParseDescription (FcConfigParse *parse) +{ + const FcChar8 *domain; + FcChar8 *desc; + + domain = FcConfigGetAttribute (parse, "domain"); + desc = FcStrBufDone (&parse->pstack->str); + if (!desc) + { + FcConfigMessage (parse, FcSevereError, "out of memory"); + return; + } + FcRuleSetAddDescription (parse->ruleset, domain, desc); + + FcStrFree (desc); } static FcExpr * @@ -2621,6 +2665,7 @@ FcParseMatch (FcConfigParse *parse) FcMatchKind kind; FcVStack *vstack; FcRule *rule = NULL, *r; + int n; kind_name = FcConfigGetAttribute (parse, "target"); if (!kind_name) @@ -2676,8 +2721,14 @@ FcParseMatch (FcConfigParse *parse) FcConfigMessage (parse, FcSevereWarning, "No <test> nor <edit> elements in <match>"); return; } - if (!FcConfigAddRule (parse->config, rule, kind)) + if ((n = FcRuleSetAdd (parse->ruleset, rule, kind)) == -1) + { FcConfigMessage (parse, FcSevereError, "out of memory"); + FcRuleDestroy (rule); + } + else + if (parse->config->maxObjects < n) + parse->config->maxObjects = n; } static void @@ -2884,6 +2935,9 @@ FcEndElement(void *userData, const XML_Char *name FC_UNUSED) case FcElementAlias: FcParseAlias (parse); break; + case FcElementDescription: + FcParseDescription (parse); + break; case FcElementRescan: FcParseRescan (parse); @@ -3085,7 +3139,8 @@ static FcBool FcConfigParseAndLoadDir (FcConfig *config, const FcChar8 *name, const FcChar8 *dir, - FcBool complain) + FcBool complain, + FcBool load) { DIR *d; struct dirent *e; @@ -3152,7 +3207,10 @@ FcConfigParseAndLoadDir (FcConfig *config, qsort (files->strs, files->num, sizeof (FcChar8 *), (int (*)(const void *, const void *)) FcSortCmpStr); for (i = 0; ret && i < files->num; i++) - ret = FcConfigParseAndLoad (config, files->strs[i], complain); + if (load) + ret = FcConfigParseAndLoad (config, files->strs[i], complain); + else + ret = FcConfigParseOnly (config, files->strs[i], complain); } bail3: FcStrSetDestroy (files); @@ -3173,13 +3231,16 @@ static FcBool FcConfigParseAndLoadFromMemoryInternal (FcConfig *config, const FcChar8 *filename, const FcChar8 *buffer, - FcBool complain) + FcBool complain, + FcBool load) { XML_Parser p; size_t len; FcConfigParse parse; FcBool error = FcTrue; + FcMatchKind k; + FcPtrListIter liter; #ifdef ENABLE_LIBXML2 xmlSAXHandler sax; @@ -3212,7 +3273,7 @@ FcConfigParseAndLoadFromMemoryInternal (FcConfig *config, if (!p) goto bail1; - if (!FcConfigParseInit (&parse, filename, config, p)) + if (!FcConfigParseInit (&parse, filename, config, p, load)) goto bail2; #ifndef ENABLE_LIBXML2 @@ -3262,6 +3323,24 @@ FcConfigParseAndLoadFromMemoryInternal (FcConfig *config, } while (buflen != 0); #endif error = parse.error; + if (load) + { + for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++) + { + FcPtrListIter iter; + + FcPtrListIterInit (parse.ruleset->subst[k], &iter); + if (FcPtrListIterIsValid (parse.ruleset->subst[k], &iter)) + { + FcPtrListIterInitAtLast (parse.config->subst[k], &iter); + FcRuleSetReference (parse.ruleset); + FcPtrListIterAdd (parse.config->subst[k], &iter, parse.ruleset); + } + } + } + FcPtrListIterInitAtLast (parse.config->rulesetList, &liter); + FcRuleSetReference (parse.ruleset); + FcPtrListIterAdd (parse.config->rulesetList, &liter, parse.ruleset); bail3: FcConfigCleanup (&parse); bail2: @@ -3275,23 +3354,15 @@ bail1: return FcTrue; } -FcBool -FcConfigParseAndLoadFromMemory (FcConfig *config, - const FcChar8 *buffer, - FcBool complain) -{ - return FcConfigParseAndLoadFromMemoryInternal (config, (const FcChar8 *)"memory", buffer, complain); -} - -FcBool -FcConfigParseAndLoad (FcConfig *config, - const FcChar8 *name, - FcBool complain) +static FcBool +_FcConfigParse (FcConfig *config, + const FcChar8 *name, + FcBool complain, + FcBool load) { - FcChar8 *filename, *f; + FcChar8 *filename = NULL, *realfilename = NULL; int fd; int len; - const FcChar8 *sysroot = FcConfigGetSysRoot (config); FcStrBuf sbuf; char buf[BUFSIZ]; FcBool ret = FcFalse; @@ -3312,40 +3383,40 @@ FcConfigParseAndLoad (FcConfig *config, } #endif - f = FcConfigFilename (name); - if (!f) + filename = FcConfigFilename (name); + if (!filename) goto bail0; - if (sysroot) - filename = FcStrBuildFilename (sysroot, f, NULL); - else - filename = FcStrdup (f); - FcStrFree (f); - - if (FcStrSetMember (config->configFiles, filename)) + realfilename = FcConfigRealFilename (config, name); + if (!realfilename) + goto bail0; + if (FcStrSetMember (config->availConfigFiles, realfilename)) { FcStrFree (filename); + FcStrFree (realfilename); return FcTrue; } - if (!FcStrSetAdd (config->configFiles, filename)) + if (load) { - FcStrFree (filename); - goto bail0; + if (!FcStrSetAdd (config->configFiles, filename)) + goto bail0; } + if (!FcStrSetAdd (config->availConfigFiles, realfilename)) + goto bail0; - if (FcFileIsDir (filename)) + if (FcFileIsDir (realfilename)) { - ret = FcConfigParseAndLoadDir (config, name, filename, complain); + ret = FcConfigParseAndLoadDir (config, name, realfilename, complain, load); FcStrFree (filename); + FcStrFree (realfilename); return ret; } FcStrBufInit (&sbuf, NULL, 0); fd = FcOpen ((char *) filename, O_RDONLY); - if (fd == -1) { + if (fd == -1) goto bail1; - } do { len = read (fd, buf, BUFSIZ); @@ -3359,12 +3430,15 @@ FcConfigParseAndLoad (FcConfig *config, } while (len != 0); close (fd); - ret = FcConfigParseAndLoadFromMemoryInternal (config, filename, FcStrBufDoneStatic (&sbuf), complain); + ret = FcConfigParseAndLoadFromMemoryInternal (config, filename, FcStrBufDoneStatic (&sbuf), complain, load); complain = FcFalse; /* no need to reclaim here */ bail1: - FcStrFree (filename); FcStrBufDestroy (&sbuf); bail0: + if (filename) + FcStrFree (filename); + if (realfilename) + FcStrFree (realfilename); if (!ret && complain) { if (name) @@ -3375,6 +3449,31 @@ bail0: } return FcTrue; } + +FcBool +FcConfigParseOnly (FcConfig *config, + const FcChar8 *name, + FcBool complain) +{ + return _FcConfigParse (config, name, complain, FcFalse); +} + +FcBool +FcConfigParseAndLoad (FcConfig *config, + const FcChar8 *name, + FcBool complain) +{ + return _FcConfigParse (config, name, complain, FcTrue); +} + +FcBool +FcConfigParseAndLoadFromMemory (FcConfig *config, + const FcChar8 *buffer, + FcBool complain) +{ + return FcConfigParseAndLoadFromMemoryInternal (config, (const FcChar8 *)"memory", buffer, complain, FcTrue); +} + #define __fcxml__ #include "fcaliastail.h" #undef __fcxml__ |