Commit Graph

1100 Commits

Author SHA1 Message Date
Behdad Esfahbod 6118781f7f Fix readlink failure
As reported by Raimund Steger.
2013-01-17 19:27:20 -06:00
Akira TAGOH 671bcb34e2 Better fix for 2fe5ddfd
Drop realpath() and fix breakage on Win32
2013-01-17 12:49:16 +09:00
Behdad Esfahbod 2fe5ddfdae Fix FC_PRGNAME default
As reported by Raimund Steger.
2013-01-16 21:01:28 -06:00
Behdad Esfahbod 55d39bcad0 Fix fc-cache crash caused by looking up NULL object incorrectly
We were returning a skiplist node when looking up NULL!
2013-01-16 07:31:15 -06:00
Behdad Esfahbod 106c4f7311 Minor 2013-01-16 07:05:07 -06:00
Akira TAGOH f9ac4c84c9 Improve FcGetPrgname() to work on BSD 2013-01-16 16:35:28 +09:00
Behdad Esfahbod ec5ca08c80 Bug 59379 - FC_PRGNAME
Can be used for per-application configuration.
2013-01-15 20:46:45 -06:00
Akira TAGOH 3f84695104 Bug 50497 - RFE: Add OpenType feature tags support
Add FC_FONT_FEATURES to store the feature tags to be enabled.
2013-01-15 19:40:26 -06:00
Akira TAGOH dffb69ed8c Fix the build fail on MinGW
Reported at http://lists.freedesktop.org/archives/fontconfig/2013-January/004601.html

just warn at the runtime instead of the compile time. it somewhat works
on even MinGW since FcMakeTempfile() isn't used on Win32 so far.
2013-01-15 17:27:12 +09:00
Behdad Esfahbod 8b8f0d2153 Minor 2013-01-14 14:39:12 -06:00
Behdad Esfahbod 8828fffd93 Copy all values from pattern to font if the font doesn't have the element
Bug 59376 - FcFontRenderPrepare enhancement
2013-01-14 14:36:38 -06:00
Behdad Esfahbod 98efed3bca Add atomic ops for Solaris
Patch from Raimund Steger.
2013-01-10 01:17:46 -06:00
Akira TAGOH 8e8a99ae8a Bug 29312 - RFE: feature to indicate which characters are missing to satisfy the language support
Add fc-validate to check the language coverage in a font.
2013-01-09 12:21:33 +09:00
Behdad Esfahbod dc21ed28d6 Fix memory corruption!
In FcStrListCreate() we were increasing reference count of set,
however, if set had a const reference (which is the case for list
of languages), and with multiple threads, the const ref (-1) was
getting up to 1 and then a decrease was destroying the set.  Ouch.

Here's the valgrind error, which took me quite a few hours of
running to catch:

==4464== Invalid read of size 4
==4464==    at 0x4E58FF3: FcStrListNext (fcstr.c:1256)
==4464==    by 0x4E3F11D: FcConfigSubstituteWithPat (fccfg.c:1508)
==4464==    by 0x4E3F8F4: FcConfigSubstitute (fccfg.c:1729)
==4464==    by 0x4009FA: test_match (simple-pthread-test.c:53)
==4464==    by 0x400A6E: run_test_in_thread (simple-pthread-test.c:68)
==4464==    by 0x507EE99: start_thread (pthread_create.c:308)
==4464==  Address 0x6bc0b44 is 4 bytes inside a block of size 24 free'd
==4464==    at 0x4C2A82E: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4464==    by 0x4E58F84: FcStrSetDestroy (fcstr.c:1236)
==4464==    by 0x4E3F0C6: FcConfigSubstituteWithPat (fccfg.c:1507)
==4464==    by 0x4E3F8F4: FcConfigSubstitute (fccfg.c:1729)
==4464==    by 0x4009FA: test_match (simple-pthread-test.c:53)
==4464==    by 0x400A6E: run_test_in_thread (simple-pthread-test.c:68)
==4464==    by 0x507EE99: start_thread (pthread_create.c:308)

Thread test is running happily now.  Will add the test in a moment.
2013-01-08 13:03:35 -06:00
Akira TAGOH 4e6c7d0827 Fix a build fail on mingw
Regarding the change of 596931c8b4
2013-01-08 16:20:40 +09:00
Akira TAGOH d837a7a584 missing header file to declare _mkdir 2013-01-08 16:18:32 +09:00
Akira TAGOH 596931c8b4 Bug 47705 - Using O_CLOEXEC 2013-01-08 15:34:09 +09:00
Akira TAGOH b6b678e71e Missing header file for _mkdir declaration 2013-01-04 11:29:50 +09:00
Behdad Esfahbod 8e143b4ec4 Minor 2013-01-03 04:19:12 -06:00
Behdad Esfahbod 86e3255118 Second try to make Sun CPP happy 2013-01-02 20:16:55 -06:00
Behdad Esfahbod 32c1d32cbd Work around Sun CPP
According to Raimund Steger:

> [...]
> diff --git a/src/Makefile.am b/src/Makefile.am
> index dc082b7..57c34a2 100644
> [...]
> +fcobjshash.gperf: fcobjshash.gperf.h fcobjs.h
> +    $(AM_V_GEN) $(CPP) -I$(top_srcdir) $< | $(GREP) '^[^#]' | awk ' \
> +    /CUT_OUT_BEGIN/ { no_write=1; next; }; \
> +    /CUT_OUT_END/ { no_write=0; next; }; \
> +    { if (!no_write) print; next; }; \
> +    ' - > $@.tmp && \
> +    mv -f $@.tmp $@

Sun Studio CPP seems to insert whitespace in a different way than GCC's CPP.

GCC generates in src/fcobjshash.gperf:

[...]
"family", FC_FAMILY_OBJECT
"familylang", FC_FAMILYLANG_OBJECT
[...]

Sun Studio generates:

[...]
 "family" , FC_FAMILY_OBJECT
 "familylang" , FC_FAMILYLANG_OBJECT
[...]

leading to:

[...]
Making all in src
gmake[2]: Entering directory `/home/rs/src/fontconfig-git/fontconfig/src'
  GEN    fcobjshash.gperf
  GEN    fcobjshash.h
Key link: " " = " ", with key set "".
1 input keys have identical hash values,
use option -D.
gmake[2]: *** [fcobjshash.h] Error 1
gmake[2]: Leaving directory `/home/rs/src/fontconfig-git/fontconfig/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/rs/src/fontconfig-git/fontconfig'
gmake: *** [all] Error 2

...maybe we could tuck in an additional sed to remove the whitespace, like:

[...]
fcobjshash.gperf: fcobjshash.gperf.h fcobjs.h
    $(AM_V_GEN) $(CPP) -I$(top_srcdir) $< | \
    $(SED) 's/^\s*//;s/\s*,\s*/,/;' | \
    $(GREP) '^[^#]' | \
    $(AWK) '/CUT_OUT_BEGIN/,/CUT_OUT_END/ { next; }; { print; };' \
    > $@.tmp && \
    mv -f $@.tmp $@
[...]

