[Fontconfig] fontconfig: Branch 'fc-2_4-keithp' - 6 commits
Keith Packard
keithp at kemper.freedesktop.org
Sat Sep 2 14:55:31 PDT 2006
doc/fontconfig-user.sgml | 40 ++++++++++++++++++++-
fc-cache/fc-cache.c | 2 -
fc-cat/fc-cat.c | 2 -
fonts.conf.in | 17 ++++-----
src/fccache.c | 4 +-
src/fcdir.c | 17 ++-------
src/fcfreetype.c | 87 ++++++++++++++++++++++++++++++++++++-----------
src/fcstr.c | 24 +++++-------
8 files changed, 133 insertions(+), 60 deletions(-)
New commits:
diff-tree 3b8a03c09d3a45f578680b5fe80255af9761b3fa (from 9b511b290548ad2920cda94507a3311efc461e8a)
Author: Keith Packard <keithp at neko.keithp.com>
Date: Sat Sep 2 14:54:14 2006 -0700
Allow font caches to contain newer version numbers
Use the version number inside the cache file to mark backward compatible
changes while continuing to reserve the filename number for incompatible
changes.
diff --git a/src/fccache.c b/src/fccache.c
index af2c68f..05dc7ee 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -231,7 +231,7 @@ FcDirCacheMapFd (int fd, off_t size)
allocated = FcTrue;
}
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
- cache->version != FC_CACHE_CONTENT_VERSION ||
+ cache->version < FC_CACHE_CONTENT_VERSION ||
cache->size != size)
{
if (allocated)
@@ -323,7 +323,7 @@ FcDirCacheValidateHelper (int fd, off_t
ret = FcFalse;
else if (c.magic != FC_CACHE_MAGIC_MMAP)
ret = FcFalse;
- else if (c.version != FC_CACHE_CONTENT_VERSION)
+ else if (c.version < FC_CACHE_CONTENT_VERSION)
ret = FcFalse;
else if (fstat (fd, &file_stat) < 0)
ret = FcFalse;
diff-tree 9b511b290548ad2920cda94507a3311efc461e8a (from 813258dc8e3a8c964af49abe810e76a95241926d)
Author: Keith Packard <keithp at neko.keithp.com>
Date: Sat Sep 2 14:52:37 2006 -0700
Unify directory canonicalization into FcStrAddFilename.
Instead of making filename canonicalization occur in multiple places, it
occurs only in FcStrAddFilename now, as all filenames pass through that
function at one point.
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index 0686481..f20d3a7 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -452,7 +452,7 @@ main (int argc, char **argv)
}
while (argv[i])
{
- if (!FcStrSetAdd (dirs, (FcChar8 *) argv[i]))
+ if (!FcStrSetAddFilename (dirs, (FcChar8 *) argv[i]))
{
fprintf (stderr, "%s: Can't add directory\n", argv[0]);
return 1;
diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
index 71b416f..bb804ab 100644
--- a/fc-cat/fc-cat.c
+++ b/fc-cat/fc-cat.c
@@ -321,7 +321,7 @@ main (int argc, char **argv)
{
for (; i < argc; i++)
{
- if (!FcStrSetAdd (args, argv[i]))
+ if (!FcStrSetAddFilename (args, argv[i]))
{
fprintf (stderr, "%s: malloc failure\n", argv[0]);
return 1;
diff --git a/src/fcdir.c b/src/fcdir.c
index 0b7c8d8..8da50e9 100644
--- a/src/fcdir.c
+++ b/src/fcdir.c
@@ -234,26 +234,17 @@ FcCache *
FcDirCacheRead (const FcChar8 *dir, FcBool force, FcConfig *config)
{
FcCache *cache = NULL;
- FcChar8 *canon_dir;
- canon_dir = FcStrCanonFilename (dir);
- if (!canon_dir) canon_dir = (FcChar8 *) dir;
-
- if (config && !FcConfigAcceptFilename (config, canon_dir)) {
- goto bail;
- }
+ if (config && !FcConfigAcceptFilename (config, dir))
+ return NULL;
/* Try to use existing cache file */
if (!force)
- cache = FcDirCacheLoad (canon_dir, config, NULL);
+ cache = FcDirCacheLoad (dir, config, NULL);
/* Not using existing cache file, construct new cache */
if (!cache)
- cache = FcDirCacheScan (canon_dir, config);
-
-bail:
- if (canon_dir != dir)
- free (canon_dir);
+ cache = FcDirCacheScan (dir, config);
return cache;
}
diff --git a/src/fcstr.c b/src/fcstr.c
index b83a709..3309014 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -764,26 +764,21 @@ FcStrCopyFilename (const FcChar8 *s)
if (*s == '~')
{
FcChar8 *home = FcConfigHome ();
+ FcChar8 *full;
int size;
if (!home)
return 0;
size = strlen ((char *) home) + strlen ((char *) s);
- new = (FcChar8 *) malloc (size);
+ full = (FcChar8 *) malloc (size);
if (!new)
return 0;
- FcMemAlloc (FC_MEM_STRING, size);
- strcpy ((char *) new, (char *) home);
- strcat ((char *) new, (char *) s + 1);
+ strcpy ((char *) full, (char *) home);
+ strcat ((char *) full, (char *) s + 1);
+ new = FcStrCanonFilename (full);
+ free (full);
}
else
- {
- int size = strlen ((char *) s) + 1;
- new = (FcChar8 *) malloc (size);
- if (!new)
- return 0;
- FcMemAlloc (FC_MEM_STRING, size);
- memcpy (new, s, size);
- }
+ new = FcStrCanonFilename (s);
return new;
}
@@ -841,6 +836,7 @@ FcStrCanonFilename (const FcChar8 *s)
FcChar8 *file;
FcChar8 *f;
const FcChar8 *slash;
+ int size;
if (*s != '/')
{
@@ -855,9 +851,11 @@ FcStrCanonFilename (const FcChar8 *s)
FcStrFree (full);
return file;
}
- file = malloc (strlen ((char *) s) + 1);
+ size = strlen ((char *) s) + 1;
+ file = malloc (size);
if (!file)
return NULL;
+ FcMemAlloc (FC_MEM_STRING, size);
slash = NULL;
f = file;
for (;;) {
diff-tree 813258dc8e3a8c964af49abe810e76a95241926d (from 5cafbd4da08aa8110a94deba59dc631c39ef7285)
Author: Keith Packard <keithp at neko.keithp.com>
Date: Fri Sep 1 22:08:41 2006 -0700
Move Free family names to bottom of respective aliases. (bug 7429)
The FreeSans, FreeSerif and FreeMono fonts cover a large number of
languages, but are of generally poor quality. Moving these after fonts which
cover specific languages but which have higher quality glyphs should improve
font selection.
diff --git a/fonts.conf.in b/fonts.conf.in
index b8855ba..adc44e8 100644
--- a/fonts.conf.in
+++ b/fonts.conf.in
@@ -308,12 +308,12 @@
<family>Times</family>
<family>Frank Ruehl</family>
<family>MgOpen Canonica</family>
- <family>FreeSerif</family>
<family>Kochi Mincho</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>ï¼ï¼³ ææ</family>
<family>Baekmuk Batang</family>
+ <family>FreeSerif</family>
</prefer>
</alias>
<alias>
@@ -329,13 +329,13 @@
<family>Helvetica</family>
<family>Nachlieli</family>
<family>MgOpen Modata</family>
- <family>FreeSans</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>AR PL KaitiM Big5</family>
<family>ï¼ï¼³ ã´ã·ãã¯</family>
<family>Baekmuk Dotum</family>
<family>SimSun</family>
+ <family>FreeSans</family>
</prefer>
</alias>
<alias>
@@ -350,10 +350,10 @@
<family>Nimbus Mono L</family>
<family>Courier</family>
<family>Miriam Mono</family>
- <family>FreeMono</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>Baekmuk Dotum</family>
+ <family>FreeMono</family>
</prefer>
</alias>
diff-tree 5cafbd4da08aa8110a94deba59dc631c39ef7285 (from 7295c6f5faa595422e0825aa2e91883147d5b50e)
Author: Keith Packard <keithp at neko.keithp.com>
Date: Fri Sep 1 22:04:52 2006 -0700
Document FC_DEBUG values (bug 6393). Document name \ escape syntax.
Limited FC_DEBUG documentation (just shows values and vague idea of what
they're related to). Also document \ escape syntax for font names, including
how family name and values have different escape requirements.
diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml
index 6c2a446..32a637c 100644
--- a/doc/fontconfig-user.sgml
+++ b/doc/fontconfig-user.sgml
@@ -3,8 +3,6 @@
<!ENTITY confdir SYSTEM "confdir.sgml">
]>
<!--
- $Id$
-
Copyright © 2003 Keith Packard
Permission to use, copy, modify, distribute, and sell this software and its
@@ -215,8 +213,46 @@ Here are some examples:
Monospace:matrix=1 .1 0 1 The users preferred monospace font
with artificial obliquing
</programlisting>
+ <para>
+The '\', '-', ':' and ',' characters in family names must be preceeded by a
+'\' character to avoid having them misinterpreted. Similarly, values
+containing '\', '=', '_', ':' and ',' must also have them preceeded by a
+'\' character. The '\' characters are stripped out of the family name and
+values as the font name is read.
+ </para>
</refsect2>
</refsect1>
+<refsect1><title>Debugging Applications</title>
+ <para>
+To help diagnose font and applications problems, fontconfig is built with a
+large amount of internal debugging left enabled. It is controlled by means
+of the FC_DEBUG environment variable. The value of this variable is
+interpreted as a number, and each bit within that value controls different
+debugging messages.
+ </para>
+ <programlisting>
+ Name Value Meaning
+ ---------------------------------------------------------
+ MATCH 1 Brief information about font matching
+ MATCHV 2 Extensive font matching information
+ EDIT 4 Monitor match/test/edit execution
+ FONTSET 8 Track loading of font information at startup
+ CACHE 16 Watch cache files being written
+ CACHEV 32 Extensive cache file writing information
+ PARSE 64 (no longer in use)
+ SCAN 128 Watch font files being scanned to build caches
+ SCANV 256 Verbose font file scanning information
+ MEMORY 512 Monitor fontconfig memory usage
+ CONFIG 1024 Monitor which config files are loaded
+ LANGSET 2048 Dump char sets used to construct lang values
+ OBJTYPES 4096 Display message when value typechecks fail
+ </programlisting>
+ <para>
+Add the value of the desired debug levels together and assign that (in
+base 10) to the FC_DEBUG environment variable before running the
+application. Output from these statements is sent to stdout.
+ </para>
+</refsect1>
<refsect1><title>Lang Tags</title>
<para>
Each font in the database contains a list of languages it supports. This is
diff-tree 7295c6f5faa595422e0825aa2e91883147d5b50e (from db970d3596fbbc75f652f1a9fe7f7ce98e651ad2)
Author: Keith Packard <keithp at neko.keithp.com>
Date: Fri Sep 1 21:30:54 2006 -0700
Guess that mac roman names with lots of high bits are actually SJIS.
Many Japanese fonts incorrectly include names tagged as Roman encoding and
English language which are actually Japanese names in the SJIS encoding.
Guess that names with a large number of high bits set are SJIS encoded
Japanese names rather than English names.
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index f85e2f8..082d17b 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -560,6 +560,28 @@ FcFontCapabilities(FT_Face face);
#include <iconv.h>
#endif
+/*
+ * A shift-JIS will have many high bits turned on
+ */
+static FcBool
+FcLooksLikeSJIS (FcChar8 *string, int len)
+{
+ int nhigh = 0, nlow = 0;
+
+ while (len-- > 0)
+ {
+ if (*string++ & 0x80) nhigh++;
+ else nlow++;
+ }
+ /*
+ * Heuristic -- if more than 1/3 of the bytes have the high-bit set,
+ * this is likely to be SJIS and not ROMAN
+ */
+ if (nhigh * 2 > nlow)
+ return FcTrue;
+ return FcFalse;
+}
+
static FcChar8 *
FcSfntNameTranscode (FT_SfntName *sname)
{
@@ -580,24 +602,35 @@ FcSfntNameTranscode (FT_SfntName *sname)
fromcode = fcFtEncoding[i].fromcode;
/*
- * "real" Mac language IDs are all less than 150.
- * Names using one of the MS language IDs are assumed
- * to use an associated encoding (Yes, this is a kludge)
- */
- if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN) &&
- sname->language_id >= 0x100)
- {
- int f;
-
- fromcode = NULL;
- for (f = 0; f < NUM_FC_MAC_ROMAN_FAKE; f++)
- if (fcMacRomanFake[f].language_id == sname->language_id)
- {
- fromcode = fcMacRomanFake[f].fromcode;
- break;
- }
- if (!fromcode)
- return 0;
+ * Many names encoded for TT_PLATFORM_MACINTOSH are broken
+ * in various ways. Kludge around them.
+ */
+ if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN))
+ {
+ if (sname->language_id == TT_MAC_LANGID_ENGLISH &&
+ FcLooksLikeSJIS (sname->string, sname->string_len))
+ {
+ fromcode = "SJIS";
+ }
+ else if (sname->language_id >= 0x100)
+ {
+ /*
+ * "real" Mac language IDs are all less than 150.
+ * Names using one of the MS language IDs are assumed
+ * to use an associated encoding (Yes, this is a kludge)
+ */
+ int f;
+
+ fromcode = NULL;
+ for (f = 0; f < NUM_FC_MAC_ROMAN_FAKE; f++)
+ if (fcMacRomanFake[f].language_id == sname->language_id)
+ {
+ fromcode = fcMacRomanFake[f].fromcode;
+ break;
+ }
+ if (!fromcode)
+ return 0;
+ }
}
if (!strcmp (fromcode, "UCS-2BE") || !strcmp (fromcode, "UTF-16BE"))
{
@@ -738,10 +771,24 @@ static const FcChar8 *
FcSfntNameLanguage (FT_SfntName *sname)
{
int i;
+ FT_UShort platform_id = sname->platform_id;
+ FT_UShort language_id = sname->language_id;
+
+ /*
+ * Many names encoded for TT_PLATFORM_MACINTOSH are broken
+ * in various ways. Kludge around them.
+ */
+ if (platform_id == TT_PLATFORM_MACINTOSH &&
+ sname->encoding_id == TT_MAC_ID_ROMAN &&
+ FcLooksLikeSJIS (sname->string, sname->string_len))
+ {
+ language_id = TT_MAC_LANGID_JAPANESE;
+ }
+
for (i = 0; i < NUM_FC_FT_LANGUAGE; i++)
- if (fcFtLanguage[i].platform_id == sname->platform_id &&
+ if (fcFtLanguage[i].platform_id == platform_id &&
(fcFtLanguage[i].language_id == TT_LANGUAGE_DONT_CARE ||
- fcFtLanguage[i].language_id == sname->language_id))
+ fcFtLanguage[i].language_id == language_id))
{
if (fcFtLanguage[i].lang[0] == '\0')
return NULL;
diff-tree db970d3596fbbc75f652f1a9fe7f7ce98e651ad2 (from 3bb1812f0d173b153415e2191ecdd27a95fc4b05)
Author: Keith Packard <keithp at neko.keithp.com>
Date: Fri Sep 1 21:12:44 2006 -0700
Prefer Bitstream Vera to DejaVu families.
DejaVu is a modified version of Bitstream Vera that covers significantly
more languages, but does so with spotty quality, lacking hinting for many
glyphs, especially for the synthesized serif oblique face. Use Bitstream
Vera (where installed).
diff --git a/fonts.conf.in b/fonts.conf.in
index 0629c80..b8855ba 100644
--- a/fonts.conf.in
+++ b/fonts.conf.in
@@ -77,8 +77,8 @@
Serif faces
-->
<alias>
- <family>DejaVu Serif</family>
<family>Bitstream Vera Serif</family>
+ <family>DejaVu Serif</family>
<family>Times New Roman</family>
<family>Thorndale AMT</family>
<family>Times</family>
@@ -97,8 +97,8 @@
Sans-serif faces
-->
<alias>
- <family>DejaVu Sans</family>
<family>Bitstream Vera Sans</family>
+ <family>DejaVu Sans</family>
<family>Helvetica</family>
<family>Arial</family>
<family>Verdana</family>
@@ -119,6 +119,7 @@
Monospace faces
-->
<alias>
+ <family>Bitstream Vera Sans Mono</family>
<family>DejaVu Sans Mono</family>
<family>Courier</family>
<family>Courier New</family>
@@ -298,8 +299,8 @@
<alias>
<family>serif</family>
<prefer>
- <family>DejaVu Serif</family>
<family>Bitstream Vera Serif</family>
+ <family>DejaVu Serif</family>
<family>Times New Roman</family>
<family>Thorndale AMT</family>
<family>Luxi Serif</family>
@@ -318,8 +319,8 @@
<alias>
<family>sans-serif</family>
<prefer>
- <family>DejaVu Sans</family>
<family>Bitstream Vera Sans</family>
+ <family>DejaVu Sans</family>
<family>Verdana</family>
<family>Arial</family>
<family>Albany AMT</family>
@@ -340,8 +341,8 @@
<alias>
<family>monospace</family>
<prefer>
- <family>DejaVu Sans Mono</family>
<family>Bitstream Vera Sans Mono</family>
+ <family>DejaVu Sans Mono</family>
<family>Andale Mono</family>
<family>Courier New</family>
<family>Cumberland AMT</family>
More information about the Fontconfig
mailing list