/*
- * $RCSId: xc/lib/fontconfig/src/fclist.c,v 1.11tsi Exp $
+ * fontconfig/src/fclist.c
*
* Copyright © 2000 Keith Packard
*
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
int s;
const char **objects;
int high, low, mid, c;
-
+
if (os->nobject == os->sobject)
{
s = os->sobject + 4;
}
if (c < 0)
mid++;
- memmove (os->objects + mid + 1, os->objects + mid,
+ memmove (os->objects + mid + 1, os->objects + mid,
(os->nobject - mid) * sizeof (const char *));
os->objects[mid] = object;
os->nobject++;
* where it requires an exact match)
*/
if (FcConfigCompareValue (&fnt->value,
- FcOpListing,
- &pat->value))
+ FcOpListing,
+ &pat->value))
break;
}
if (fnt == NULL)
static FcChar32
FcListMatrixHash (const FcMatrix *m)
{
- int xx = (int) (m->xx * 100),
- xy = (int) (m->xy * 100),
+ int xx = (int) (m->xx * 100),
+ xy = (int) (m->xy * 100),
yx = (int) (m->yx * 100),
yy = (int) (m->yy * 100);
FcListValueListHash (FcValueListPtr list)
{
FcChar32 h = 0;
-
+
while (list != NULL)
{
h = h ^ FcListValueHash (&list->value);
int entries;
FcListBucket *buckets[FC_LIST_HASH_SIZE];
} FcListHashTable;
-
+
static void
FcListHashTableInit (FcListHashTable *table)
{
if (value.type == FcTypeString)
{
FcLangResult res = FcLangCompare (value.u.s, lang);
- if (res == FcLangEqual || (res == FcLangDifferentCountry && idx < 0))
+ if (res == FcLangEqual)
+ return i;
+
+ if (res == FcLangDifferentCountry && idx < 0)
idx = i;
}
}
for (prev = &table->buckets[hash % FC_LIST_HASH_SIZE];
(bucket = *prev); prev = &(bucket->next))
{
- if (bucket->hash == hash &&
+ if (bucket->hash == hash &&
FcListPatternEqual (bucket->pattern, font, os))
return FcTrue;
}
bucket->pattern = FcPatternCreate ();
if (!bucket->pattern)
goto bail1;
-
+
for (o = 0; o < os->nobject; o++)
{
if (!strcmp (os->objects[o], FC_FAMILY) || !strcmp (os->objects[o], FC_FAMILYLANG))
for (v = FcPatternEltValues(e), idx = 0; v;
v = FcValueListNext(v), ++idx)
{
- if (!FcPatternAdd (bucket->pattern,
- os->objects[o],
+ if (!FcPatternAdd (bucket->pattern,
+ os->objects[o],
FcValueCanonicalize(&v->value), defidx != idx))
goto bail2;
}
++table->entries;
return FcTrue;
-
+
bail2:
FcPatternDestroy (bucket->pattern);
bail1:
FcListHashTable table;
int i;
FcListBucket *bucket;
+ int destroy_os = 0;
if (!config)
{
goto bail0;
}
FcListHashTableInit (&table);
+
+ if (!os)
+ {
+ os = FcObjectGetSet ();
+ destroy_os = 1;
+ }
+
/*
* Walk all available fonts adding those that
* match to the hash table
full++;
}
}
- printf ("used: %d max: %d avg: %g\n", full, max,
+ printf ("used: %d max: %d avg: %g\n", full, max,
(double) ents / FC_LIST_HASH_SIZE);
}
#endif
FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
free (bucket);
}
-
+
return ret;
bail2:
bail1:
FcListHashTableCleanup (&table);
bail0:
+ if (destroy_os)
+ FcObjectSetDestroy (os);
return 0;
}
if (!config)
{
+ if (!FcInitBringUptoDate ())
+ return 0;
+
config = FcConfigGetCurrent ();
if (!config)
return 0;
sets[nsets++] = config->fonts[FcSetApplication];
return FcFontSetList (config, sets, nsets, p, os);
}
+#define __fclist__
+#include "fcaliastail.h"
+#undef __fclist__