though I'm not sure what kind of guarantee CPP can give us/what easier option I might have missed...
2013-01-02 19:04:17 -06:00
Behdad Esfahbod b1510145e7 Fix build around true/false 2013-01-02 18:57:47 -06:00
Behdad Esfahbod 46ab96b8fa Fix more warnings.
Linux build and mingw32 cross build warning-free now.
2013-01-02 18:00:09 -06:00
Behdad Esfahbod ec8a40d238 Fix build and warnings on win32 2013-01-02 17:35:56 -06:00
Behdad Esfahbod 766bed901f Fix compiler warnings 2013-01-02 02:19:04 -06:00
Behdad Esfahbod 93fb1d4bab Remove FcSharedStr* 2013-01-02 02:18:02 -06:00
Behdad Esfahbod 6b14378107 Fixup fcobjs.c
Ouch!
2013-01-02 01:54:38 -06:00
Behdad Esfahbod 6047ce7b9f Warn about undefined/invalid attributes during config parsing 2013-01-02 01:31:34 -06:00
Behdad Esfahbod b604f10c0c Make fcobjs.c thread-safe
With this, the library should be threadsafe as far as my analysis goes!
2013-01-02 01:09:43 -06:00
Behdad Esfahbod 2ae07bbcd2 Make FcDirCacheDispose() threadsafe 2013-01-02 01:04:58 -06:00
Behdad Esfahbod 68b8ae9af8 Make cache hash threadsafe
This concludes my first pass at making fontconfig threadsafe.  Now to
testing and actually fixing it!
2013-01-02 01:04:47 -06:00
Behdad Esfahbod adb03b730d Make random-state initialization threadsafe 2013-01-02 01:04:03 -06:00
Behdad Esfahbod 91dd7d28ff Add a big cache lock
Not used yet.
2013-01-02 01:03:49 -06:00
Behdad Esfahbod 8d2bbb193a Make cache refcounting threadsafe 2013-01-02 01:03:22 -06:00
Behdad Esfahbod 31ee38e541 Minor 2013-01-02 01:03:18 -06:00
Behdad Esfahbod b8f238e49d Make FcCacheIsMmapSafe() threadsafe 2013-01-02 01:03:06 -06:00
Behdad Esfahbod b27a22aae9 Minor 2013-01-02 01:01:52 -06:00
Behdad Esfahbod 0552f26016 Make default-FcConfig threadsafe 2013-01-02 01:01:29 -06:00
Behdad Esfahbod e53f5da54f Minor 2013-01-02 00:58:52 -06:00
Behdad Esfahbod 7ae24b4554 Refactor; contain default config in fccfg.c 2013-01-02 00:58:31 -06:00
Behdad Esfahbod 32b0d88923 Make FcDefaultFini() threadsafe 2013-01-02 00:57:26 -06:00
Behdad Esfahbod 7019896c99 Make FcInitDebug() idempotent 2013-01-02 00:53:16 -06:00
Behdad Esfahbod b97ab0c949 Make FcGetDefaultLang and FcGetDefaultLangs thread-safe 2013-01-02 00:52:14 -06:00
Behdad Esfahbod 64af9e1917 Make refcounts, patterns, charsets, strings, and FcLang thread-safe 2013-01-02 00:51:00 -06:00
Behdad Esfahbod 814871b2aa Add thread-safety primitives 2013-01-02 00:38:36 -06:00
Behdad Esfahbod b53744383d Fix build stuff 2013-01-02 00:38:18 -06:00
Behdad Esfahbod db6d86a6c1 Remove shared-str pool
We used to have a shared-str pool.  Removed to make thread-safety
work easier.  My measurements show that the extra overhead is not
significant by any means.
2013-01-02 00:37:00 -06:00
Behdad Esfahbod ed41b23765 Switch .gitignore to git.mk 2013-01-02 00:36:12 -06:00
Behdad Esfahbod d58c31e6dc Use a static perfect hash table for object-name lookup
The hash table is generated by gperf.  For runtime element types, we use
a append-only linked list.

A bit clumsy, but I think I got it right.
2013-01-02 00:35:39 -06:00
Behdad Esfahbod 7c0f79c5fe Deprecate FcName(Un)RegisterObjectTypes / FcName(Un)RegisterConstants
These never worked as intended.  The problem is, if Fontconfig tries to
read config files when these new types / constants are not registered,
it errs.  As a result, no defined types / constants are usable from
config files.  Which makes these really useless.  Xft was the only user
of this API and even there it's not really used.  Just kill it.

One inch closer to thread-safety since we can fix the object-type hash
table at compile time.
2013-01-01 22:55:08 -06:00
Behdad Esfahbod a498f2f717 Minor 2013-01-01 20:27:54 -06:00
Behdad Esfahbod 8198127b25 Don't crash in FcPatternFormat() with NULL pattern 2013-01-01 20:20:31 -06:00
Behdad Esfahbod c9581b47c4 Don't crash in FcPatternDestroy with NULL pattern 2013-01-01 20:20:12 -06:00
Behdad Esfahbod e7d3e21632 Add NULL check 2013-01-01 20:19:57 -06:00
Behdad Esfahbod 5bb5da4c4a Refuse to set value to unsupported types during config too 2013-01-01 20:19:57 -06:00
Behdad Esfahbod 3878a12541 Make FC_DBG_OBJTYPES debug messages into warnings
And remove FC_DBG_OBJTYPES since it has no use now.
2013-01-01 20:19:53 -06:00
Behdad Esfahbod 209750a4e0 Warn if <name target="font"> appears in <match target="pattern"> 2012-12-31 20:11:12 -06:00
Behdad Esfahbod 31ce352bb3 Initialize matrix during name parsing
Before:
$ fc-match sans:matrix=2 -v | grep matrix
	matrix: [2 6.95183e-310; 0 0](s)

After:
$ fc-match sans:matrix=2 -v | grep matrix
	matrix: [2 0; 0 1](s)
2012-12-31 19:56:06 -06:00
Behdad Esfahbod b1630dc00e Enable fcarch assert checks even when FC_ARCHITECTURE is explicitly given
After all, if the asserts fail, the resulting library simply can't be
working correctly.
2012-12-31 17:20:29 -06:00
Behdad Esfahbod a603be89cd Unbreak build when FC_ARCHITECTURE is defined 2012-12-31 17:00:19 -06:00
Behdad Esfahbod 1fbb0b3b15 Don't warn if an unknown element is used in an expression
The type will be resolved at runtime...

For example, we can do this now without getting a warning:

<match target="font">
  <test name="scalable" compare="eq">
    <bool>false</bool>
  </test>
  <edit name="pixelsizefixupfactor" mode="assign">
    <divide>
      <name target="pattern">pixelsize</name>
      <name target="font"   >pixelsize</name>
    </divide>
  </edit>
  <edit name="matrix" mode="assign">
    <times>
      <name>matrix</name>
      <matrix>
        <name>pixelsizefixupfactor</name> <double>0</double>
        <double>0</double> <name>pixelsizefixupfactor</name>
       </matrix>
    </times>
  </edit>
  <edit name="size" mode="assign">
    <divide>
      <name>size</name>
      <name>pixelsizefixupfactor</name>
    </divide>
  </edit>
</match>

Previously the last edit was generating:

Fontconfig warning: "/home/behdad/.local/etc/fonts/conf.d/00-scale-bitmap-fonts.conf", line 29: saw unknown, expected number
2012-12-30 19:08:42 -06:00
Behdad Esfahbod 51b0044648 Allow target="font/pattern/default" in <name> elements
Based on idea from Raimund Steger.

For example, one can do something like this:

