Commit Graph

746 Commits

Author SHA1 Message Date
Behdad Esfahbod f9feb587fa [win32] Do not remove leading '\\' such that network paths work
Raised by Diego Santa Cruz.
2009-02-15 13:40:24 -08:00
Behdad Esfahbod 1cdf7efb22 [win32] Expand "APPSHAREFONTDIR" to ../share/fonts relative to binary location
Proposed by Diego Santa Cruz.
2009-02-15 13:40:24 -08:00
Behdad Esfahbod e62058abb9 [win32] Fix usage of GetFullPathName()
Diego Santa Cruz pointed out that we are using that API wrongly.
The forth argument is a pointer to a pointer.  Turns out we don't
need that arugment and it accepts NULL, so just pass that.
2009-02-15 13:40:24 -08:00
Behdad Esfahbod 574805478c [fcfreetype] Fix typo in GB2312 encoding name string (#19845)
This was causing failure when opening iconv converter, hence rendering
GB2312-encoded fonts with no other usable encoding unusable.
2009-02-15 13:40:18 -08:00
Karl Tomlinson 575ee6cddd Change FcCharSetMerge API
To only work on writable charsets.  Also, return a bool indicating whether
the merge changed the charset.

Also changes the implementation of FcCharSetMerge and FcCharSetIsSubset
2009-02-15 13:40:18 -08:00
Behdad Esfahbod b8860e2faf [fcmatch] Fix crash when no fonts are available. 2009-02-15 13:40:17 -08:00
Behdad Esfahbod 263f16ced2 Oops, fix FcPatternFilter 2009-02-13 16:54:06 -08:00
Behdad Esfahbod 4074fd254e Revive FcConfigScan() (bug #17121)
FcConfigScan() with parameters cache=NULL and force=FcTrue can be used
to scan font dirs without any caching side effect.
2009-02-13 16:54:06 -08:00
Behdad Esfahbod 25a09eb9bf Don't use FcCharSetCopy in FcCharSetMerge
The Copy function is actually a ref, not real copy.
2009-02-13 16:54:06 -08:00
Behdad Esfahbod d230cf144f Make FcCharSetMerge() public
That's needed for apps to be abled to do pruning themselves without
the performance penalty of recreating new charsets all the time.
2009-02-13 16:54:05 -08:00
Behdad Esfahbod 6d764a3f9b [fcmatch] Move FcFontSetMatch() functionality into FcFontSetMatchInternal()
Except for the final FcFontRenderPrepare().  This way we have more
flexibility to do caching in FcFontMatch() while leaving FcFontSetMatch()
intact.
2009-02-13 16:54:05 -08:00
Behdad Esfahbod a5a384c5ff [fcmatch] When matching, reserve score 0 for when elements don't exist
Previously an index j was added to element score to prefer matches earlier
in the value list to the later ones.  This index started from 0, meaning
that the score zero could be generated for the first element.  By starting
j from one, scores for when the element exists in both pattern and font
can never be zero.  The score zero is reserved for when the element is
NOT available in both font and pattern.  We will use this property later.

This shouldn't change matching much.  The only difference I can think of
is that if a font family exists both as a bitmap font and a scalable
version, and when requesting it at the size of the bitmap version,
previously the font returned was nondeterministic.  Now the scalable
version will always be preferred.
2009-02-13 16:54:05 -08:00
Behdad Esfahbod c7641f2872 [fcmatch] Use larger multipliers to enforce order
Previously the matcher multiplied comparison results by 100 and added
index value to it.  With long lists of families (lots of aliases),
reaching 100 is not that hard.  That could result in a non-match early
in the list to be preferred over a match late in the list.  Changing
the multiplier from 100 to 1000 should fix that.

To keep things relatively in order, the lang multiplier is changed
from 1000 to 10000.
2009-02-13 16:54:05 -08:00
Behdad Esfahbod 1b43ccc805 [fcmatch.c] Fix debug formatting 2009-02-13 16:54:04 -08:00
Behdad Esfahbod a291cfc710 Fix comparison of family names to ignore leading space properly
Previously fc-match "xxx,nazli" matched Nazli, but "xxx, nazli" didn't.
This was because of a bug in FcCompareFamily's short-circuit check
that forgot to ignore spaces.
2009-02-13 16:54:04 -08:00
Behdad Esfahbod 0c93b91db0 Implement FcPatternFormat and use it in cmdline tools (bug #17107)
Still need to add more features, but the API is there, and used
by cmdline tools with -f or --format.
2009-02-13 16:54:04 -08:00
Behdad Esfahbod f9806ab4b9 Remove special-casing of FC_FILE in FcPatternPrint()
I can't understand why the special case is needed.  Indeed, removing it
does not make any difference in the "fc-match --verbose" output, and
that's the only time fc-match uses FcPatternPrint.
2009-02-13 16:54:03 -08:00
Behdad Esfahbod 8ae1e3d5dc Explicitly chmod() directories (bug #18934)
Two changes:

  - after mkdir(), we immediately chmod(), such that we are not affected
    by stupid umask's.

  - if a directory we want to use is not writable but exists, we try a
    chmod on it.  This is to recover from stupid umask's having affected
    us with older versions.
2009-02-13 16:54:03 -08:00
Behdad Esfahbod b6cf885a0a Don't use identifier named complex 2009-02-13 16:54:03 -08:00
Behdad Esfahbod 00c0972aca Fix compile with old FreeType that doesn't have FT_Select_Size() (bug #17498) 2009-02-13 16:54:02 -08:00
Behdad Esfahbod 350dc5f350 Use __builtin_popcount() when available (bug #17592) 2009-02-13 16:54:02 -08:00
Behdad Esfahbod f69db8d49c Consistently use FcStat() over stat() in all places 2009-02-13 16:54:01 -08:00
Behdad Esfahbod 9e2ed2513b [fccache] Consistently use FcStat() over stat() (bug #18195) 2009-02-13 16:54:01 -08:00
Harald Fernengel fe8e8a1dd7 Don't use variables named 'bool' (bug #18851) 2009-02-13 16:54:01 -08:00
Behdad Esfahbod 355ed50b18 Don't call FcPatternGetCharSet in FcSortWalk unless we need to (#17361) 2009-02-13 16:54:00 -08:00
Behdad Esfahbod 799691c901 Don't leak FcValues string loaded through fcxml.c (#17661)
Patch from Caolan McNamara.
2009-02-13 16:54:00 -08:00
Chris Wilson 311da2316f Reduce number of allocations during FcSortWalk().
The current behaviour of FcSortWalk() is to create a new FcCharSet on
each iteration that is the union of the previous iteration with the next
FcCharSet in the font set. This causes the existing FcCharSet to be
reproduced in its entirety and then allocates fresh leaves for the new
FcCharSet. In essence the number of allocations is quadratic wrt the
number of fonts required.

By introducing a new method for merging a new FcCharSet with an existing
one we can change the behaviour to be effectively linear with the number
of fonts - allocating no more leaves than necessary to cover all the
fonts in the set.

For example, profiling 'gedit UTF-8-demo.txt'
    Allocator		    nAllocs	    nBytes
Before:
    FcCharSetFindLeafCreate 62886	    2012352
    FcCharSetPutLeaf        9361	    11441108
After:
    FcCharSetFindLeafCreate 1940	    62080
    FcCharSetPutLeaf        281		    190336

The savings are even more significant for applications like firefox-3.0b5
which need to switch between large number of fonts.
Before:
    FcCharSetFindLeafCreate 4461192	    142758144
    FcCharSetPutLeaf	    1124536	    451574172
After:
    FcCharSetFindLeafCreate 80359	    2571488
    FcCharSetPutLeaf	    18940	    9720522

Out of interest, the next most frequent allocations are
    FcPatternObjectAddWithBinding 526029    10520580
    tt_face_load_eblc	    42103	    2529892
2009-02-13 16:54:00 -08:00
Behdad Esfahbod 241fbde1ab Add FcConfigReference() (#17124) 2009-02-13 16:53:59 -08:00
Behdad Esfahbod 03dcaaa08f Document when config can be NULL (#17105)
Note that this also fixes a bug with FcFontList() where previously
it was NOT checking whether the config is up-to-date.  May want to
keep the old behavior and document that ScanInterval is essentially
unused internally (FcFontSetList uses it, but we can remove that
too).
2009-02-13 16:53:59 -08:00
Behdad Esfahbod 74e16ceeea Fix docs re 'orig' argument of FcPatternBuild and family
Now call it 'p' or 'pattern', since it's modified in place.
There is no copying.
2009-02-13 16:53:57 -08:00
Behdad Esfahbod e690fbb20e Get rid of $Id$ tags 2009-02-13 16:53:57 -08:00
Behdad Esfahbod 41fc0fe68d Add FcPatternFilter() (#13016) 2009-02-13 16:53:56 -08:00
Behdad Esfahbod 2987409853 Implement fc-list --verbose (#13015)
A private FcObjectGetSet() is implemented that provides an
FcObjectSet of all registered elements.  FcFontSetList() is
then modified to use the object set from FcObjectGetSet() if
provided object-set is NULL.

Alternatively FcObjectGetSet() can be made public.  In that
case fc-list can use that as a base if --verbose is included,
and also add any elements provided by the user (though that has
no effect, as all elements from the cache are already registered).
Currently fc-list ignores user-provided elements if --verbose
is specified.
2009-02-13 16:53:56 -08:00
Behdad Esfahbod 317b849215 Replace RCS Id tags with the file name 2009-02-13 16:53:55 -08:00
Behdad Esfahbod 1bcf4ae5f2 When canonizing filenames, squash // and remove final / (#bug 16286)
The fact that we now drop final slashes from all filenames without
checking that the file name represents a directory may surprise some,
but it doesn't bother me really.
2009-02-13 16:53:54 -08:00
Behdad Esfahbod e04afe83de Avoid C99ism in Win32 code (#16651) 2009-02-13 16:53:54 -08:00
Keith Packard 8ade236923 Ignore empty <dir></dir> elements
An empty element would cause every file starting with the current
directory to be scanned, probably not what the user wanted.
2008-05-24 17:14:24 -07:00
Sayamindu Dasgupta ad3fc66791 FcConfigUptoDate breaks if directory mtime is in the future. Bug 14424.
At OLPC, we came across a bug where the Browse activity (based on xulrunner)
took 100% CPU after an upgrade/. It turns out the Mozilla uses
FcConfigUptoDate() to check if new fonts have been added to the system, and
this function was always returning FcFalse since we have the mtimes of some
font directories set in the future. The attached patch makes
FcConfigUptoDate() print a warning and return FcTrue if mtime of directories
are in the future.
2008-05-24 16:15:27 -07:00
Evgeniy Stepanov b808204023 Fix index/offset for 'decorative' matcher. Bug 15890.
It seems indices in _FcMatchers array are slightly mixed up, MATCH_DECORATIVE
should be 10, not 11.

And MATCH_RASTERIZER_INDEX should be 13, not 12, right?
2008-05-24 16:09:17 -07:00
Keith Packard 3a3f687b75 Add extended, caps, dunhill style mappings.
extended -> expanded.
caps, dunhill -> decorative
2008-05-04 01:27:42 -07:00
Keith Packard 13a14cbf56 Fix a few memory tracking mistakes.
The built-in memory tracking code in fontconfig relies on a lot of manual
function call tracking. A pain, but it helps debug leaks.
2008-05-04 01:26:40 -07:00
Keith Packard 19d124dc4f Deal with libtool 2.2 which doesn't let us use LT_ variables. (bug 15692)
Libtool-2.2 introduces new restrictions. So now it does not allow LT_*
variables as it includes marcros:

m4_pattern_forbid([^_?LT_[A-Z_]+$])

Rename the LT_ variables to LIBT_ to work around this restriction.
2008-05-03 20:23:37 -07:00
Carlo Bramini 0028f72bc8 Add FreeType-dependent functions to fontconfig.def file. (bug 15415)
With PUBLIC_FILES no longer containing the freetype-dependent symbols, those
must be added to the fontconfig.def file build process.
2008-05-03 20:18:01 -07:00
Keith Packard 3322ca8553 Use of ":=" in src/Makefile.am is unportable (bug 14420)
Building 2.5.91 on Solaris with the native make(1) yields

...
Making all in src
make: Fatal error in reader: Makefile, line 313: Unexpected end of line seen
Current working directory /tmp/fontconfig-2.5.91/src
*** Error code 1

This is due to the following line (src/Makefile.am:143):

    CLEANFILES := $(ALIAS_FILES)

Changing that to a standard assignment ("=") fixes the problem.

I believe the ":=" is a typo. ALIAS_FILES is just a statically assigned
variable; it's not like evaluating it more than once would be a problem.
2008-05-03 20:07:35 -07:00
Ryan Schmidt 9ffa2fa7ef fontconfig build fails if "head" is missing or unusable (bug 14304)
If the /usr/bin/head program is missing or unusable, or if an unusable head
program is listed first in the PATH, fontconfig fails to build

using "sed -n 1p" instead of "head -1" would be a suitable workaround.
2008-05-03 19:49:07 -07:00
Dennis Schridde 6d65081e35 Proper config path for static libraries in win32
Since fontconfig didn't have special handling for paths in static Windows
libraries, I've created a patch which should fix this.

Basically it does this:
fccfg.c:
If fontconfig_path was uninitialised it tries to get the directory the exe is
in and uses a fonts/ dir inside that.
fcxml.c:
In case the fonts.conf lists a <dir>CUSTOMFONTDIR</dir>, it searches for a
fonts/ directory where the exe is located.
2008-05-03 19:45:31 -07:00
Sylvain Pasche 53aec11107 Fontconfig options for freetype sub-pixel filter configuration
David Turner has modified FreeType to be able to render sub-pixel decimated
glyphs using different methods of filtering. Fontconfig needs new
configurables to support selecting these new filtering options. A patch
follows that would correspond to one available for Cairo in bug 10301.
2008-05-03 19:33:45 -07:00
Keith Packard 73e8ae3ac8 Remove size and dpi values from bitmap fonts. Bug 8765.
The only relevant information is the pixel size; don't report anything else.
2008-05-03 17:43:39 -07:00
Keith Packard 60421f5d68 Work around for bitmap-only TrueType fonts that are missing the glyf table.
Bitmap-only TrueType fonts without a glyf table will not load a glyph when
FT_LOAD_NO_SCALE is set. Work around this by identifying TrueType fonts that have no
glyphs and select a single strike to measure the glyph map with.
2008-05-03 17:20:34 -07:00
Keith Packard ad43ccaafa Distribute new fcftint.h file 2008-01-10 08:58:57 -08:00
Keith Packard a0a1da22a4 Include fcftaliastail.h so that the freetype funcs are exported.
This header file needs to be included at the end of every file that
exports any freetype symbols.
2008-01-07 16:31:06 -08:00
Keith Packard dbd065ad31 Remove freetype requirement for build-time applications.
This avoids requiring the freetype development files when cross compiling
2008-01-02 08:47:14 -08:00
Keith Packard 0aa5fbaa0d Fix OOM failure case in FcPStackPush.
When allocation for the node attributes fail, clean up the node allocation
and report failure.
2007-12-23 14:06:41 -08:00
Hongbo Zhao 0f7870887a Not_contain should use strstr, not strcmp on strings. (bug 13632)
For Version 2.5.0, (same for previous version 2.4.2), in source file fccfg.c,
on line 700,

Original:
      ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;

Should change to:
      ret = FcStrStrIgnoreCase (left.u.s, right.u.s) == 0;

I think this is just a mistake when copy-n-paste similar codes in the same
function. Apparently, return for "Not_contain" should be just the inverse of
"Contain", not the same as "Equal".
2007-12-12 21:48:10 -08:00
Tor Lillqvist 8a3dc4880c Workaround for stat() brokenness in Microsoft's C library (bug 8526)
Fix a couple of longstanding problems with fontconfig on Windows that
manifest themselves especially in GIMP. The root cause to the problems is in
Microsoft's incredibly stupid stat() implementation. Basically, stat()
returns wrong timestamp fields for files on NTFS filesystems on machines
that use automatic DST switching.

See for instance http://bugzilla.gnome.org/show_bug.cgi?id=154968 and
http://www.codeproject.com/datetime/dstbugs.asp

As fccache.c now looks at more fields in the stat struct I fill in them all.
I noticed that fstat() is used only on a fd just after opening it, so on
Win32 I just call my stat() replacement before opening instead...
Implementing a good replacement for fstat() would be harder because the code
in fccache.c wants to compare inode numbers. There are no (readily
accessible) inode numbers on Win32, so I fake it with the hash of the full
file name, in the case as it is on disk. And fstat() doesn't know the full
file name, so it would be rather hard to come up with a inode number to
identify the file.

The patch also adds similar handling for the cache directory as for the fonts
directory: If a cachedir element in fonts.conf contains the magic string
"WINDOWSTEMPDIR_FONTCONFIG_CACHE" it is replaced at runtime with a path under
the machine's (or user's) temp folder as returned by GetTempPath(). I don't
want to hardcode any pathnames in a fonts.conf intended to be distributed to
end-users, most of which who wouldn't know how to edit it anyway. And
requiring an installer to edit it gets complicated.
2007-11-13 16:41:55 -08:00
Keith Packard 1315db01b6 Revert "Remove fcprivate.h, move the remaining macros to fcint.h."
This reverts commit b607922909.

Conflicts:

	src/Makefile.am

Xft still uses the macros that are in fcprivate.h. Document those macros and
include fcprivate.h in the published header files.
2007-11-13 15:48:30 -08:00
Behdad Esfahbod cf223cc7bc Add FcGetLangs() and FcLangGetCharSet(). 2007-11-05 15:29:44 -05:00
Keith Packard de1faa42d1 Export FcConfig{G,S}etRescanInverval from .so, mark as deprecated.
These two names are typos of the correct names. Instead of simply changing
them, the correct thing to do is leave them in the library, add the correct
functions and mark them as deprecated so any source packages will be updated.

This requires bumping the minor version of the library (for adding APIs)
instead of bumping the major version of the library (for removing APIs).
2007-11-04 12:20:45 -08:00
Keith Packard fc141b492b Have FcConfigSetCurrent accept the current configuration and simply return
without updating anything.
2007-11-03 22:45:31 -07:00
Keith Packard c833409f6b Use FcLangDifferentTerritory instead of FcLangDifferentCountry. 2007-11-03 21:58:34 -07:00
Keith Packard 1d93c1752f Typo error in function name: Inverval -> interval 2007-11-03 21:56:36 -07:00
Keith Packard e37d10fa74 Make file_stat argument to FcDirCacheLoadFile optional.
Allow file_stat to be NULL by using a local stat structure in that case.
2007-11-03 14:16:29 -07:00
Keith Packard b607922909 Remove fcprivate.h, move the remaining macros to fcint.h.
fcprivate.h was supposed to extend the fontconfig API for the various
fontconfig utilities. Instead, just have those utilities use the internal
fcint.h header file (which they already do), removing fcprivate.h from the
installation and hence from the defacto public API.
2007-11-03 13:09:01 -07:00
Keith Packard 681bb379de Respect "binding" attribute in <alias> entries.
This makes creating "same" aliases for renamed font families far easier.
2007-10-25 22:30:49 -07:00
Keith Packard ad27687f72 Also check configDirs mtimes in FcConfigUptoDate
Checking only config files and font directories can miss changes which
affect only a configuration directory. Check those to catch any changes.
2007-10-25 21:23:36 -07:00
Keith Packard 7a1a7c0c15 Build fix for Solaris 10 with GCC.
Solaris 10 with GCC doesn't appear capable of supporting the symbol
visibility stuff, so disable it.
2007-10-25 14:36:24 -07:00
Behdad Esfahbod fc990b2e86 Update CaseFolding.txt to Unicode 5.1.0 2007-10-25 14:20:06 -07:00
Keith Packard 4ee9ca6786 Match 'ultra' on word boundaries to detect ultra bold fonts. (bug 2511)
Added FcStrContainsWord to detect strings on word boundaries.
2007-10-25 14:00:15 -07:00
Keith Packard 7f46cdbb87 Ensure weight/slant values present even when style is supplied (bug 9313).
If the provided style value doesn't match any available font, fall back to
using the weight and slant values by ensuring that those are in the pattern.
2007-10-25 01:35:32 -07:00
Keith Packard 79641a3b0c Handle UltraBlack weight.
UltraBlack is weight 950 on the CSS scale; handle this by name and value
encoding it as fontconfig weight 215.
2007-10-25 01:03:40 -07:00
Keith Packard d02f6a70f1 Oops. Left debugging printf in previous commit. 2007-10-25 01:02:58 -07:00
Keith Packard 4657944d0c FcInit should return FcFalse when FcInitLoadConfigAndFonts fails. (bug 10976)
Thanks to David <ssdk@ispras.ru> for spotting this error.
2007-10-25 00:41:28 -07:00
Tilman Sauerbeck 28baf72736 Store FcVendorFoundries in read-only memory.
Create fixed size strings for vendor and foundry.
2007-10-25 00:38:44 -07:00
Tilman Sauerbeck 481f6c2307 Store FcNoticeFoundries in read-only memory.
Use a single character array and a separate table of integer indices.
2007-10-25 00:36:37 -07:00
Keith Packard a72ef35ce6 Replace makealias pattern with something supported by POSIX grep (bug 11083)
The suggested replacement in the bug was not supported by GNU grep, so I
created something that should be supported everywhere (famous last words).
2007-10-25 00:22:04 -07:00
Keith Packard 1bd0b5ba73 Eliminate relocations from FcCodePageRange structure (bug 10982).
FcCodePageRange was using char pointers; replace them with char arrays.
2007-10-18 09:48:31 -07:00
Keith Packard 96925b99c0 Eliminate relocations for glyph name table.
Glyph names (now used only for dingbats) were using many relocations,
causing startup latency plus per-process memory usage. Replace pointers with
table indices, shrinking table size and elimninating relocations.
2007-10-18 09:43:22 -07:00
Keith Packard bc5e8adb4d Must not insert cache into hash table before completely validating.
The cache was inserted into the hash table before the timestamps in the
cache were verified; if that verification failed, an extra pointer to the
now freed cache would be left in the hash table. FcFini would fail an
assertion as a result.
2007-10-18 09:41:00 -07:00
Keith Packard e85789a997 Place language name in constant array instead of pointer.
Constant char array of 8 bytes is the same size as a pointer plus a short
string, so this actually saves memory and eliminates a pile of relocations.
2007-10-18 08:58:14 -07:00
Mike FABIAN 07e646cc84 Avoid crashes if config files contain junk.
If ~/.fonts.conf contains:

  <edit mode="assign_replace" name="spacing">
     <int>mono</int>
       </edit>

fontconfig crashes:

    mfabian@magellan:~$ fc-match sans
        Fontconfig error: "~/.fonts.conf", line 46: "mono": not a valid
	integer
	    セグメンテーション違反です (core dumped)
	        mfabian@magellan:~$

Of course the above is nonsense, “mono” is no valid integer indeed.

But I think nevertheless fontconfig should not crash in that case.

The problem was caused by partially truncated expression trees caused by
parse errors -- typechecking these walked the tree without verifying the
integrity of the structure. Of course, the whole tree will be discarded
shortly after being loaded as it contained an error.
2007-10-18 05:44:28 -07:00
Keith Packard 238489030a Don't use X_OK bit when checking for writable directories (bug 12438)
Some mingw versions have broken X_OK checking; instead of trying to work
around this in a system-depedent manner, simply don't bother checking for
X_OK along with W_OK as such cases are expected to be mistakes, and not
sensible access control.
2007-10-18 05:04:39 -07:00
Keith Packard f7da903d37 Make FC_FULLNAME include all fullname entries, elide nothing. [bug 12827]
The old policy of eliding fullname entries which matched FC_FAMILY or
FC_FAMILY + FC_STYLE meant that applications could not know what the
font foundry set as the fullname of the font. Hiding information is not
helpful.
2007-10-18 04:31:33 -07:00
Keith Packard 144ca87831 Comment about mmaping cache files was misleading. 2007-10-18 04:29:13 -07:00
Keith Packard db6f19f13b Store font directory mtime in cache file.
Instead of relying on mtime ordering between a directory and its associated
cache file, write the directory mtime into the cache file itself. This makes
cache file checks more reliable across file systems.

This change is made in a way that old programs can use new cache files, but
new programs will need new cache files.
2007-10-18 04:13:51 -07:00
Keith Packard 3ae9258f9e Free temporary string in FcDirCacheUnlink (Bug #11758)
In FcDirCacheUnlink(), the line

  cache_hashed = FcStrPlus (cache_dir, cache_base);

allocates memory in cache_hashed that is never free()'d before the function
exits.

Reported by Ben Combee.
2007-08-05 12:31:03 -07:00
Keith Packard c80a08d6bf Work around FreeType bug when glyph name buffer is too small.
Recent versions of FreeType do not correctly deal with glyph name buffers
that are too small; work around this by declaring a buffer that can hold any
PS name (127 bytes).
2007-03-12 10:32:23 -07:00
Stephan Kulow 9b74b78fe8 Make FcPatternDuplicate copy the binding instead of always using Strong.
I noticed that Qt always uses a different font than fc-match advertises.
Debugging the issue, I found that a call that looks pretty innocent is
changing all weak bindings to strong bindings and as such changes the
semantic of the match: FcPatternDuplicate.
2007-03-12 10:21:35 -07:00
Keith Packard 0f963b0d3e Segfault scanning non-font files. Disallow scan edit of user vars. (#8767)
Missing NULL font check before attempting to edit scanned pattern.
Also, <match target="scan"> rules are now checked to ensure all
edited variables are in the predefined set; otherwise, the resulting
cache files will not be stable.
2006-12-02 13:57:45 -08:00
Kean Johnston c9c6875014 Don't use varargs CPP macros in fccache.c. (bug 8733)
src/fccache.c uses a trick to try and use a function name that is also a
macro name. It does this using the varargs args() macro. Replace that
with separate macros for each number of formals.
2006-12-02 13:36:56 -08:00
Keith Packard 72ffe6536a Add FcFreeTypeQueryFace external API. Bug #7311.
Expose ability to build an FcPattern directly from an FT_Face
object.
2006-12-02 13:22:27 -08:00
Keith Packard 5e234d9e76 Fix grep pattern in makealias to work on non-Gnu grep (bug 8368).
grep -l -w '^foo' doesn't work on Solaris. Replace with
grep -l '^foo\>' instead which does. Also, grep -l will
report the filename more than once (!), so add | head -1
to pick just the first one.
2006-12-02 13:14:23 -08:00
Keith Packard 2b77216ee2 Avoid writing uninitialized structure pad bytes to cache files.
The union inside the FcValue structure contains pad bytes. Instead of
copying the whole structure to the cache block, copy only the initialized
fields to avoid writing whichever bytes serve as padding within the
structure.
2006-12-02 13:04:05 -08:00
Keith Packard 64d7e303df Warn (and recover) from config file without <cachedir> elements.
When updating from older fontconfig versions, if the config file
is not replaced, it will not contain <cachedir> elements. Lacking these,
fontconfig has no place to store cached font information and cannot operate
reasonably.

Add code to check and see if the loaded configuration has no cache
directories, and if so, warn the user and add both the default system cache
directory and the normal per-user cache directory.
2006-12-02 12:14:49 -08:00
Keith Packard 253ec7609c Use explicit platform/nameid order when scanning ttf files.
Instead of accepting whatever order names appear in the font file,
use an explicit ordering for both platform and nameid.

Platforms are high precedence than nameids.

The platform order is:

	microsoft, apple unicode, macintosh, (other)

The family nameid order is:

	preferred family, font family

The fullname nameid order is:

	mac full name, full name

The style nameid order is

	preferred subfamily, font subfamily

This will change the names visible to users in various application UIs, but
should not change how existing font names are matched as all names remain
present in the resulting database. The hope is that family names will, in
general, be less ambiguous. Testing here shows that commercial fonts
have longer names now while DejaVu has a shorter family name, and moves more
of the font description to the style name.
2006-12-02 11:47:07 -08:00
Keith Packard b5803016d7 FcStrCanonAbsoluteFilename should be static. 2006-11-12 17:15:55 -08:00
Han-Wen Nienhuys 0596d7296c More fixes for Win32 building (bug 8311)
Our build system barfs on autogen.sh, which ignores --noconfigure. Configure
needs a host of options to make the cross compile work in our case.

Fix typo in fccache.c
2006-09-17 17:03:33 -07:00
Han-Wen Nienhuys 1de7a4cc09 FcStrCanonFileName buggy for mingw. (bug 8311)
FcStrCanonFileName checks whether s[0] == '/', and recurses if not.

This only works on POSIX. On dos, this crashes with a stack overflow.

The patch attached splits this functionality in two functions
(FcStrCanonAbsoluteFilename) and uses GetFullPathName on windows to get an
absolute path.  It also fixes a number of other issues. With this patch,
LilyPond actually produces output on Windows.
2006-09-17 14:34:46 -07:00
Keith Packard cc104e6a91 Detect and use available random number generator (bug 8308)
Prefer random over lrand48 over rand
2006-09-17 14:20:18 -07:00
Keith Packard 706a1b367a Build fontconfig.def from header files when needed.
Instead of attempting to track exported symbols manually in
fontconfig.def.in, build it directly from the public fontconfig header files
to ensure it exports the public API.
2006-09-17 14:09:12 -07:00
Keith Packard 97c3d5b692 Reimplement FcConfigAppFontAddDir; function was lost in 2.4.0.
With the cache restructuring of 2.4.0, the ability to add
application-specific font files and directories was accidentally lost.
Reimplement this using by sharing the logic used to load configured font
directories.
2006-09-15 00:23:40 -07:00
Keith Packard 9419bb34f6 Fix conf.d directory sorting.
Sort was using broken comparison function.
2006-09-09 21:21:01 -07:00
Keith Packard 49b44b277f Insert newly created caches into reference data structure.
All caches used in the application must be in the cache reference list so
internal references can be tracked correctly. Failing to have newly created
caches in the list would cause the cache to be deallocated while references
were still present.
2006-09-09 16:41:58 -07:00
Keith Packard 5d2f7a9d92 Accept locale environment variables that do not contain territory.
Locale environment variables (LC_ALL, LC_CTYPE, LANG) must contain language,
and may contain territory and encoding. Don't accidentally require territory
as that will cause fontconfig to fall back to 'en'.
2006-09-09 10:04:42 -07:00
Keith Packard f6cfbe16bf Attempt to fix makealias usage for build on Mac OS X.
Avoid using fcalias.h or fcaliastail.h on systems which don't support it.
Provided solution still generates these files, but does not use them.
2006-09-07 15:17:10 -07:00
Keith Packard 6cff1dca81 Replace gnu-specific sed command with simple grep.
makealias was using a gnu-extension to sed addressing, replace that with a
simple (and more robuse) grep command. Also, found a bug in the public
header file that was leaving one symbol out of the process.
2006-09-07 14:37:52 -07:00
David Turner 31e0f03210 Replace character discovery loop with simpler, faster version.
The existing loop for discovering which characters map to glyphs is ugly and
inefficient. The replacement is functionally identical, but far cleaner and
faster.
2006-09-07 14:29:35 -07:00
Keith Packard 8d779ce4b3 Reference patterns in FcCacheCopySet.
As patterns are put into the font set copy, mark them as referenced so the
cache stays around while the font set is in use.
2006-09-07 14:22:16 -07:00
Keith Packard c3796ac606 Charset hashing depended on uniqueness of leaves.
Charset hashing actually use the value of the leaf pointers, which is
clearly wrong, especially now that charsets are not shared across multiple
font directories.
2006-09-06 17:45:40 -07:00
Keith Packard 08bef68701 Parallel build fix for fcalias.h and fcaliastail.h
These are built from the same script, but creating a single dependency rule
caused parallel make to run the script twice.
2006-09-06 17:43:08 -07:00
Keith Packard 23816bf9ac Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven)
Using a simple shell script that processes the public headers, two header
files are constructed that map public symbols to hidden internal aliases
avoiding the assocated PLT entry for referring to a public symbol.

A few mistakes in the FcPrivate/FcPublic annotations were also discovered
through this process
2006-09-05 02:24:01 -07:00
Keith Packard 323ecd0cd3 Correct reference count when sharing cache file objects.
Multiple maps of the same cache file share the same mapped object; bump the
cache object reference count in this case
2006-09-04 23:19:59 -07:00
Keith Packard 17389539a0 Make cache reference counting more efficient.
Eliminate need to reference cache object once per cached font, instead
just count the number of fonts used from the cache and bump the reference
count once by that amount. I think this makes this refernece technique
efficient enough for use.
2006-09-04 22:26:24 -07:00
Keith Packard 9e612141df Reference count cache objects.
Caches contain patterns and character sets which are reference counted and
visible to applications. Reference count the underlying cache object so that
it stays around until all reference objects are no longer in use.

This is less efficient than just leaving all caches around forever, but does
avoid eternal size increases in case applications ever bother to actually
look for changes in the font configuration.
2006-09-04 22:20:25 -07:00
Keith Packard 8fe2104a1e Leave cache files mapped permanently.
Without reference counting on cache objects, there's no way to know when
an application is finished using objects pulled from the cache. Until some
kinf of cache reference counting can be done, leave all cache objects mapped
for the life of the library (until FcFini is called). To mitigate the cost
of this, ensure that each instance of a cache file is mapped only once.
2006-09-04 13:59:58 -07:00
Keith Packard 9a9fd975a1 Can't typecheck values for objects with no known type.
Objects that aren't part of the built-in object list don't have predefined
types, so we can't typecheck them.
2006-09-04 12:46:01 -07:00
Keith Packard a04ac99f0f Hide FreeType glue code from library ABI.
FreeType glue code was escaping the shared library.
2006-09-04 02:13:13 -07:00
Keith Packard 4984242e36 Hide private functions in shared library. Export functionality for utilities.
Borrowing header stuff written for cairo, fontconfig now exposes in the
shared library only the symbols which are included in the public header
files. All private symbols are hidden using suitable compiler directives.

A few new public functions were required for the fontconfig utility programs
(fc-cat and fc-cache) so those were added, bumping the .so minor version number
in the process.
2006-09-04 00:47:07 -07:00
Keith Packard 34227592c2 Remove all .cvsignore files 2006-09-03 16:27:09 -07:00
Keith Packard e3b771a63e Using uninitialized (and wrong) variable in FcStrCopyFilename.
A typo from the change in where filename canonicalization occurs.
2006-09-02 23:09:44 -07:00
Keith Packard 04cedae0d5 Don't segfault when string values can't be parsed as charsets or langsets.
If parsing charsets or langsets fails, return a FcTypeVoid value instead of
a charset/langset value with a NULL pointer in it (which is invalid).
2006-09-02 20:23:31 -07:00
Keith Packard fb6e30ab3e Fix missing initialization/destruction of new 'scan' target subst list.
Forgot to initialize and destroy the new substitution list for the 'scan'
match target.
2006-09-02 20:07:29 -07:00
Keith Packard c2c6976d1a 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.
2006-09-02 17:52:12 -07:00
Keith Packard 3b8a03c09d 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.
2006-09-02 14:54:14 -07:00
Keith Packard 9b511b2905 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.
2006-09-02 14:52:37 -07:00
Keith Packard 7295c6f5fa 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.
2006-09-01 21:30:54 -07:00
Keith Packard 3bb1812f0d 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.
2006-09-01 15:33:27 -07:00
Keith Packard 5b8e43a48e Avoid #warning directives on non-GCC compilers. (bug 7683)
Detect GCC and use #warning only on GCC systems.
2006-09-01 12:36:31 -07:00
Keith Packard 09bd9ae2be 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.
2006-09-01 02:22:59 -07:00
Keith Packard 18b6857c64 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.
2006-09-01 01:49:47 -07:00
Keith Packard bc5e487f2a 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.
2006-09-01 01:15:14 -07:00
Keith Packard 551b6b2cd7 Allow FcTypeLangSet to match either FcTypeLangSet or FcTypeString.
Applications explicitly setting FC_LANG with string would fail due
to typechecking disallowing this case.
2006-08-31 18:16:00 -07:00
Keith Packard f57783d2e9 Revert ABI changes from version 2.3
Accidental ABI changes and additions were discovered by looking at the
differences in fontconfig.h. All of those have been reverted.
2006-08-31 14:38:18 -07:00
Keith Packard 0a87ce715e 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.
2006-08-31 11:56:43 -07:00
Keith Packard d8ab9e6c42 Automatically remove invalid cache files.
Cache files for missing or more recently modified directories are
automatically removed at the end of every fc-cache run.
2006-08-31 09:42:49 -07:00
Keith Packard e9a564e2cd Serialized value lists were only including one value.
The next pointer in the serialized value list wasn't getting set, so they
were truncated at a single value.
2006-08-31 09:07:32 -07:00
Keith Packard c50ea916b0 Use intptr_t instead of off_t inside FcCache structure.
This avoids OS-dependencies in the cache file structure.
2006-08-30 23:09:39 -07:00
Keith Packard 76abb77f26 Fix fc-cat again. Sigh.
Internal interfaces in cache management changed again...
2006-08-30 22:23:25 -07:00
Keith Packard 2d3387fd72 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.

Call FcFini from fc-match to make valgrind happy.
2006-08-30 21:59:53 -07:00
Keith Packard 09f9f6f62a 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.
2006-08-30 18:50:58 -07:00
Keith Packard c02886485b FcCharSetSerialize was using wrong offset for leaves. Make fc-cat work.
FcCharSetSerialize was computing the offset to the unserialized leaf,
which left it pointing at random data when the cache was reloaded.

fc-cat has been updated to work with the new cache structure.

Various debug messages extended to help diagnose serialization errors.
2006-08-30 13:51:03 -07:00
Keith Packard e3096d90fd 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.
2006-08-30 04:24:03 -07:00
Keith Packard 7ce1967331 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.
2006-08-30 04:16:22 -07:00
Keith Packard 2a9179d889 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.
2006-08-28 11:51:12 -07:00
Keith Packard 7db39f7298 Regenerate x86 line in fcarch.tmpl.h to match change in cache data.
Also remove spurious printf of directory names.
2006-08-28 09:43:12 -07:00
Keith Packard 0d9e31c810 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.
2006-08-27 23:40:51 -07:00
Keith Packard af180c4037 Fix up fc-cache and fc-cat for no global cache changes.
fc-cache and fc-cat use internal (fcint.h) APIs that have
changed with the elimination of the global cache.
2006-08-27 22:24:39 -07:00
Keith Packard 00f059e930 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.
2006-08-27 21:53:48 -07:00
Keith Packard cf65c0557e Add architecture to cache filename.
Make cache filenames unique by inserting the architecture name into the
filename.
2006-08-27 18:29:51 -07:00
Keith Packard db50cbdaf5 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.
2006-08-27 18:19:39 -07:00
Keith Packard d2f786849c 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.
2006-08-27 17:04:01 -07:00
Patrick Lam 7410e40bd9 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.
2006-08-04 16:13:00 +00:00
Patrick Lam 62a4a8459a 2006-07-19 Jon Burgess (jburgess@uklinux.net) reviewed by: plam
Fix file-descriptor leak in FcGlobalCacheDestroy.
2006-07-19 02:14:28 +00:00
Patrick Lam 1c14f2d963 2006-05-31 Yong Li (rigel863@gmail.com) reviewed by: plam, Bedhad Esfahbod
TrueType Collection table offsets are absolute, not relative.
2006-06-02 18:48:30 +00:00
Patrick Lam 31b7e6d7f5 2006-04-27 Paolo Borelli (pborelli@katamail.com) reviewed by: plam
Make FcStrCopy slightly more efficient.
2006-04-28 07:00:25 +00:00
Patrick Lam 0037aad501 Keith Packard <keithp@keithp.com>
Reduce transient memory usage during config file parsing by allocating
    smaller buffers (64 seems to be a magic number).
2006-04-27 08:13:45 +00:00
Keith Packard 529291bef4 Eliminate pattern freezing 2006-04-27 07:54:07 +00:00
Keith Packard c1c3ba06d5 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>
2006-04-27 07:11:44 +00:00
Patrick Lam 73775d8f28 Fix the issues with GNU libiconv vs. libc iconv (which especially appear on
Solarii). Approach suggested by Tim Mooney.
reviewed by: plam
2006-04-25 15:33:07 +00:00
Patrick Lam f045376c08 Include $(top_srcdir), $(top_srcdir)/src before anything else.
Shuffle order of includes for building out of srcdir on win32.
reviewed by: plam
2006-04-25 05:57:41 +00:00
Patrick Lam 55e145b025 Prevent terrible perf regression by getting the if-condition right
(reported by Wouter Bolsterlee).
2006-04-20 16:57:50 +00:00
Patrick Lam 93f67dfc73 Dominic Lachowicz <cinamod@hotmail.com>
Implement mmap-like code for Windows using MapViewOfFile.
2006-04-19 16:53:50 +00:00
Patrick Lam c001a192af Bail gracefully if the cache file does not contain enough data. 2006-04-19 16:17:19 +00:00
Patrick Lam 8cfa0bbc82 Fix Gecko-exposed segfault from my last hack to FcObjectToPtrLookup.
Simplify code and get things straight.
2006-04-14 18:35:16 +00:00
Patrick Lam 2f02e38361 Fix memory leak (Coverity defect #2089).
Ignore script if subtable is missing (Coverity defect #2088).
Fix possible null pointer dereference (Coverity defect #784) and memory
    leak (Coverity defects #785, #786).
Don't copy FcCharSet if we're going to throw it away anyway. (Reported by
    Kenichi Handa).
reviewed by: plam
2006-04-12 14:36:36 +00:00
Patrick Lam a56e89ab4f Fix bad behaviour on realloc resulting in crash.
reviewed by: plam
2006-04-12 03:02:57 +00:00
Patrick Lam 5c90509c07 Don't crash if config is null (Coverity defect #984). 2006-04-12 02:38:28 +00:00
Patrick Lam 2de24638b2 Missing bits from previous patches.
Remove extra semi-colon.
Fix memory leak in error case (Coverity defects #776, #985).
Fix memory leaks (Coverity defects #779, #781) and memory use after free
    (Coverity defect #780).
reviewed by: plam
2006-04-11 16:54:24 +00:00
Patrick Lam 04f7d3e7fd Properly convert static charsets to dynamic charsets.
Fix memory leak in error case (Coverity defects #1820, #1821, #1822).
Fix memory leak (Coverity defect #1819).
prevent crash when invalid include line is parsed (Coverity defect #763).
Fix potential null pointer access (Coverity defect #1804).
Remove dead code (Coverity defect #1194).
Prevent potential null pointer access (Coverity defect #767), ensure error
    value is read (Coverity defect #1195).
reviewed by: plam
2006-04-11 14:20:59 +00:00
Patrick Lam ac0010940e Swap typo in order of ALIGN and dereferencing, fixing bug 6529. 2006-04-10 21:04:54 +00:00
Patrick Lam 3ea92166a0 Fix string memory leak (Coverity defect #1823).
Fix memory leak with hash collision (Coverity defect #1824).
reviewed by: plam
2006-04-10 19:33:03 +00:00
Patrick Lam c814c301ee Don't leak header in non-error case (Coverity defect #1825).
reviewed by: plam
2006-04-10 16:12:55 +00:00
Patrick Lam 65448e8b2a src/fcdir.c (FcDirScanConfig) Don't leak in error cases (Coverity defects
#777, #1826)
reviewed by: plam
2006-04-10 16:06:42 +00:00
Patrick Lam ae2aafe602 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
2006-04-10 15:46:34 +00:00
Patrick Lam f23f5f388d SGI compilation fixes (reported by Christoph Bauer):
1) reorder union definition of _FcChar;
2) omit .stats =.
2006-04-07 17:37:09 +00:00
Patrick Lam 44415a079a Portability fixes for HP-UX (reported by Christoph Bauer). Replace
'__inline__' by AC_C_INLINE and 'inline'. Replace '__alignof__' by
    'fc_alignof'.
reviewed by: plam
2006-04-07 17:27:39 +00:00
Patrick Lam 91fe51b4f8 Move up #include of config.h. Fail if neither inttypes.h nor stdint.h is
available. Fixes bug 6171.
reviewed by: plam
2006-04-07 17:06:55 +00:00
Patrick Lam d6217cc6bc Patrick Lam <plam@mit.edu>
Make fontconfig compile under MinGW:
1) remove unneeded #includes;
2) make use of mmap and sysconf conditional;
3) replace rand_r by srand/rand if needed;
4) use chsize instead of ftruncate; and
5) update libtool exports file
2006-04-07 04:42:32 +00:00
Patrick Lam 3a342c5a6c Eliminate warning. 2006-04-07 04:19:49 +00:00
Patrick Lam 392fa276dc Reduce amount of dirty rss by const'ing some data structures.
Don't fail if we can't create or remove $(pkgcachedir) i.e.
    /var/cache/fontconfig. (reported by Quanah Gibson-Mount).
reviewed by: plam
2006-04-06 04:52:21 +00:00
Patrick Lam 0d745819a9 Fix intel compiler warnings: make many variables static, eliminate
duplicate names, reduce variable scopes, unsigned/signed printf
    formatting.
reviewed by: plam
2006-04-06 04:33:11 +00:00
Patrick Lam b17cf498be Fix multiarch support (don't destroy multiarch files!)
Require pkg-config. (Thanks Behdad; better solution wanted for libxml2
    detection!)
reviewed by: plam
2006-03-24 15:21:10 +00:00
Patrick Lam c022182231 On Windows, unlink before rename. Reported by Tim Evans. 2006-03-23 04:21:10 +00:00
Patrick Lam e3c6d3364c Sort directory entries while scanning them from disk; prevents Heisenbugs
due to file ordering in a directory.
reviewed by: plam
2006-03-08 19:10:57 +00:00
Patrick Lam d8951c0cc2 Remove stuff we don't use, make get_{char,short,long} functions of ftglue
macros to be inlined.
Code cleanups (excess prototype, old-style function definition).
reviewed by: plam
2006-03-08 02:30:43 +00:00
Patrick Lam 9226e04c69 Because we hacked FcPatternGet, we don't really need to expand the filename
again in FcPatternGetString.
2006-03-05 15:33:46 +00:00
Patrick Lam 618adbaf7b Ok, so some people (wine!) use FcPatternGet to fetch FC_FILE. Make that
work. Reported by Bernhard Rosenkraenzer.
2006-03-05 06:05:50 +00:00
Patrick Lam dc70c15aba Include inttypes.h instead of stdint.h if appropriate. 2006-03-03 18:35:42 +00:00
Patrick Lam bb6b19938e Get rid of C++-style comments. 2006-03-03 06:35:53 +00:00
Patrick Lam b36f2a39d0 Fix suspicious return expression which causes junk to be returned.
reviewed by: plam
2006-03-03 06:11:31 +00:00
Patrick Lam 0cfaf27e33 Takashi Iwai <tiwai@suse.de> reviewed by: plam
Fix double-free on error case.
2006-02-24 16:41:34 +00:00
Patrick Lam 656b47f698 Pass the buck; make fontconfig not crash on pango badness. 2006-02-21 15:56:41 +00:00
Patrick Lam f2fb985c7a Eliminate redundancies.
reviewed by: plam
2006-02-21 15:50:19 +00:00
Patrick Lam b023dbd384 Eliminate unused vars reported by Intel's compiler.
reviewed by: plam
2006-02-21 15:40:18 +00:00
Patrick Lam dacf81ed4c Freeze patterns created by configuration file for tiny memory savings
(every little bit helps).
reviewed by: plam, keithp
2006-02-21 15:24:28 +00:00
Patrick Lam 530e66b008 Fix the underlying cause of the below segfault (must usually call
FcDirCacheHasCurrentArch after FcDirCacheValid).
2006-02-18 18:18:07 +00:00
Patrick Lam a68ce9525d Fix segfault (reported by fcrozat) caused by incorrect input on cache
files.
2006-02-18 17:56:25 +00:00
Patrick Lam 310817371c Bump up magic version; we changed the binary format. 2006-02-17 14:44:42 +00:00
Patrick Lam 8c0d692125 Deal correctly with changing FC_CACHE_MAGIC. 2006-02-16 17:50:04 +00:00
Patrick Lam 719f4b841f Don't bail if fontconfig can't remove a dir cache file. Skip the ID of a
cache file when copying. Eliminate 'source file too small' bug in
    FcDirCacheWrite.
2006-02-16 07:12:04 +00:00
Patrick Lam f8a17f3298 Fix memory leak in error condition code. 2006-02-13 22:19:30 +00:00
Patrick Lam 5657098e29 Skip bitmap fonts which can't even get it together enough to declare a
family name; this appears to reproduce previous fontconfig behaviour.
reviewed by: plam
2006-02-13 21:51:11 +00:00
Patrick Lam d00c3cb5e0 Try to open /var/cache/fontconfig/[hashed name] before fonts.cache-2 in a
directory, because /var/cache/fontconfig failures ought to be fixable,
    unlike fonts.cache-2 failures, which may leave you screwed.
reviewed by: plam
2006-02-11 05:01:32 +00:00
Patrick Lam 9e07e0a77b Use a tri-state to mark the fonts which didn't get blocked but were just
missing an element, to distinguish them from the fonts that do match
    the element.
reviewed by: plam
2006-02-11 04:50:46 +00:00
Patrick Lam f11a184104 Don't kill fonts because they don't declare an element that's being matched
on.
reviewed by: plam
2006-02-10 19:40:11 +00:00
Patrick Lam 879af7060b Define and pass O_BINARY to open if appropriate, for those platforms that
need it. Reported by Doodle.
2006-02-09 18:44:14 +00:00
Patrick Lam c7490074c5 Fix attempt to close -1. Don't unboundedly grow bad caches (reported by
fcrozat).
2006-02-09 16:19:42 +00:00
Patrick Lam a8c425301a Fix problem with missing 'en' due to euro.patch: change cache file format
slightly to coincide with that generated by fc-lang.
2006-02-09 15:25:57 +00:00
Patrick Lam b10e77628c Fix warning. 2006-02-08 03:34:17 +00:00
Patrick Lam 5c3deb2985 Don't reject dirs that can't be normalized (fixes lilypond, and is correct
in the context of application font directories.)
Use normalized directory name exclusively in FcCacheReadDirs.
reviewed by: plam
2006-02-07 22:09:01 +00:00
Patrick Lam efb11b36c4 Perf optimizations. Inline FcValueCanonicalize, reduce FcValueListPtrU
usage, remove redundant cast.
reviewed by: plam
2006-02-07 21:15:33 +00:00
Patrick Lam 6cc02fe6b9 src/fccharset.c (FcLangCharSetPopulate, FcCharSetInsertLeaf)
Fix missing FcCacheBankToIndex in FcCharSetInsertLeaf. Declare extern for
    static arrays as arrays, not pointers. (Part of the fix for 'fonts
    don't have en' issue after Euro patch.)
(I forgot to commit the ChangeLog last time.)
reviewed by: plam
2006-02-07 20:56:48 +00:00
Patrick Lam a81f23c0ce Fix hidden variable warning. 2006-02-07 03:53:32 +00:00
Patrick Lam 799157dbbf Remove de-escaping logic because FcCacheWriteString doesn't escape anyway.
Do blockwise reading instead of byte-wise for performance.
2006-02-07 02:33:57 +00:00
Patrick Lam 8b413bb62c Takashi Iwai <tiwai@suse.de>
Don't loop infinitely on recursive symlinks (client-side).
2006-02-07 02:22:50 +00:00
Patrick Lam fff5a5af30 Skip subdirs when skipping over stale bits of global cache. Introduce state
machine into FcGlobalCacheDir to avoid doing inappropriate operations
    on global dir entries, e.g. writing out an out-of-date cache entry.
reviewed by: plam
2006-02-06 22:44:02 +00:00
Patrick Lam 98592bbb1d Hoist FcFileIsDir check out of FcFileScanConfig loop.
reviewed by: plam
2006-02-06 21:52:15 +00:00
Patrick Lam a0aa54f6ee Don't rescan when trying to normalize a non-declared font dir. Don't add
font dirs multiple times (even if they're aliased).
reviewed by: plam
2006-02-06 19:25:45 +00:00
Patrick Lam 86e75dfb5d Explain apples/oranges comparison and fix compilation error.
reviewed by: plam
2006-02-06 14:44:46 +00:00
Patrick Lam f076169d19 Insert check for integer overflow in # of fonts.
reviewed by: plam
2006-02-06 14:14:21 +00:00
Patrick Lam 68355f3877 src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheSave, FcDirCacheConsume,
FcDirCacheWrite)
Check I/O call return values and eliminate unused variable warnings.
reviewed by: plam
2006-02-05 02:57:21 +00:00
Patrick Lam c4c47a7654 src/fccfg.c (FcConfigAppFontAddFile, FcConfigAppFontAddDir)
Fix memory leak.
reviewed by: plam
2006-02-04 00:09:42 +00:00
Patrick Lam a8e4d9eb39 Gracefully handle the case where a cache asserts that it has a negative
number of fonts, causing overflow.
reviewed by: plam
2006-02-04 00:04:00 +00:00
Patrick Lam 1af0f5741a Fix double free in error case. 2006-02-03 23:47:37 +00:00
Patrick Lam 28aefd013d Toast broken global cache files.
reviewed by: plam
2006-01-31 07:16:22 +00:00
Patrick Lam 3616cbe251 Actually use the directories that I added to the global cache. Fixes 'make
check'.
2006-01-31 04:42:20 +00:00
Patrick Lam 81d97094cf Make global cache work again after putting dir names into global cache (I
misplaced the recording of a file offset).
2006-01-30 16:31:56 +00:00
Patrick Lam 2c4e012497 Update fc-cat to handle subdir lists in global cache file.
Another FcCacheReadString return value check.
2006-01-30 15:59:17 +00:00
Patrick Lam c5411c4cae Make fccache more resilient to broken cache files by checking return value
of FcCacheReadString all the time.
reviewed by: plam
2006-01-30 15:44:13 +00:00
Patrick Lam 30c4189deb Fix global cache reads of subdirectories.
reviewed by: plam
2006-01-30 04:47:17 +00:00
Patrick Lam 971cf18018 Add documentation for FcConfigNormalizeFontDir.
Write directory information to global caches to fix make check (reported by
    Ronny V. Vindenes). This changes the global cache format again.
2006-01-30 04:27:53 +00:00
Patrick Lam 97293e07dd Move FcConfigNormalizeFontDir call so that it doesn't result in infinite
recursion (reported by Ronny V. Vindenes).
2006-01-27 05:47:59 +00:00
Patrick Lam 3cf9f5cec3 Add a couple of missing normalizations to make fc-cache work right; only
scan subdirectories once.
2006-01-27 00:27:37 +00:00
Patrick Lam 4073203deb Don't crash on non-existant directories in global cache.
reviewed by: plam
2006-01-26 16:11:41 +00:00
Patrick Lam f468f568b4 Stop trampling the directory name when writing out caches. (with Mike
Fabian:) Beef up FcConfigNormalizeFontDir to scan subdirs when
    necessary. Don't scan directories that can't be normalized.
2006-01-26 16:09:12 +00:00
Patrick Lam 575a37b797 Fix additional memory leaks reported by Ronny V. Vindenes: don't invoke
FcValueSave on hashed static strings in FcPatternAddWithBinding.
Add another st_dev check in FcDirCacheOpen.
2006-01-25 14:52:49 +00:00
Patrick Lam 16a71eff3e Treat zh-hk fonts differently from zh-tw fonts. This patch may cause
fontconfig to treat A-X fonts differently from A-Y fonts; please mail
    the fontconfig list if this causes any problems.
reviewed by: plam
2006-01-25 02:54:37 +00:00
Patrick Lam 6f9fcb5186 Fix memory leaks reported by Ronny V. Vindenes. 2006-01-25 02:33:46 +00:00
Patrick Lam 986e35979e Fix for unaligned memory accesses.
reviewed by: plam
2006-01-19 19:20:30 +00:00
Patrick Lam 58bdd29619 Properly order the FcConfigAddFontDir and FcConfigNormalizeFontDir calls to
avoid crashes.
reviewed by: plam
2006-01-18 15:41:15 +00:00
Patrick Lam eadadf489a Fix segfault when consuming zero-length caches in fc-cat (which has no
config, so FcConfigAddFontDir shouldn't be called.)
2006-01-15 05:31:58 +00:00
Patrick Lam 8a0b0ed6d0 Compare device numbers as well as inodes. Always normalize directory names
before comparing them.
Allocate extra space for appended '/' in directory name.
reviewed by: plam
2006-01-14 21:23:03 +00:00
Patrick Lam df3efc11a9 Explicitly add font dirs to config.fontDirs even if they're empty. Set
current config in fc-cache.c. Fix treatment of cache directory as read
    from cache file; don't use string equality to determine if we have the
    right file, use inode equality.
2006-01-10 13:15:05 +00:00
Patrick Lam cd9bca6970 Normalize font dirs by using the form, as given in fonts.conf, and recorded
in FcConfig's fontDirs string set, as canonical.
Actually update config.fontDirs as font directories are scanned.
2006-01-09 13:58:04 +00:00
Patrick Lam 5576a5873d Fix matching bug when multiple elements match; don't use the sum of all
scores, but the best score.
Also more perf opts, e.g. evaluate best over all font sets rather than on a
    per-set basis (and other changes).
2006-01-08 10:58:30 +00:00
Patrick Lam 05a98eaf4b Properly skip past dir caches that contain zero fonts (as occurs in global
caches.) Reported by Mike Fabian.
2006-01-08 10:50:51 +00:00
Patrick Lam 5fe09702f4 Print out full pathname in fc-match -v as well. Reported by Frederic
Crozat.
Fix bug where fc-match crashes when given __DUMMY__ property to match on.
(I added the __DUMMY__ string to enable callers of FcObjectToPtrLookup to
    distinguish an error return from a successful return. -PL)
reviewed by: plam
2006-01-07 06:36:24 +00:00
Patrick Lam c60ec7cc6d Add self to AUTHORS list.
Minor change to global cache file format to fix fc-cat bug reported by
    Frederic Crozat, and buglet with not globally caching directories with
    zero fonts cached.
2006-01-05 15:12:22 +00:00
Patrick Lam 52ac91f7c1 Fix double-free which occurs because FcValueCanonicalize doesn't create an
extra copy of the returned value, it only canonicalizes it.
reviewed by: plam
2006-01-02 17:20:23 +00:00
Patrick Lam ebc157f9a1 Shut up GCC warnings on amd.
reviewed by: plam
2005-12-21 20:00:20 +00:00
Patrick Lam 19ea60bc7c Avoid check on _fcBankId nullness and fix case where it used to crash. 2005-12-21 05:37:10 +00:00