Commit Graph

59 Commits

Author SHA1 Message Date
Josselin Mouette e831f12a38 Treat C.UTF-8 and C.utf8 locales as built in the C library.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717423
https://bugs.freedesktop.org/show_bug.cgi?id=101605
2017-06-27 21:21:18 +09:00
Florent Rougon b0a5b4b48e FcLangSetCompare(): fix bug when two charsets come from different "buckets"
In fcLangCountrySets, it may happen that two charsets for the same
language but different territories are found in different FcChar32
"buckets" (different "columns" on the same line). This is currently the
case for the following pairs:

  mn-cn  and mn-mn
  pap-an and pap-aw

The FcLangSetCompare() code so far used to return FcLangDifferentLang
instead of FcLangDifferentTerritory when comparing:

  an FcLangSet containing only mn-cn with one containing only mn-mn

or

  an FcLangSet containing only pap-an with one containing only pap-aw

This commit fixes this problem.
2017-06-12 13:36:22 +09:00
Florent Rougon 209619b1a6 Fix erroneous test on language id in FcLangSetPromote()
FcLangSetIndex() indicates "not found" with a non-negative return value.
Return value 0 doesn't imply "not found", it rather means "language
found at index 0 in fcLangCharSets".
2017-06-09 15:52:23 +09:00
Florent Rougon 4970c7e810 Fix an off-by-one error in FcLangSetIndex()
This commit fixes a bug that can be reproduced like this:
  - remove all languages starting with 'a' in fc-lang/Makefile.am (in
    ORTH's definition);
  - rebuild fontconfig with this change (-> new fc-lang/fclang.h);
  - create an FcLangSet 'ls1' that contains at least the first language
    from fcLangCharSets (i.e., the first *remaining* in lexicographic
    order); let's assume it is "ba" for the sake of this description;
  - create an FcLangSet 'ls2' that only contains the language "aa" (any
    language starting with 'a' should work as well);
  - check the return value of FcLangSetContains(ls1, ls2);

The expected return value is FcFalse, however it is FcTrue if you use
the code before this commit.

What happens is that FcLangSetIndex() returns 0, because this is the
index of the first slot after the not-found language "aa" in
fcLangCharSets (since we removed all languages starting with 'a').
However, this index happens to be non-negative, therefore
FcLangSetContainsLang() mistakenly infers that the language "aa" was
found in fcLangCharSets, and thus calls FcLangSetBitGet(ls1, 0), which
returns FcTrue since we've put the first remaining language "ba" in the
'ls1' language set.

The "return -low;" statement previously in FcLangSetIndex() was
inconsistent with the final return statement. "return -(low+1);" fixes
this inconsistency as well as the incorrect behavior described above.
2017-06-09 14:35:43 +09:00
Akira TAGOH 48c8b7938a Allow the modification on FcTypeVoid with FcTypeLangSet and FcTypeCharSet
FcTypeVoid is likely to happen when 'lang' and 'charset'
is deleted by 'delete' or 'delete_all' mode in edit.
Without this change, any modification on them are simply
ignored.

This is useful to make a lot of changes, particularly
when one wants to add a few and delete a lot say.
2014-05-13 21:22:17 +09:00
Akira TAGOH 569657a24c Fix a memory leak 2013-03-05 12:46:01 +09:00
Behdad Esfahbod 64af9e1917 Make refcounts, patterns, charsets, strings, and FcLang thread-safe 2013-01-02 00:51:00 -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 dd69d96e06 Fix sign-compare warnings 2012-12-29 22:47:49 -05: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 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 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
Behdad Esfahbod 0d47cfabd8 Bug 28958 - lang=en matches other langs
Patch from Akira TAGOH.
2010-12-07 18:48:56 -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 594dcef0f3 Remove all training whitespaces 2010-04-12 12:19:05 -04: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 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 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 7c12181f7a Improve charset printing 2009-07-28 14:23:10 -04:00
Behdad Esfahbod 5c6d1ff23b Fix FcNameUnparseLangSet()
Was broken since ffd6668b46
2009-07-22 19:25:24 -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 3074a73b41 Replace 'KEITH PACKARD' with 'THE AUTHOR(S)' in license text in all files 2009-03-13 17:59:28 -04:00
Behdad Esfahbod d62b85af21 [fclang] Implement FcLangSetGetLangs() (#18846) 2009-02-15 14:13:34 -08:00
Behdad Esfahbod 317b849215 Replace RCS Id tags with the file name 2009-02-13 16:53:55 -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
Behdad Esfahbod cf223cc7bc Add FcGetLangs() and FcLangGetCharSet(). 2007-11-05 15:29:44 -05:00
Keith Packard c833409f6b Use FcLangDifferentTerritory instead of FcLangDifferentCountry. 2007-11-03 21:58:34 -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
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 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
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 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 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 b36f2a39d0 Fix suspicious return expression which causes junk to be returned.
reviewed by: plam
2006-03-03 06:11:31 +00:00
Patrick Lam 61571f3f2e Pass around FcCache *s to the Unserialize functions for extra consistency
(and less overhead, for what that's worth).
2005-11-25 15:50:34 +00:00
Patrick Lam 7fd7221e68 Add *NeededBytesAlign(), which overestimates the padding which is later
added by the new ALIGN macro. Fix alignment problems on ia64 and s390
    by bumping up block_ptr appropriately. (Earlier version by Andreas
    Schwab).
Use sysconf to determine proper PAGESIZE value; this appears to be
    POSIX-compliant. (reported by Andreas Schwab)
reviewed by: plam
2005-11-16 15:55:17 +00:00
Patrick Lam 82f35f8bb4 Fix bug 2878 (excessive relocations at startup for charsets, reported by
Ross Burton): fc-lang/fc-lang now creates the static form of the
    langset, not the dynamic form, so that the charsets should now be in
    .rodata.
2005-11-04 19:31:26 +00:00
Patrick Lam 21696e5bf0 Add consts to variables so as to move arrays into .rodata.
reviewed by: plam
2005-10-14 21:02:31 +00:00
Patrick Lam 4262e0b385 Overhaul the serialization system to create one mmapable file per directory
and distribute bytes for each directory from a single malloc for that
    directory. Store pointers as differences between the data pointed to
    and the pointer's address (s_off = s - v). Don't serialize data
    structures that never actually get serialized. Separate strings used
    for keys from strings used for values (in FcPatternElt and FcValue,
    respectively). Bump FC_CACHE_VERSION to 2.
2005-08-24 06:21:30 +00:00
Patrick Lam 212c9f437e #ifdef out old cache stuff, replace with first version of new mmapping
cache. Add *Read and *Write procedures which mmap in and write out the
    fontconfig data structures to disk. Currently, create cache in /tmp,
    with different sections for each architecture (as returned by uname's
    .machine field. Run the fc-cache binary to create a new cache file;
    fontconfig then uses this cache file on subsequent runs, saving lots of
    memory. Also fixes a few bugs and leaks.
2005-07-25 04:10:09 +00:00
Patrick Lam cd2ec1a940 Add functionality to allow fontconfig data structure serialization.
This patch allows the fundamental fontconfig data structures to be
    serialized. I've converted everything from FcPattern down to be able to
    use *Ptr objects, which can be either static or dynamic (using a union
    which either contains a pointer or an index) and replaced storage of
    pointers in the heap with the appropriate *Ptr object. I then changed
    all writes of pointers to the heap with a *CreateDynamic call, which
    creates a dynamic Ptr object pointing to the same object as before.
    This way, the fundamental fontconfig semantics should be unchanged; I
    did not have to change external signatures this way, although I did
    change some internal signatures. When given a *Ptr object, just run *U
    to get back to a normal pointer; it gives the right answer regardless
    of whether we're using static or dynamic storage.
I've also implemented a Fc*Serialize call. Calling FcFontSetSerialize
    converts the dynamic FcFontSets contained in the config object to
    static FcFontSets and also converts its dependencies (e.g. everything
    you'd need to write to disk) to static objects. Note that you have to
    call Fc*PrepareSerialize first; this call will count the number of
    objects that actually needs to be allocated, so that we can avoid
    realloc. The Fc*Serialize calls then check the static pointers for
    nullness, and allocate the buffers if necessary. I've tested the
    execution of fc-list and fc-match after Fc*Serialize and they appear to
    work the same way.
2005-06-28 03:41:02 +00:00
Keith Packard 46b51147d1 Change files from ISO-Latin-1 to UTF-8 2004-12-07 01:14:46 +00:00
Keith Packard 74a623e02e Implement new semantics for Contains and LISTING:
LISTING requires that the font Contain all of the pattern values, where
    Contain is redefined for strings to mean precise matching (so that
    Courier 10 Pitch doesn't list Courier fonts)
"Contains" for lang means both langs have the same language and either the
    same country or one is missing the country
2003-07-20 16:06:18 +00:00
Keith Packard 947afeb566 Optimization in FcLangSetIndex was broken, occasionally returning a pointer
to the wrong location on miss
2003-06-09 17:31:03 +00:00
Colin Walters 12d49d3cf4 Remove some unused variables, and initialize some other ones so gcc doesn't
warn us.
2003-04-17 17:43:04 +00:00
Keith Packard cc9dd09816 switch // comment 2003-03-22 01:55:00 +00:00