<match target="font">
  <test name="scalable" compare="eq">
    <bool>false</bool>
  </test>
  <edit name="pixelsizefixupfactor" mode="assign">
    <divide>
      <name target="pattern">pixelsize</name>
      <name target="font"   >pixelsize</name>
    </divide>
  </edit>
  <edit name="matrix" mode="assign">
    <times>
      <name>matrix</name>
      <matrix>
        <name>pixelsizefixupfactor</name> <double>0</double>
        <double>0</double> <name>pixelsizefixupfactor</name>
       </matrix>
    </times>
  </edit>
</match>

Part of work to make bitmap font scaling possible.  See thread
discussion:

http://lists.freedesktop.org/archives/fontconfig/2012-December/004498.html
2012-12-30 19:01:23 -06:00
Behdad Esfahbod d7e1965aa0 Remove memory accounting and reporting
That belongs in tools like cairo/util/malloc-stat.so
2012-12-29 23:12:07 -05:00
Behdad Esfahbod d823bb3cad Fixup from 4f6767470f 2012-12-29 22:57:53 -05:00
Behdad Esfahbod eb9ffac7e5 Fix more warnings 2012-12-29 22:56:14 -05:00
Behdad Esfahbod 1404af312a Fix warning 2012-12-29 22:55:36 -05:00
Behdad Esfahbod dd69d96e06 Fix sign-compare warnings 2012-12-29 22:47:49 -05:00
Behdad Esfahbod 4ad3a73691 Fix more warnings 2012-12-29 22:37:19 -05:00
Behdad Esfahbod 83d8019011 Fix unused-parameter warnings 2012-12-29 22:32:56 -05:00
Behdad Esfahbod 24cdcf52ab Fix compiler warnings 2012-12-29 22:24:24 -05:00
Behdad Esfahbod 4f6767470f Parse matrices of expressions
Previously a <matrix> element could only accept four <double> literals.
It now accepts full expressions, which can in turn poke into the
pattern, do math, etc.
2012-12-29 21:39:06 -05:00
Behdad Esfahbod 927dd3ddb5 Fix typo
Ouch, this has been wrong since 2004...  I guess no one uses <patelt>
stuff.
2012-12-29 20:14:07 -05:00
Akira TAGOH 9ce36f4bbe Check the system font to be initialized
config->fonts is an array and checking if config->fonts is a null
will not be useful.
2012-12-11 18:53:57 +09:00
Akira TAGOH 58040349e8 Fix a memory leak 2012-12-11 12:38:42 +09:00
Akira TAGOH 5ea3118ad6 Fix a typo that accessing to the out of array 2012-12-11 12:35:02 +09:00
Akira TAGOH cef2b50c66 clean up
ret won't be -1 if HAVE_STRUCT_DIRENT_D_TYPE isn't defined.
2012-12-11 12:30:05 +09:00
Akira TAGOH 608c5b590b Remove the duplicate null-check 2012-12-10 10:54:47 +09:00
Akira TAGOH e7954674eb Fix the wrong estimation for the memory usage information in fontconfig 2012-12-07 19:09:36 +09:00
Akira TAGOH 959442bca1 Fix a typo 2012-12-06 19:49:05 +09:00
Akira TAGOH 9231545c6b Do not show the deprecation warning if it is a symlink 2012-12-05 18:13:25 +09:00
Akira TAGOH 3d3629f86a Fix a potability issue about stdint.h 2012-11-27 18:25:11 +09:00
Akira TAGOH c20ac78b01 Bug 57114 - regression on FcFontMatch with namelang
After 7587d1c99d applied, family,
style, and fullname is localized against current locale or lang
if any though, the string in other languages were dropped from
the pattern. this caused unexpected mismatch on the target="font"
rules.

This fix adds other strings at the end of the list.
2012-11-15 16:37:32 +09:00
Akira TAGOH 8890f94438 Fix wrongly squashing for the network path on Win32.
Patch from Diego Santa Cruz
2012-10-09 11:03:03 +09:00
Akira TAGOH 535e0a37d6 Bug 54138 - X_OK permission is invalid for win32 access(..) calls
X_OK checking was added back in 8ae1e3d5dc
which was removed due to the same reason in
238489030a.
apparently the test case in Bug#18934 still works without it.
so I'm removing it again to get this working on Windows.
2012-08-31 12:39:38 +09:00
Akira TAGOH 375cdbce9d Bug 53585 - Two highly-visible typos in src/fcxml.c 2012-08-16 20:33:12 +09:00
Akira TAGOH da9400212d Fix a build fail with gcc 2.95, not supporting the flexible array members. 2012-07-09 14:46:51 +09:00
Marius Tolzmann e5a59eac90 Fix warning about deprecated, non-existent config includes
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 8: reading configurations from ~/.fonts.conf.d is deprecated.

Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.

Be polite and do not issue the warning if deprecated config includes
(e.g. ~/.fonts.conf.d and/or ~/.fonts.conf) do not exist.
2012-06-22 13:58:46 +09:00
Marius Tolzmann 3a5e9bc75d Fix newline in warning about deprecated config includes 2012-06-22 13:57:13 +09:00
Akira TAGOH 4353df754f clean up the lock file properly on even hardlink-not-supported filesystem. 2012-06-18 10:52:21 +09:00
Akira TAGOH 997a64a67b Fix the fail of make install with --disable-shared on Win32 2012-06-14 11:27:31 +09:00
Akira TAGOH cd280f6532 Fix a build fail on MINGW 2012-06-13 20:01:30 +09:00
Akira TAGOH b447fc5d52 Bug 50835 - Deprecate FC_GLOBAL_ADVANCE
FC_GLOBAL_ADVANCE is deprecated. this flag is simply ignored on
freetype 2.4.5 or later.
2012-06-11 23:28:55 +09:00
Mark Brand 0b20bd0281 fix building for WIN32
8c255fb185 moved some code out of switch
but did not declare 'buffer'. Also, replacing the "break" with
"goto bail" neglected the WIN32 specific code.
2012-06-11 20:13:02 +09:00
Akira TAGOH cf70eaa3bf Bug 50525 - superfluous whitespace in the style 2012-06-08 19:41:59 +09:00
Akira TAGOH f4103bf708 fcdefault: Add the lang object at FcConfigSubstituteWithPat() only when kind is FcMatchPattern 2012-06-08 19:17:57 +09:00
Akira TAGOH 07e52eeb09 fcdefault: no need to set FC_LANG in FcDefaultSubstitute() anymore 2012-06-08 15:54:48 +09:00
Akira TAGOH 550fd49d4f Add the default language to the pattern prior to do build the substitution
the default language is referred from the FC_LANG environment variable
or the current locale
2012-06-08 15:48:30 +09:00
Akira TAGOH 2261a64ce1 fcdefault: fallback if the environment variables are empty
try to fallback if FC_LANG, LC_ALL, LC_CTYPE and LANG is empty
2012-06-08 15:47:52 +09:00
Akira TAGOH bbc8fb5ba7 Bug 32853 - Export API to get the default language
Add a new API FcGetDefaultLangs() to export the string sets of the default
languages.
2012-06-08 15:18:30 +09:00
Akira TAGOH 1b692d8ab9 Fix the wrong estimation for the memory usage information in fontconfig 2012-06-01 19:06:17 +09:00
Akira TAGOH 5254a6630f Fix a typo and polish the previous change 2012-05-31 13:07:29 +09:00
Akira TAGOH 4a741e9a0a Fix the build fail on Solaris
It's introduced by 0ac6c98294.
Use lstat() and S_ISDIR() to check if it's the directory or not
if there are no d_type in struct dirent.
2012-05-30 18:30:49 +09:00
Mikhail Gusarov 0ac6c98294 Fix cache aging for fonts on FAT filesystem under Linux
Windows does not update mtime of directory on FAT filesystem when
file is added to it or removed from it. Fontconfig uses mtime of
directory to check cache file aging and hence fails to detect
newly added or recently removed files.

