Commit 82f4243f authored by Keith Packard's avatar Keith Packard

Switch to RFC 3066 based lang names

parent 899e3526
/*
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.18 2002/06/19 20:08:22 keithp Exp $
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.19 2002/06/30 23:45:17 keithp Exp $
*
* Copyright 2001 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -613,6 +613,9 @@ FcPatternHash (const FcPattern *p);
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
FcBool
FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append);
FcResult
FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
......
......@@ -29,12 +29,12 @@ EXPATLIB=-lexpat
REQUIREDLIBS=$(LDPRELIBS) $(FREETYPE2LIB) $(EXPATLIB)
SRCS=fcatomic.c fcblanks.c fccache.c fccfg.c fccharset.c fcdbg.c \
fcdefault.c fcdir.c fcfreetype.c fcfs.c fcinit.c fclist.c fcmatch.c \
fcmatrix.c fcname.c fcpat.c fcstr.c fcxml.c
fcdefault.c fcdir.c fcfreetype.c fcfs.c fcinit.c fclang.c fclist.c \
fcmatch.c fcmatrix.c fcname.c fcpat.c fcstr.c fcxml.c
OBJS=fcatomic.o fcblanks.o fccache.o fccfg.o fccharset.o fcdbg.o \
fcdefault.o fcdir.o fcfreetype.o fcfs.o fcinit.o fclist.o fcmatch.o \
fcmatrix.o fcname.o fcpat.o fcstr.o fcxml.o
fcdefault.o fcdir.o fcfreetype.o fcfs.o fcinit.o fclang.o fclist.o \
fcmatch.o fcmatrix.o fcname.o fcpat.o fcstr.o fcxml.o
#include <Library.tmpl>
......
/*
* $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.13 2002/06/26 22:56:51 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.14 2002/06/29 20:31:02 keithp Exp $
*
* Copyright 2001 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -111,7 +111,7 @@ FcCharSetFindLeafPos (const FcCharSet *fcs, FcChar32 ucs4)
else
high = mid - 1;
}
if (numbers[high] < ucs4)
if (high < 0 || numbers[high] < ucs4)
high++;
return -(high + 1);
}
......@@ -711,7 +711,7 @@ FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result)
* it's not exactly human readable output. As a special case, 0 is encoded as a space
*/
static unsigned char charToValue[256] = {
static const unsigned char charToValue[256] = {
/* "" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
/* "\b" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
/* "\020" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
......@@ -746,7 +746,7 @@ static unsigned char charToValue[256] = {
/* "\370" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
static FcChar8 valueToChar[0x55] = {
static const FcChar8 valueToChar[0x55] = {
/* 0x00 */ '!', '#', '$', '%', '&', '(', ')', '*',
/* 0x08 */ '+', '.', '/', '0', '1', '2', '3', '4',
/* 0x10 */ '5', '6', '7', '8', '9', ';', '<', '>',
......
This diff is collapsed.
......@@ -163,6 +163,10 @@ typedef struct _FcCharLeaf {
FcChar32 map[256/32];
} FcCharLeaf;
typedef enum _FcLangResult {
FcLangEqual, FcLangDifferentCountry, FcLangDifferentLang
} FcLangResult;
struct _FcCharSet {
int ref; /* reference count */
FcBool constant; /* in hash table constant */
......@@ -393,6 +397,10 @@ FcDebug (void);
int
FcFontDebug (void);
/* fcfreetype.c */
FcBool
FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
/* fcfs.c */
/* fcgram.y */
int
......@@ -460,6 +468,16 @@ FcMemAlloc (int kind, int size);
void
FcMemFree (int kind, int size);
/* fclang.c */
FcBool
FcFreeTypeSetLang (FcPattern *pattern, FcCharSet *charset);
FcLangResult
FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
const FcCharSet *
FcCharSetForLang (const FcChar8 *lang);
/* fclist.c */
/* fcmatch.c */
......@@ -479,6 +497,13 @@ FcPatternFindElt (const FcPattern *p, const char *object);
FcPatternElt *
FcPatternInsertElt (FcPattern *p, const char *object);
FcBool
FcPatternAddWithBinding (FcPattern *p,
const char *object,
FcValue value,
FcValueBinding binding,
FcBool append);
/* fcrender.c */
/* fcmatrix.c */
......@@ -510,4 +535,7 @@ FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
FcBool
FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
int
FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
#endif /* _FC_INT_H_ */
/*
* $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.14 2002/06/19 21:32:18 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.15 2002/06/29 20:31:02 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -48,6 +48,33 @@ FcCompareString (char *object, FcValue value1, FcValue value2)
return (double) FcStrCmpIgnoreCase (value1.u.s, value2.u.s) != 0;
}
static double
FcCompareFamily (char *object, FcValue value1, FcValue value2)
{
if (value2.type != FcTypeString || value1.type != FcTypeString)
return -1.0;
return (double) FcStrCmpIgnoreBlanksAndCase (value1.u.s, value2.u.s) != 0;
}
static double
FcCompareLang (char *object, FcValue value1, FcValue value2)
{
FcLangResult result;
if (value2.type != FcTypeString || value1.type != FcTypeString)
return -1.0;
result = FcLangCompare (value1.u.s, value2.u.s);
switch (result) {
case FcLangEqual:
return 0;
case FcLangDifferentCountry:
return 1;
case FcLangDifferentLang:
default:
return 2;
}
}
static double
FcCompareBool (char *object, FcValue value1, FcValue value2)
{
......@@ -115,10 +142,10 @@ static FcMatcher _FcMatchers [] = {
{ FC_CHARSET, FcCompareCharSet, 1, 1 },
#define MATCH_CHARSET 1
{ FC_FAMILY, FcCompareString, 2, 4 },
{ FC_FAMILY, FcCompareFamily, 2, 4 },
#define MATCH_FAMILY 2
{ FC_LANG, FcCompareString, 3, 3 },
{ FC_LANG, FcCompareLang, 3, 3 },
#define MATCH_LANG 3
{ FC_SPACING, FcCompareInteger, 5, 5 },
......@@ -545,6 +572,11 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool tri
ncs = FcCharSetCopy (ncs);
*cs = ncs;
FcPatternReference (node->pattern);
if (FcDebug () & FC_DBG_MATCH)
{
printf ("Add ");
FcPatternPrint (node->pattern);
}
if (!FcFontSetAdd (fs, node->pattern))
{
FcPatternDestroy (node->pattern);
......@@ -582,6 +614,11 @@ FcFontSetSort (FcConfig *config,
int f;
int i;
if (FcDebug () & FC_DBG_MATCH)
{
printf ("Sort ");
FcPatternPrint (p);
}
nnodes = 0;
for (set = 0; set < nsets; set++)
{
......
/*
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.9 2002/06/19 20:08:22 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.10 2002/06/29 20:31:02 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -392,7 +392,11 @@ FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSe
}
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
FcPatternAddWithBinding (FcPattern *p,
const char *object,
FcValue value,
FcValueBinding binding,
FcBool append)
{
FcPatternElt *e;
FcValueList *new, **prev;
......@@ -408,7 +412,7 @@ FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
goto bail1;
new->value = value;
new->binding = FcValueBindingStrong;
new->binding = binding;
new->next = 0;
e = FcPatternInsertElt (p, object);
......@@ -449,6 +453,18 @@ bail0:
return FcFalse;
}
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
{
return FcPatternAddWithBinding (p, object, value, FcValueBindingStrong, append);
}
FcBool
FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append)
{
return FcPatternAddWithBinding (p, object, value, FcValueBindingWeak, append);
}
FcBool
FcPatternDel (FcPattern *p, const char *object)
{
......
/*
* $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.4 2002/05/21 17:06:22 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.5 2002/05/29 22:07:33 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -82,6 +82,29 @@ FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2)
return (int) c1 - (int) c2;
}
int
FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2)
{
FcChar8 c1, c2;
for (;;)
{
do
c1 = *s1++;
while (c1 == ' ');
do
c2 = *s2++;
while (c2 == ' ');
if (!c1 || !c2)
break;
c1 = FcToLower (c1);
c2 = FcToLower (c2);
if (c1 != c2)
break;
}
return (int) c1 - (int) c2;
}
int
FcStrCmp (const FcChar8 *s1, const FcChar8 *s2)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment