Keith Packard [Sun, 3 Sep 2006 00:52:12 +0000 (17:52 -0700)]
Add FcMatchScan to resolve Delicious font matching issues (bug #6769)
The Delicious family includes one named Delicious Heavy, a bold variant
which is unfortunately marked as having normal weight. Because the family
name is 'Delicious', fontconfig accidentally selects this font instead of
the normal weight variant. The fix here rewrites the scanned data by running
the scanned pattern through a new substitution sequence tagged with
<match target=scan>; a sample for the Delicious family is included to
demonstrate how it works (and fix Delicious at the same time).
Also added was a new match predicate -- the 'decorative' predicate which is
automatically detected in fonts by searching style names for key decorative
phrases like SmallCaps, Shadow, Embosed and Antiqua. Suggestions for
additional decorative key words are welcome. This should have little effect
on font matching except when two fonts share the same characteristics except
for this value.
Keith Packard [Sat, 2 Sep 2006 21:54:14 +0000 (14:54 -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.
Keith Packard [Sat, 2 Sep 2006 21:52:37 +0000 (14:52 -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.
Keith Packard [Sat, 2 Sep 2006 05:08:41 +0000 (22:08 -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.
Keith Packard [Sat, 2 Sep 2006 05:04:52 +0000 (22:04 -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.
Keith Packard [Sat, 2 Sep 2006 04:30:54 +0000 (21:30 -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.
Keith Packard [Sat, 2 Sep 2006 04:12:44 +0000 (21:12 -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).
Keith Packard [Fri, 1 Sep 2006 22:33:27 +0000 (15:33 -0700)]
Fonts matching lang not territory should satisfy sort pattern lang.
A pattern specifying 'Chinese' (:lang=zh) without a territory should be
satisfied by any font supporting any Chinese lang. The code was requiring
that the lang tags match exactly, causing this sort to fail.
Keith Packard [Fri, 1 Sep 2006 19:45:43 +0000 (12:45 -0700)]
Chinese/Macau needs the Hong Kong orthography instead of Taiwan (bug 7884)
From Abel Cheung:
Currently zh_mo.orth includes zh_tw.orth, which means it is assumed Macau
only uses traditional Chinese characters used in Taiwan; however that is
wrong, as a majority of Macau people speaks Cantonese too, and also uses
additional traditional Chinese chars from Hong Kong (there are already some
place names that can't be represented in just chars used in Taiwan). So it
should include zh_hk.orth instead.
Keith Packard [Fri, 1 Sep 2006 09:22:59 +0000 (02:22 -0700)]
Fontset pattern references are relative to fontset, not array.
Within a fontset, the patterns are stored as pointers in an array.
When stored as offsets, the offsets are relative to the fontset object
itself, not the base of the array of pointers.
Keith Packard [Fri, 1 Sep 2006 08:49:47 +0000 (01:49 -0700)]
Fix fc-lang to use new charset freezer API.
Charset freezer api now uses allocated object. Also required minor fixes to
charset freezer code to remove assumption that all input charsets are
persistant.
Keith Packard [Fri, 1 Sep 2006 08:15:14 +0000 (01:15 -0700)]
Pass directory information around in FcCache structure. Freeze charsets.
Instead of passing directory information around in separate variables,
collect it all in an FcCache structure. Numerous internal and tool
interfaces changed as a result of this.
Charsets are now pre-frozen before being serialized. This causes them to
share across multiple fonts in the same cache.
Keith Packard [Thu, 31 Aug 2006 18:56:43 +0000 (11:56 -0700)]
With no args, fc-cat now dumps all directories.
Automatically list all font directories when no arguments are given to
fc-cat. Also add -r option to recurse from specified cache directories.
fc-cat also now prints the cache filename in verbose mode, along with the
related directory name.
Keith Packard [Thu, 31 Aug 2006 04:59:53 +0000 (21:59 -0700)]
Skip broken caches. Cache files are auto-written, don't rewrite in fc-cache.
Validate cache contents and skip broken caches, looking down cache path for
valid ones.
Every time a directory is scanned, it will be written to a cache file if
possible, so fc-cache doesn't need to re-write the cache file. This makes
detecting when the cache was generated a bit tricky, so we guess that if the
cache wasn't valid before running and is valid afterwards, the cache file
was written.
Also, allow empty charsets to be serialized with null leaves/numbers.
Eliminate a leak in FcEdit by switching to FcObject sooner.
Keith Packard [Thu, 31 Aug 2006 01:50:58 +0000 (18:50 -0700)]
Rework Object name database to unify typechecking and object lookup.
Eliminate ancient list of object name databases and load names into single
hash table that includes type information. Typecheck all pattern values to
avoid mis-typed pattern elements.
Keith Packard [Wed, 30 Aug 2006 11:24:03 +0000 (04:24 -0700)]
Fix build problems caused by cache rework.
Pagesize no longer matters in architecture decisions, the entire cache file
is mmaped into the library. However, lots of intptr_t values are in use now,
so that value is important.
fc-lang now requires fcserialize.c, which has been added to the repository.
Keith Packard [Wed, 30 Aug 2006 11:16:22 +0000 (04:16 -0700)]
Rework cache files to use offsets for all data structures.
Replace all of the bank/id pairs with simple offsets, recode several
data structures to always use offsets inside the library to avoid
conditional paths. Exposed data structures use pointers to hold offsets,
setting the low bit to distinguish between offset and pointer.
Use offset-based data structures for lang charset encodings; eliminates
separate data structure format for that file.
Much testing will be needed; offsets are likely not detected everywhere in
the library yet.
Keith Packard [Mon, 28 Aug 2006 18:51:12 +0000 (11:51 -0700)]
Revert to original FcFontSetMatch algorithm to avoid losing fonts.
The fancy new FcFontSetMatch algorithm would discard fonts for the
wrong reasons; fc-match sans:lang=en,ja would discard all fonts without
Japanese support. This commit reverts to the original algorithm which
ensure that FcFontSetMatch always matches the first font in the
FcFontSetSort return list.
Keith Packard [Mon, 28 Aug 2006 17:30:22 +0000 (10:30 -0700)]
During test run, remove cache directory to avoid stale cache usage.
As file timestamps have only one second granularity, an old cache
file could easily be used when a test took less than 1 second to run.
Just remove the cache directory and its contents before each test is run.
Also, remove mention of the old cache file from the test config file.
Keith Packard [Mon, 28 Aug 2006 06:40:51 +0000 (23:40 -0700)]
Eliminate ./ and ../ elements from font directory names when scanning.
FcStrCanonFilename eliminates ./ and ../ elements from pathnames through
simple string editing. Also, relative path names are fixed by prepending the
current working directory.
Keith Packard [Mon, 28 Aug 2006 04:53:48 +0000 (21:53 -0700)]
Eliminate global cache. Eliminate multi-arch cache code.
With the removal of the in-directory cache files, and the addition of
per-user cache directories, there is no longer any reason to preserve the
giant global cache file. Eliminating of this unifies the cache structure
and simplifies the overall caching strategies greatly.
Keith Packard [Mon, 28 Aug 2006 01:19:39 +0000 (18:19 -0700)]
Eliminate NormalizeDir. Eliminate gratuitous stat/access calls per dir.
Normalized directory names offer protection against looped directory trees
but cost enormous numbers of system calls (stat per file in the hierarchy).
Also, cache file directory name contents are validated each time the
directory is modified, don't re-validate every time the cache file is loaded
with an access and stat call.
Keith Packard [Mon, 28 Aug 2006 00:04:01 +0000 (17:04 -0700)]
Write caches to first directory with permission. Valid cache in FcDirCacheOpen.
Previous policy was to attempt to update the cache in place and bail if that
didn't work. Now, search for the first writable directory and place the
cache file there instead. Furthermore, on startup, search directory list for
valid cache files instead of bailing if the first found cache file wasn't
valid.
Keith Packard [Sun, 27 Aug 2006 23:25:07 +0000 (16:25 -0700)]
Construct short architecture name from architecture signature.
Map existing architecture signature to short architecture name
at build time. This architecture name is (as yet) unused, but will be used
to build per-architecture cache files with names made unique by including
the architecture name. The auto-detected architecture name can be overridden
with the --with-arch=ARCH configure option.
Patrick Lam [Fri, 4 Aug 2006 16:13:00 +0000 (16:13 +0000)]
2006-08-04 Keith Packard (keithp@keithp.com) reviewed by: plam
Make cache directories configurable. Simplify and correct some code which
deals with per-directory caches.
Patrick Lam [Thu, 27 Apr 2006 08:13:45 +0000 (08:13 +0000)]
Keith Packard <keithp@keithp.com>
Reduce transient memory usage during config file parsing by allocating
smaller buffers (64 seems to be a magic number).
Keith Packard [Thu, 27 Apr 2006 07:11:44 +0000 (07:11 +0000)]
Make path names in cache files absolute (NB, cache format change) Stop
permitting cache files to be stored in font dirs. Bump cache magic.
Don't include /fonts.cache-2 in cache hash construction.
reviewed by: Patrick Lam <plam@mit.edu>
Patrick Lam [Mon, 10 Apr 2006 15:46:34 +0000 (15:46 +0000)]
Fix double free (spotted by Coverity, CID #1965).
Check if pattern is not null before using it (Coverity defect #1883).
Fix memory leak with hash collision (Coverity defect #1829).
Fix memory leak when bail cases (Coverity defect #1828).
Don't leak directory name (Coverity defect #1827).
reviewed by: plam