This changeset detects FAT filesystem (currently implemented for
Linux) and adds generating checksum of directory entries instead
of using mtime which guarantees proper cache rebuild.

For non-FAT filesystems this patch adds single syscall per directory
which is negligeable overhead.

This fixes bug https://bugs.freedesktop.org/show_bug.cgi?id=25535

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2012-05-28 16:46:04 +09:00
Akira TAGOH dc2da23e69 Move statfs/statvfs wrapper to fcstat.c and add a test for the mtime broken fs
just rework to share the efforts between FcIsFsMmapSafe() and FcIsFsMtimeBroken().
2012-05-28 16:46:01 +09:00
Mikhail Gusarov 6a83c1ad40 Move FcStat to separate compilation unit
FcStat() logic is quite complicated in presence of various semi-broken operating
systems and filesystems, split it out in order to make it a bit easier.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2012-05-28 16:01:00 +09:00
Akira TAGOH 26160366d7 fcatomic: fallback to create a directory with FcAtomicLock
link(2) might be failed on the filesystem that doesn't support
the hard link. e.g. FcAtomicLock() always fails on FAT filesystem
when link(2) is available.
So that may be a good idea to fallback if link(2) is failed.
2012-05-28 15:59:33 +09:00
Akira TAGOH 2837c63876 Bug 33644 - Fontconfig doesn't match correctly in <test>
Warn if the multiple values is set to <test>, including the case of
in <alias> because the behavior isn't intuitive since so many users
is asking for a help to get things working for their expectation.

Use multiple <match>s or <alias>es for OR operator and
multiple <test>s for AND operator.
2012-05-25 13:11:25 +09:00
Akira TAGOH 8c255fb185 Bug 20411 - fontconfig doesn't match FreeDesktop directories specs
Allows reading configuration files, fonts and cache files from
the directories where the XDG Base Directory Specification defines.

the old directories are still in the configuration files for
the backward compatibility.
2012-05-18 11:12:50 +09:00
Akira TAGOH bc4517d8e5 Bug 19128 - Handling whitespace in aliases
Add a new attribute `ignore-blanks' to <test>.
When this is set to "true", any blanks in the string will be ignored
on comparison.  This takes effects for compare="eq" or "not_eq" only.

Also changed the behavior of the comparison on <alias> too.
2012-05-14 12:06:12 +09:00
Akira TAGOH 5ac12c0e94 fcarch.c: get rid of the duplicate definition of FC_MAX
FC_MAX is also available in src/fcint.h
2012-05-10 16:47:09 +09:00
Keith Packard d81407611b Deal with architectures where ALIGNOF_DOUBLE < 4
This patch isn't really tested as I don't have such a machine, but I
have a bug report that on m68k machines, double values are aligned on
smaller than 4 byte boundaries. If ALIGNOF_DOUBLE < sizeof(int),
the "expected" sizeof of FcValue is miscomputed. Use the maximum of 4
(sizeof (int)) and ALIGNOF_DOUBLE when computing the expected size of
FcValue.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-05-02 12:01:38 +09:00
Akira TAGOH d2718257f9 Output more verbose debugging log to show where to insert the element into the value list 2012-05-01 20:22:17 +09:00
Akira TAGOH 7d65f9f514 Bug 39278 - make usage of mmap optional
Stop using mmap() if the cache file is stored on NFS.
also added FONTCONFIG_USE_MMAP environment variable to enforce the use of
or not the use of mmap(2) regardless of what the filesystem the cache files
are stored on.
2012-04-25 16:38:01 +09:00
Akira TAGOH 7587d1c99d Bug 27765 - FcMatch() returns style in wrong language
Add "namelang" object to obtain the localized name in the font regardless
of the lang object. it's applied to "familylang", "stylelang" and
"fullnamelang" alltogether. this would helps if one wants to enforce
selecting them in the specific language if any.  the default value for
the namelang object is determined from current locale.
2012-04-24 12:44:56 +09:00
Akira TAGOH 06d6b7c312 Create CACHEDIR.TAG when fc-cache is run or only when the cache directory is created at the runtime.
Also add FcCacheCreateTagFile() API to do create CACHEDIR.TAG on the cache
directory.
2012-04-23 11:26:32 +09:00
Akira TAGOH 22dc546090 Fix a build issue again when no regex functions available
Reported by Jon TURNEY
2012-04-20 20:12:24 +09:00
Akira TAGOH dd2a3d3520 Bug 25151 - Move cleanCacheDirectory() from fc-cache.c into
the library

Add FcDirCacheScan() API to clean up the cache files in the directory.
2012-04-18 12:55:23 +09:00
Keith Packard 9e62fcedfe Use posix_fadvise to speed startup
Given that fontconfig will scan all of the cache file data during the
first font search, ask the kernel to start reading the pages right away.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-04-17 12:20:25 +09:00
Akira TAGOH 470e92c9db Bug 27526 - Compatibility fix for old windows sytems
Patch from Gianluigi Tiesi
2012-04-12 14:01:25 +09:00
Akira TAGOH ac6271dbac Bug 48573 - platform without regex do not have also REG_XXX defines
Fix a build issue on the platforms where regex isn't available
2012-04-12 11:01:12 +09:00
Akira TAGOH 9231d79ad1 Bug 28491 - Allow matching on FC_FILE
Allow :file=/path/to/font/file on matching
2012-04-11 16:36:36 +09:00
Akira TAGOH 2589207cfd Bug 26830 - Add search for libiconv non-default directory
Add --with-libiconv, --with-libiconv-includes and --with-libiconv-lib
to specify the directory where libiconv might be installed.
2012-04-10 18:45:31 +09:00
Akira TAGOH ddefa5021f Bug 22862 - <alias> ignores <match> <test>s
Allow to use the test elements in the alias element.
2012-04-06 11:14:42 +09:00
Akira TAGOH e181ab4de5 Bug 29341 - Make some fontconfig paths configurable
Add configure options to set the directory to be installed:
  --with-templatedir for the configuration files a.k.a.
    /etc/fonts/conf.avail
  --with-baseconfigdir for fonts.conf etc a.k.a. /etc/fonts
  --with-configdir for the active configuration files a.k.a.
    /etc/fonts/conf.d
  --with-xmldir for fonts.dtd etc

and the default path for templatedir is changed to
${datadir}/fontconfig/conf.avail
2012-04-05 12:23:49 +09:00
Akira TAGOH 9fe7c986c6 Bug 48020 - Fix for src/makealias on Solaris 10
Use the command substitution `command` instead of $(command) for
Solaris 10.
2012-03-29 15:43:38 +09:00
Akira TAGOH becbdaebe3 Move workaround macros for fat binaries into the separate header file 2012-03-29 12:50:47 +09:00
Akira TAGOH 4a060729a1 fcpat: Increase the number of buckets in the shared string hash table
This is a reasonably conservative increase in the number of buckets in the hash
table to 251.  After FcInit(), there are 240 shared strings in use on my system
(from configuration files I assume).  The hash value is stored in each link in
the chains so comparison are actually not very expensive.  This change should
reduce the average length of chains by a factor of 8.  With the reference
counted strings, it should keep the average length of chains to about 2.  The
number of buckets is prime so as not to rely too much on the quality of the
hash function.

https://bugs.freedesktop.org/show_bug.cgi?id=17832#c5

Patch from Karl Tomlinson
2012-03-28 13:42:01 +09:00
Akira TAGOH d8dcff7b96 Bug 17832 - Memory leaks due to FcStrStaticName use for external patterns
Use the reference-counted strings instead of the static strings

Patch from Karl Tomlinson
2012-03-28 13:42:01 +09:00
Akira TAGOH ea1c6ea337 Fix a memory leak in FcDirScanConfig() 2012-03-27 21:06:36 +09:00
Akira TAGOH 92ac054ce5 fcmatch: Set FcResultMatch at the end if the return value is valid.
In the previous code, the result of 'result' in the argument for
FcFontSetSort() and FcFontSetMatch() wasn't predictable and not reliable to
check if the return value is valid or not. this change is to ensure if it's
performed successfully.
2012-03-22 19:15:27 +09:00
Jeremy Huddleston 8cc4498122 fcarch: Check for architecture signature at compile time rather than configure time
https://bugs.freedesktop.org/show_bug.cgi?id=20208

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-21 11:59:01 +09:00
Akira TAGOH 93460f93e9 Fix a build issue due to the use of non-portable variables
$< isn't supported in BSD make say. $(RM) is pre-defined in GNU make
though, not in BSD make say. so changed to check on configure if it's
pre-defined by make, otherwise set the appropriate command to $(RM).

This would be a workaround until it has the certain pre-defined value.
2012-03-16 16:34:37 +09:00
Akira TAGOH a5b609196f Revert "Fix a build fail on some environment."
This reverts commit 0fdfddf2ac.

Conflicts:

	doc/Makefile.am
2012-03-16 11:55:30 +09:00
Akira TAGOH 0fdfddf2ac Fix a build fail on some environment. 2012-03-10 23:30:30 +09:00
Akira TAGOH 0ca752dd25 Check null value for given object to avoid possibly segfaulting 2012-03-07 17:56:39 +09:00
Akira TAGOH 1f01c4b60c Bug 23336 - unable to display bitmap-only (SFNT) TrueType or OpenType
Force to find out a size for bitmap-only ttf to avoid the blank glyphs
in the font.

Patch from Bug Fly
2012-03-07 17:32:14 +09:00
Akira TAGOH a13d518fdd Bug 41694 - FcCache functions have random-number-generator side effects
Use the own random number generator state if possible.
2012-02-28 12:52:25 +09:00
Akira TAGOH 5e4ea1104c Do not update stream->pos when seeking is failed. 2012-02-22 16:50:13 +09:00
Akira TAGOH 71b14d645f Bug 46169 - Pointer error in FcConfigGlobMatch
Fix possibly accessing the invalid memory and a crash in the worst case
when the glob string is longer than the string.
2012-02-22 16:30:05 +09:00
Mike Frysinger 3abf981542 makealias: handle missing funcs better
When adding new functions, if the actual definition doesn't match the
header (say due to a typo), the regeneration of the internal headers
get confused and output bad cpp logic.  This causes gcc to barf due
to mismatched #ifdef/#endif.  Which is a pain to figure out due to
the sheer voulme of generated code.

So tweak the makealias script to detect this case and error out.
While we're here, improve the cpp output a bit to indent, include
comments, and merge similar ifdef blocks.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Mike Frysinger d9c4462778 FcObjectValidType: tweak -1 checking
Newer gcc doesn't like when you switch on an enum and use a value
that isn't declared:

fcname.c: In function 'FcObjectValidType':
fcname.c:299:2: warning: case value '4294967295'
	not in enumerated type 'FcType' [-Wswitch]

So tweak the logic to avoid this warning.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Mike Frysinger 97c9506e4d fix build warnings when using --with-arch
Latest configure code will setup FC_ARCHITECTURE directly rather than
going through ARCHITECTURE, so update fcarch.h accordingly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Mike Frysinger 123d344f45 FcName{,Get}Constant: constify string input
These funcs don't modify the incoming string, so add const markings.
This is the "right thing", shouldn't change the ABI, and fixes some
gcc warnings:

fccfg.c: In function 'FcConfigEvaluate':
fccfg.c:916:2: warning: passing argument 1 of 'IA__FcNameConstant'
	discards 'const' qualifier from pointer target type [enabled by default]
fcalias.h:253:34: note: expected 'FcChar8 *' but
	argument is of type 'const FcChar8 *'

fcxml.c: In function 'FcTypecheckExpr':
fcxml.c:604:2: warning: passing argument 1 of 'IA__FcNameGetConstant'
	discards 'const' qualifier from pointer target type [enabled by default]
fcalias.h:251:37: note: expected 'FcChar8 *' but
	argument is of type 'const FcChar8 *'

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Mike Frysinger 647569d029 FcStat: change to FcChar8 for first arg
This shouldn't affect the ABI, makes FcStat more like the rest of the
fontconfig API, and fixes warnings where we pass FcChar8* pointers in
to this func from other places.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Mike Frysinger e3a66c2937 delete unused variables
Newer gcc is better at detecting set-but-unused variables.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Mike Frysinger 6f020161e8 FcStrPlus: optimize a little
We've already calculated the lengths of these strings, so re-use those
values to avoid having to rescan the strings multiple times.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:09:51 -05:00
Akira TAGOH a18ca17b62 Bug 40452 - Running 'fc-match --all' core dumps when no fonts are installed
This would changes the behavior of FcFontSort().
it won't returns NULL afterward.
2012-02-21 15:29:56 +09:00
Akira TAGOH cbb6ee1662 Bug 35517 - Remove Apple Roman cmap support
Get rid of the apple roman encoding related code
2012-02-21 15:16:14 +09:00
Behdad Esfahbod 082caefb6d Bug 41171 - Invalid use of memset 2011-09-24 13:52:05 -04:00
Behdad Esfahbod bf3bfa72d9 Fix stupid bug in FcFontSort()
I broke FcFontSort() language handling at the end of 2008 with this
commit: c7641f28

G-d knows how many of the lang-matching bugs in bugzilla will be
fixed by this changed...

I'm really sorry, everyone!
2011-06-22 13:06:19 -04:00
Behdad Esfahbod e61eba94ef Switch fc-cat to use FcPatternFormat()
Added the a builtin "fccat" to FcPatternFormat().
2011-06-20 11:55:25 -04:00
Behdad Esfahbod a15ac5d384 Switch fc-match to use FcPatternFormat()
Fix small bug in FcPatternFormat that was letting element-default to
consume the convertor sequence.
2011-06-20 11:32:46 -04:00
Behdad Esfahbod e0be405a1d Bug 26718 - "fc-match sans file" doesn't work
- Do not throw away FC_FILE in FcNameUnparse
- Update the builtin "fclist" format to remove FC_FILE properly instead
- Switch fc-list to use FcPatternFormat()

Note that I had previously broken fc-list and it was not showing the
file name anymore.  No one noticed that it seems!  Now fixed.
2011-06-20 11:22:17 -04:00
Behdad Esfahbod 0fcf866d44 Bug 36577 - Updating cache with no-bitmaps disables bitmap fonts...
Do not remove blacklisted fonts during cache generation.  We already
apply the blacklist when reading the caches.  The idea always has been
that the config should not affect caches built, although that design
was tarnished with the introduction of target="scan" configurations.
2011-06-20 11:07:56 -04:00
Behdad Esfahbod 1c475d5c8c Bug 35587 - Add padding to make valgrind and glibc not hate each other 2011-03-28 16:33:12 -04:00
Behdad Esfahbod c21fb9ac27 Always define FcStat as a function
Such that first arg is const char *.  We also need to make more changes
in that function as part of some other bug.
2011-03-14 18:49:21 -03:00
Behdad Esfahbod 6c7915c105 Mark constant strings as constant
Fixes a few compiler warnings in fcxml.c and makes it clear that they
should not be freed.
2011-03-14 18:21:32 -03:00
Behdad Esfahbod c76ed777dd Bug 30566 - fcformat.c:interpret_enumerate() passes uninitialized idx to FcPatternGetLangSet() 2011-03-14 18:04:59 -03:00
Behdad Esfahbod 0c7b867617 Fix assertion failure on le32d4
Reported by Jon TURNEY.
2011-01-02 13:25:29 -07:00
Behdad Esfahbod 43bf659eed Skip <range> elements with begin > end 2010-12-28 02:55:31 -06:00
Behdad Esfahbod 549c9962a4 Allow editing charset and lang in target="scan"
Merge commit 'fa269cf812ee304534b0e4c44662202496008db0'

Fixes:
Bug 31969 - Can't modify charset in target="scan"
Bug 23758 - Can't modify lang in target="scan"
2010-12-28 02:51:10 -06:00
Behdad Esfahbod d1a0fca316 Make fc-arch stuff cross-compiling-safe
Fixes:
Bug 32679 - fontconfig-2.8.0 does not cross compile
Bug 25462 - Cross-compilation doesn't work
2010-12-28 01:22:34 -06:00
Akira TAGOH 3c862aad9f Add editing langset feature.
The syntax to add any langset to the langset table looks like:

<match target="scan">
    <test name="family">
        <string>Buggy Sans</string>
    </test>
    <edit name="lang" mode="assign">
        <plus>
            <name>lang</name>
            <langset>
                <string>zh-cn</string>
                <string>zh-tw</string>
            </langset>
        </plus>
    </edit>
</match>

To remove any langset from the langset table:

<match target="scan">
    <test name="family">
        <string>Buggy Sans</string>
    </test>
    <edit name="lang" mode="assign">
        <minus>
            <name>lang</name>
            <langset>
                <string>ja</string>
            </langset>
        </minus>
    </edit>
</match>
2010-12-09 11:40:08 +09:00
Akira TAGOH d975cdda78 Add the range support in blank element 2010-12-09 11:36:26 +09:00
Akira TAGOH 857b7efe1e Add charset editing feature.
The syntax to add any characters to the charset table looks like:

<match target="scan">
    <test name="family">
        <string>Buggy Sans</string>
    </test>
    <edit name="charset" mode="assign">
        <plus>
            <name>charset</name>
            <charset>
                <int>0x3220</int>    <!-- PARENTHESIZED IDEOGRAPH ONE -->
            </charset>
        </plus>
    </edit>
</match>

To remove any characters from the charset table:

<match target="scan">
    <test name="family">
        <string>Buggy Sans</string>
    </test>
    <edit name="charset" mode="assign">
        <minus>
            <name>charset</name>
            <charset>
                <int>0x06CC</int>    <!-- ARABIC LETTER FARSI YEH -->
                <int>0x06D2</int>    <!-- ARABIC LETTER YEH BARREE -->
                <int>0x06D3</int>    <!-- ARABIC LETTER YEH BARREE WITH HAMZA ABOVE -->
            </charset>
        </minus>
    </edit>
</match>

You could also use the range element for convenience:

...
            <charset>
                <int>0x06CC</int>    <!-- ARABIC LETTER FARSI YEH -->
                <range>
                    <int>0x06D2</int>    <!-- ARABIC LETTER YEH BARREE -->
                    <int>0x06D3</int>    <!-- ARABIC LETTER YEH BARREE WITH HAMZA ABOVE -->
                </range>
            </charset>
...
2010-12-09 11:09:24 +09:00
Behdad Esfahbod 0d47cfabd8 Bug 28958 - lang=en matches other langs
Patch from Akira TAGOH.
2010-12-07 18:48:56 -05:00
Behdad Esfahbod 1e7a2a4f6c Fix returned value 2010-12-02 08:13:59 -05:00
Behdad Esfahbod 5aaf466d38 Cleanup copyright notices to replace "Keith Packard" with "the author(s)" 2010-11-10 16:45:42 -05:00
Behdad Esfahbod 52960d05eb Add new public API: FcCharSetDelChar() 2010-09-21 13:14:41 -04:00
Behdad Esfahbod 25afea879d Add comments 2010-08-18 11:31:31 -04:00
Behdad Esfahbod ac5a233643 Fix comment 2010-04-12 12:49:53 -04:00
Behdad Esfahbod 594dcef0f3 Remove all training whitespaces 2010-04-12 12:19:05 -04:00
Behdad Esfahbod d0d1f3904c More whitespace 2010-04-12 12:10:05 -04:00
Behdad Esfahbod 2b0f3f1128 Whitespace 2010-04-12 11:52:09 -04:00
Behdad Esfahbod 632612b810 Accept TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS from name table
The OT spec says:

"When building a Unicode font for Windows, the platform ID should be 3 and the
encoding ID should be 1. When building a symbol font for Windows, the platform
ID should be 3 and the encoding ID should be 0."

We were ignoring the SYMBOL_CS entry before.  It's UTF-16/UCS-2 like the
UNICODE_CS.

Also, always use UTF-16BE instead of UCS-2BE.  The conversion was doing
UTF-16BE anyway.
2010-04-07 12:49:30 -04:00
Behdad Esfahbod 3cd1e673a9 Bug 26157 Solaris/Sun C 5.8: compilation of 2.8.0 and 2.7.3 fails 2010-02-25 17:11:14 -05:00
Tor Lillqvist bb8fdae8ad Use correct autoconf variable
Use LIBT_CURRENT_MINUS_AGE instead of the undefined
lt_current_minus_age for the name of the DLL when generating the MS
style import library.
2009-11-18 21:55:39 +02:00
Behdad Esfahbod d2fb683796 Clean up Makefile's a bit 2009-11-18 09:35:40 -05:00
Behdad Esfahbod 192927225c [fc-glyphname] Rename internal arrays to prefix with _fc_
Although they were static, I was still surprised that gdb was seeing
our variable "glyphs".  Not helpful.
2009-11-18 09:26:24 -05:00
Behdad Esfahbod 3e5e83e12e [src] Create fcglyphname.h automatically 2009-11-18 09:26:01 -05:00
Behdad Esfahbod 77f4e60a32 Remove bogus comment
Last night in between my dreams I also noticed that we support Unicode
values up to 0x01000000 and not 0x00100000 which I thought before.
This covers the entire Unicode range.
2009-11-18 09:10:05 -05:00
Behdad Esfahbod a90a3ad97a Make sure fclang.h and fcarch.h are built 2009-11-17 12:10:01 -05:00
Behdad Esfahbod a3b2426819 [lang] Fix serializing LangSet from older versions 2009-11-16 18:29:26 -05:00
Behdad Esfahbod 8480c6f863 [arch] Try to ensure proper FcLangSet alignment in arch 2009-11-16 17:46:18 -05:00
Behdad Esfahbod dffcb2a083 [xml] Remove unused code 2009-11-16 17:46:18 -05:00
Behdad Esfahbod b2d9101230 [int] Remove more unused macros 2009-11-16 17:46:18 -05:00
Behdad Esfahbod 963820fcbf [int] Remove fc_value_* macros that did nothing other than renaming 2009-11-16 17:46:18 -05:00
Behdad Esfahbod 888f9427ae [int] Remove fc_storage_type() in favor of direct access to v->type 2009-11-16 17:46:18 -05:00
Behdad Esfahbod 486fa46893 Remove unused macros 2009-11-16 17:46:18 -05:00
Behdad Esfahbod 1f4e6fecde Bump cache version up from 2 to 3 and fix FcLangSet caching/crash
Protect cache against future expansions of FcLangSet (adding new
orth files).  Previously, doing so could change the size of
that struct.  Indeed, that happened between 2.6.0 and 2.7.3, causing
crashes.  Unfortunately, sizeof(FcLangSet) was not checked in fcarch.c.

This changes FcLangSet code to be able to cope with struct size changes.
And change cache format, hence bumping from 2 to 3.
2009-11-16 17:46:12 -05:00
Behdad Esfahbod 6b1fc678ca [int] Define MIN/MAX/ABS macros 2009-11-16 17:28:50 -05:00
Behdad Esfahbod 8009229bc5 Move FcAlign to fcint.h 2009-11-16 15:12:52 -05:00
Behdad Esfahbod 5e544b32d8 Use default config in FcFileScan() and FcDirScan()
Before a NULL config was passed down adn essentially FcFileScan was
equivalent to FcFreeTypeQuery.  Now fc-scan tool correctly applies
the configuration to the scanned patterns.
2009-09-06 22:10:22 -04:00
Behdad Esfahbod c5f0a65b36 Revert "Fix FcNameUnparseLangSet()" and redo it
This reverts commit 5c6d1ff23b and
fixes that bug using the new reverse-map I added in the previous
commit.
2009-08-25 20:41:34 -04:00
Behdad Esfahbod d354a321ee Bug 23419 - "contains" expression seems not working on the fontconfig rule
Fix bug in FcLangSetContains(), similar to
5c6d1ff23b
2009-08-25 20:39:20 -04:00
Behdad Esfahbod f33a23133e Bug 22037 - No Fonts installed on a default install on Windows Server 2003
Make it easy to install on older Windows
2009-08-21 13:41:41 -04:00
Tor Lillqvist 8b1ceef0b7 Use multi-byte codepage aware string function on Windows
The East Asian double-byte codepages have characters with backslash as
the second byte, so we must use _mbsrchr() instead of strrchr() when
looking at pathnames in the system codepage.
2009-08-13 18:19:56 -04:00
Tor Lillqvist d15678127a Fix heap corruption on Windows in FcEndElement()
Must not call FcStrFree() on a value returned by
FcStrBufDoneStatic(). In the Windows code don't bother with dynamic
allocation, just use a local buffer.
2009-08-13 18:17:33 -04:00
Tor Lillqvist a1b6e34a9a Fix MinGW compilation
Need to define _WIN32_WINNT as 0x0500 to get declaration for
GetSystemWindowsDirectory().
2009-08-13 18:13:04 -04:00
Behdad Esfahbod 7c12181f7a Improve charset printing 2009-07-28 14:23:10 -04:00
Behdad Esfahbod 7575c66661 TT_MS_ID_UCS_4 is really UTF-16BE, not UTF-32
Reported by Yuriy Kaminskiy.
2009-07-25 16:38:52 -04:00
Behdad Esfahbod 5c6d1ff23b Fix FcNameUnparseLangSet()
Was broken since ffd6668b46
2009-07-22 19:25:24 -04:00
Behdad Esfahbod d9741a7f1a Remove unused macros 2009-07-22 19:01:06 -04:00
Karl Tomlinson 792ce655cb Don't change the order of names unnecessarily (#20128)
so that TT_NAME_ID_PREFERRED_FAMILY is consistently preferred over
TT_NAME_ID_FONT_FAMILY when both are specified for the default language.
2009-07-22 08:39:23 -04:00
Behdad Esfahbod 327fc9d183 Use GetSystemWindowsDirectory() instead of GetWindowsDirectory() (#22037) 2009-07-21 15:41:47 -04:00
Behdad Esfahbod 16e55c7c85 Fix leak with string VStack objects 2009-07-20 16:30:12 -04:00
Behdad Esfahbod 55e202a62d Remove unused ftglue code 2009-06-28 14:14:46 -04:00
Behdad Esfahbod 57cf838ccc Fix win32 build 2009-06-28 13:46:41 -04:00
Behdad Esfahbod 3164ac7622 [xml] Intern more strings 2009-06-24 13:52:13 -04:00
Behdad Esfahbod 390c05e64a [xml] Allocate FcExpr's in a pool in FcConfig
Reduces number of malloc's for FcExprs from hundreds into single digits.
2009-06-24 13:52:13 -04:00
Behdad Esfahbod 398d436441 [xml] Mark more symbols static 2009-06-24 13:52:13 -04:00
Behdad Esfahbod a96ecbfa20 [xml] Centralize FcExpr allocation
To be improved, using a central pool.
2009-06-24 13:52:13 -04:00
Behdad Esfahbod 5aebb3e299 Remove unused prototypes and function 2009-06-24 13:52:12 -04:00
Behdad Esfahbod 900723f3d2 [charset] Grow internal FcCharset arrays exponentially 2009-06-24 13:52:12 -04:00
Behdad Esfahbod cce69b07ef Always set *changed in FcCharsetMerge 2009-06-24 13:52:12 -04:00
Behdad Esfahbod 86bdf4598f Add XXX note about Unicode Plane 16 2009-06-24 13:52:12 -04:00
Behdad Esfahbod efe5eae26b Simplify FcValueSave() semantics 2009-06-24 13:52:11 -04:00
Behdad Esfahbod 8ea654b2aa Use/prefer WWS family/style (name table id 21/22) 2009-06-24 13:52:11 -04:00
Behdad Esfahbod 76845a40c5 Mark matchers array const (#21935) 2009-06-24 13:52:11 -04:00
Behdad Esfahbod 58aa0c8ee8 Detect TrueType Collections by checking the font data header
Instead of checking for "face->num_faces >1". (GNOME bug #577952)
2009-06-24 13:52:10 -04:00
Serge van den Boom 1dd95fcb8b Correctly handle mmap() failure (#21062) 2009-06-24 13:52:10 -04:00
Behdad Esfahbod ffd6668b46 [fc-lang] Make LangSet representation in the cache files stable
Fontconfig assigns an index number to each language it knows about.
The index is used to index a bit in FcLangSet language map.  The bit
map is stored in the cache.

Previously fc-lang simply sorted the list of languages and assigned
them an index starting from zero.  Net effect is that whenever new
orth files were added, all the FcLangSet info in the cache files would
become invalid.  This was causing weird bugs like this one:

  https://bugzilla.redhat.com/show_bug.cgi?id=490888

With this commit we fix the index assigned to each language.  The index
will be based on the order the orth files are passed to fc-lang.  As a
result all orth files are explicitly listed in Makefile.am now, and
new additions should be made to the end of the list.  The list is made
to reflect the sorted list of orthographies from 2.6.0 released followed
by new additions since.

This fixes the stability problem.  Needless to say, recreating caches
is necessary before any new orthography is recognized in existing fonts,
but at least the existing caches are still valid and don't cause bugs
like the above.
2009-06-24 13:52:10 -04:00
Behdad Esfahbod 4d13536db4 [fcstr] Remove unused variable 2009-06-24 13:52:09 -04:00
Behdad Esfahbod caeea376da Document FcPatternFormat() format 2009-03-13 19:06:43 -04:00
Behdad Esfahbod f6d8343989 [fcformat] Fix default-value handling 2009-03-13 17:59:29 -04:00
Behdad Esfahbod 3074a73b41 Replace 'KEITH PACKARD' with 'THE AUTHOR(S)' in license text in all files 2009-03-13 17:59:28 -04:00
Behdad Esfahbod de69ee14d3 [fcxml.c] Embed a static 64-byte attr buffer in FcPStack
Reduces number of mallocs called from FcConfigSaveAttr in my small test
from 160 down to 6.
2009-03-12 13:14:38 -04:00
Behdad Esfahbod 39861b7d9c [fcxml] Embed 64 static FcVStack objects in FcConfigParse
This reduces the number of mallocs called from FcVStackPush from
over 800 down to zero.
2009-03-12 13:14:38 -04:00
Behdad Esfahbod 1d7b47da9d [fcxml] Embed 8 static FcPStack objects in FcConfigParse
This reduces the number of mallocs called from FcPStackPush from
over 900 down to zero.
2009-03-12 13:14:38 -04:00
Behdad Esfahbod 532d8a1dbc [fcxml] Don't allocate attr array if there are no attributes
Reduces number of mallocs from FcConfigSaveAttr() in my small test
from over 900 down to 157.
2009-03-12 13:14:37 -04:00
Behdad Esfahbod 3ed70071cd [fcstr,fcxml] Don't copy FcStrBuf contents when we would free it soon
We can simply NUL-terminate the buffer and use it.  Reduces number of
mallocs called from FcStrBufDone in my small test from 631 down to 66.
2009-03-12 13:14:37 -04:00
Behdad Esfahbod 7d35c11b33 [fcstr.c] Embed a static 64-byte buffer in FcStrBuf
Reduces number of mallocs called from FcStrBufChar in my small test
from 900 down to 6.
2009-03-12 13:14:37 -04:00
Behdad Esfahbod 04ac14fc14 [fcformat] Add list of undocumented language features 2009-02-16 02:14:41 -08:00
Behdad Esfahbod 384542fa91 [fcformat] Add a 'pkgkit' builtin that prints tags for font packages
For DejaVu Sans Condensed it generates:

font(dejavusans)
font(dejavusanscondensed)
font(:lang=aa)
font(:lang=ab)
...
font(:lang=yo)
font(:lang=zu)
2009-02-16 02:14:30 -08:00
Behdad Esfahbod 9d58d01c5c [fcformat] Enumerate langsets like we do arrays of values
If one asks for a format like '%{[]elt{expr}}' and the first value
for elt is a langset, we enumerate the langset languages in expr.
2009-02-15 14:13:38 -08:00
Behdad Esfahbod d62b85af21 [fclang] Implement FcLangSetGetLangs() (#18846) 2009-02-15 14:13:34 -08:00
Behdad Esfahbod cdfb76585e [fcformat] Implement array enumeration
The format '%{[]family,familylang{expr}}' expands expr once for the first
value of family and familylang, then for the second, etc, until both lists
are exhausted.
2009-02-15 13:40:31 -08:00
Behdad Esfahbod 0673ef3881 [fcformat] Support 'default value' for simple tags
The format '%{family:-XXX} prints XٓٓٓٓXX if the element family is not defined.
Also works for things like '%{family[1]:-XXX}'.
2009-02-15 13:40:30 -08:00
Behdad Esfahbod 9c83a8376f [fcformat] Support indexing simple tags
The format '%{family[0]}' will only output the first value for element family.
2009-02-15 13:40:30 -08:00
Behdad Esfahbod d04a750764 [fcformat] Add support for builtin formats
The '%{=unparse}' format expands to the FcNameUnparse() result on the
pattern.  Need to add '%{=verbose}' for FcPatternPrint() output but
need to change that function to output to a string first.

Also added the '%{=fclist}' and '%{=fcmatch}' which format like the
default format of fc-list and fc-match respectively.
2009-02-15 13:40:30 -08:00
Behdad Esfahbod 85c7fb67ce [fcformat] Refactor code to avoid malloc 2009-02-15 13:40:30 -08:00
Behdad Esfahbod d4f7a4c6af [fcformat] Start adding builtins 2009-02-15 13:40:29 -08:00
Behdad Esfahbod c8f5933d13 [fcformat] Implement 'delete', 'escape', and 'translate' filter functions
The format '%{family|delete( )}' expands to family values with space removed.
The format '%{family|translate( ,-)}' expands to family values with space
replaced by dash.  Multiple chars are supported, like tr(1).
The format '%{family|escape(\\ )}' expands to family values with space
escaped using backslash.
2009-02-15 13:40:29 -08:00
Behdad Esfahbod b6a23028be [fcformat] Add value-count syntax
The format '%{#family}' expands to the number of values for the element
'family', or '0' if no such element exists in the pattern.
2009-02-15 13:40:29 -08:00
Behdad Esfahbod dccbbe83ef [FcStrBuf] better handle malloc failure
If buffer has failed allocation, return NULL when done.
2009-02-15 13:40:28 -08:00
Behdad Esfahbod ced38254b4 [fcformat] Implement 'cescape', 'shescape', and 'xmlescape' converters 2009-02-15 13:40:28 -08:00
Behdad Esfahbod 2017a5eb79 [fcformat] Add simple converters
The format '%{family|downcase}' for example prints the lowercase of
the family element.  Three converters are defined right now:
'downcase', 'basename', and 'dirname'.
2009-02-15 13:40:27 -08:00
Behdad Esfahbod 7717b25ffd [fcformat] Add conditionals
The conditional '%{?elt1,elt2,!elt3{expr1}{expr2}}' will evaluate
expr1 if elt1 and elt2 exist in pattern and elt3 doesn't exist, and
expr2 otherwise.  The '{expr2}' part is optional.
2009-02-15 13:40:27 -08:00
Behdad Esfahbod 8c31a2434d [fcformat] Add element filtering and deletion
The filtering, '%{+elt1,elt2,elt3{subexpr}}' will evaluate subexpr
with a pattern only having the listed elements from the surrounding
pattern.

The deletion, '%{-elt1,elt2,elt3{subexpr}}' will evaluate subexpr
with a the surrounding pattern sans the listed elements.
2009-02-15 13:40:26 -08:00
Behdad Esfahbod d6506ff6ee [fcformat] Add support for subexpressions
The syntax is '{{expr}}'.  Can be used for aligning/justifying an entire
subexpr for example.
2009-02-15 13:40:26 -08:00
Behdad Esfahbod 27b3e2dddf [fcformat] Refactor and restructure code for upcoming changes
Also makes it thread-safe.
2009-02-15 13:40:26 -08:00
Behdad Esfahbod c493c3b770 [fcformat] Add support for width modifiers
One can do '%30{family}' for example.  Or '%-30{family}' for the
left-aligned version.
2009-02-15 13:40:25 -08:00
Behdad Esfahbod b697fa2523 [cache] After writing cache to file, update the internal copy to reflect this
Only do it for small caches though.  For large cache we'd better off loading
the cache file again, mmap()ing it.

Based on patch from Diego Santa Cruz.
2009-02-15 13:40:25 -08:00
Behdad Esfahbod 6bb5d72fe7 [fccache] Make sure the cache is current when reusing from open caches
Reported by Diego Santa Cruz.
2009-02-15 13:40:25 -08:00
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