INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
LOCAL_LIBRARIES=FontconfigClientLibs
- DEPLIBS=FontconfigDepLibs
+ DEPLIBS=FontconfigClientDepLibs
SRCS=fc-cache.c
OBJS=fc-cache.o
INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
LOCAL_LIBRARIES=FontconfigClientLibs
- DEPLIBS=FontconfigDepLibs
+ DEPLIBS=FontconfigClientDepLibs
SRCS=fc-list.c
OBJS=fc-list.o
#include <fontconfig/fontconfig.h>
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#else
#endif
#endif
-void usage (char *program)
+static void usage (char *program)
{
fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
program);
int
main (int argc, char **argv)
{
- int ret = 0;
- FcFontSet *set;
int verbose = 0;
int i;
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_LANG, 0);
#ifndef _FCFREETYPE_H_
#define _FCFREETYPE_H_
+#include <freetype/freetype.h>
FT_UInt
FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4);
__v__.u.d = va_arg (va, double); \
break; \
case FcTypeString: \
- __v__.u.s = va_arg (va, char *); \
+ __v__.u.s = va_arg (va, FcChar8 *); \
break; \
case FcTypeBool: \
__v__.u.b = va_arg (va, FcBool); \
#include <libxml/parser.h>
xmlDocPtr
-FcConfigLoad (const char *file);
+FcConfigLoad (const FcChar8 *file);
FcBool
FcConfigParse (FcConfig *config,
} FcObjectType;
typedef struct _FcConstant {
- const char *name;
+ const FcChar8 *name;
const char *object;
int value;
} FcConstant;
FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
/* fccfg.c */
-char *
-FcConfigFilename (const char *url);
+FcChar8 *
+FcConfigFilename (const FcChar8 *url);
FcConfig *
FcConfigCreate (void);
FcBool
FcConfigBuildFonts (FcConfig *config);
-char **
+FcChar8 **
FcConfigGetDirs (FcConfig *config);
-char **
+FcChar8 **
FcConfigGetConfigFiles (FcConfig *config);
-char *
+FcChar8 *
FcConfigGetCache (FcConfig *config);
FcBlanks *
FcBool
FcConfigAppFontAddFile (FcConfig *config,
- const char *file);
+ const FcChar8 *file);
FcBool
FcConfigAppFontAddDir (FcConfig *config,
- const char *dir);
+ const FcChar8 *dir);
void
FcConfigAppFontClear (FcConfig *config);
FcChar32
FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
-#ifndef FONTCONFIG_NO_FREETYPE
-#include <freetype/freetype.h>
-FT_UInt
-FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4);
-#endif
-
/* fcdbg.c */
void
FcPatternPrint (FcPattern *p);
/* fcdir.c */
FcBool
-FcDirScan (FcFontSet *set,
- FcFileCache *cache,
- FcBlanks *blanks,
- const char *dir,
- FcBool force);
+FcFileScan (FcFontSet *set,
+ FcFileCache *cache,
+ FcBlanks *blanks,
+ const FcChar8 *file,
+ FcBool force);
FcBool
-FcDirSave (FcFontSet *set, const char *dir);
+FcDirScan (FcFontSet *set,
+ FcFileCache *cache,
+ FcBlanks *blanks,
+ const FcChar8 *dir,
+ FcBool force);
+
+FcBool
+FcDirSave (FcFontSet *set, const FcChar8 *dir);
/* fcfreetype.c */
FcPattern *
-FcFreeTypeQuery (const char *file, int id, FcBlanks *blanks, int *count);
+FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
/* fcfs.c */
FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
const FcConstant *
-FcNameGetConstant (char *string);
+FcNameGetConstant (FcChar8 *string);
FcBool
-FcNameConstant (char *string, int *result);
+FcNameConstant (FcChar8 *string, int *result);
FcPattern *
-FcNameParse (const char *name);
+FcNameParse (const FcChar8 *name);
FcChar8 *
FcNameUnparse (FcPattern *pat);
FcPatternAddDouble (FcPattern *p, const char *object, double d);
FcBool
-FcPatternAddString (FcPattern *p, const char *object, const char *s);
+FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
FcBool
FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
FcResult
-FcPatternGetString (FcPattern *p, const char *object, int n, char **const s);
+FcPatternGetString (FcPattern *p, const char *object, int n, FcChar8 const** s);
FcResult
FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
/* fcstr.c */
-char *
-FcStrCopy (const char *s);
+FcChar8 *
+FcStrCopy (const FcChar8 *s);
#define FcToLower(c) (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
int
-FcStrCmpIgnoreCase (const char *s1, const char *s2);
+FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
int
FcUtf8ToUcs4 (FcChar8 *src_orig,
/* fcxml.c */
FcBool
-FcConfigParseAndLoad (FcConfig *config, const char *file, FcBool complain);
+FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
_FCFUNCPROTOEND
#include "fcint.h"
static unsigned int
-FcFileCacheHash (const char *string)
+FcFileCacheHash (const FcChar8 *string)
{
unsigned int h = 0;
- char c;
+ FcChar8 c;
while ((c = *string++))
h = (h << 1) ^ c;
return h;
}
-char *
+FcChar8 *
FcFileCacheFind (FcFileCache *cache,
- const char *file,
+ const FcChar8 *file,
int id,
int *count)
{
unsigned int hash;
- const char *match;
- FcFileCacheEnt *c, *name;
+ const FcChar8 *match;
+ FcFileCacheEnt *c, *name;
int maxid;
struct stat statb;
maxid = c->id;
if (c->id == id)
{
- if (stat (file, &statb) < 0)
+ if (stat ((char *) file, &statb) < 0)
{
if (FcDebug () & FC_DBG_CACHE)
printf (" file missing\n");
* "file_name" id time "font_name" \n
*/
-static FcBool
-FcFileCacheReadString (FILE *f, char *dest, int len)
+static FcChar8 *
+FcFileCacheReadString (FILE *f, FcChar8 *dest, int len)
{
- int c;
- FcBool escape;
+ int c;
+ FcBool escape;
+ FcChar8 *d;
+ int size;
+ int i;
while ((c = getc (f)) != EOF)
if (c == '"')
if (len == 0)
return FcFalse;
+ size = len;
+ i = 0;
+ d = dest;
escape = FcFalse;
while ((c = getc (f)) != EOF)
{
{
switch (c) {
case '"':
- *dest++ = '\0';
- return FcTrue;
+ c = '\0';
+ break;
case '\\':
escape = FcTrue;
continue;
}
}
- if (--len <= 1)
- return FcFalse;
- *dest++ = c;
+ if (i == size)
+ {
+ FcChar8 *new = malloc (size * 2);
+ if (!new)
+ break;
+ memcpy (new, d, size);
+ size *= 2;
+ if (d != dest)
+ free (d);
+ d = new;
+ }
+ d[i++] = c;
+ if (c == '\0')
+ return d;
escape = FcFalse;
}
- return FcFalse;
+ if (d != dest)
+ free (d);
+ return 0;
}
static FcBool
static FcBool
FcFileCacheAdd (FcFileCache *cache,
- const char *file,
+ const FcChar8 *file,
int id,
time_t time,
- const char *name,
+ const FcChar8 *name,
FcBool replace)
{
FcFileCacheEnt *c;
}
c = malloc (sizeof (FcFileCacheEnt) +
- strlen (file) + 1 +
- strlen (name) + 1);
+ strlen ((char *) file) + 1 +
+ strlen ((char *) name) + 1);
if (!c)
return FcFalse;
c->next = *prev;
*prev = c;
c->hash = hash;
- c->file = (char *) (c + 1);
+ c->file = (FcChar8 *) (c + 1);
c->id = id;
- c->name = c->file + strlen (file) + 1;
+ c->name = c->file + strlen ((char *) file) + 1;
strcpy (c->file, file);
c->time = time;
c->referenced = replace;
void
FcFileCacheLoad (FcFileCache *cache,
- const char *cache_file)
+ const FcChar8 *cache_file)
{
FILE *f;
- char file[8192];
+ FcChar8 file_buf[8192], *file;
int id;
time_t time;
- char name[8192];
+ FcChar8 name_buf[8192], *name;
- f = fopen (cache_file, "r");
+ f = fopen ((char *) cache_file, "r");
if (!f)
return;
cache->updated = FcFalse;
- while (FcFileCacheReadString (f, file, sizeof (file)) &&
+ file = 0;
+ name = 0;
+ while ((file = FcFileCacheReadString (f, file_buf, sizeof (file_buf))) &&
FcFileCacheReadInt (f, &id) &&
FcFileCacheReadTime (f, &time) &&
- FcFileCacheReadString (f, name, sizeof (name)))
+ (name = FcFileCacheReadString (f, name_buf, sizeof (name_buf))))
{
(void) FcFileCacheAdd (cache, file, id, time, name, FcFalse);
+ if (file != file_buf)
+ free (file);
+ if (name != name_buf)
+ free (name);
+ file = 0;
+ name = 0;
}
+ if (file && file != file_buf)
+ free (file);
+ if (name && name != name_buf)
+ free (name);
fclose (f);
}
FcBool
-FcFileCacheUpdate (FcFileCache *cache,
- const char *file,
- int id,
- const char *name)
+FcFileCacheUpdate (FcFileCache *cache,
+ const FcChar8 *file,
+ int id,
+ const FcChar8 *name)
{
- const char *match;
+ const FcChar8 *match;
struct stat statb;
FcBool ret;
match = file;
- if (stat (file, &statb) < 0)
+ if (stat ((char *) file, &statb) < 0)
return FcFalse;
ret = FcFileCacheAdd (cache, match, id,
statb.st_mtime, name, FcTrue);
}
static FcBool
-FcFileCacheWriteString (FILE *f, char *string)
+FcFileCacheWriteString (FILE *f, const FcChar8 *string)
{
char c;
FcBool
FcFileCacheSave (FcFileCache *cache,
- const char *cache_file)
+ const FcChar8 *cache_file)
{
- char *lck;
- char *tmp;
+ FcChar8 *lck;
+ FcChar8 *tmp;
FILE *f;
int h;
FcFileCacheEnt *c;
if (!cache->updated && cache->referenced == cache->entries)
return FcTrue;
- lck = malloc (strlen (cache_file)*2 + 4);
+ lck = malloc (strlen ((char *) cache_file)*2 + 4);
if (!lck)
goto bail0;
- tmp = lck + strlen (cache_file) + 2;
- strcpy (lck, cache_file);
- strcat (lck, "L");
- strcpy (tmp, cache_file);
- strcat (tmp, "T");
- if (link (lck, cache_file) < 0 && errno != ENOENT)
+ tmp = lck + strlen ((char *) cache_file) + 2;
+ strcpy ((char *) lck, (char *) cache_file);
+ strcat ((char *) lck, "L");
+ strcpy ((char *) tmp, (char *) cache_file);
+ strcat ((char *) tmp, "T");
+ if (link ((char *) lck, (char *) cache_file) < 0 && errno != ENOENT)
goto bail1;
- if (access (tmp, F_OK) == 0)
+ if (access ((char *) tmp, F_OK) == 0)
goto bail2;
- f = fopen (tmp, "w");
+ f = fopen ((char *) tmp, "w");
if (!f)
goto bail2;
if (fclose (f) == EOF)
goto bail3;
- if (rename (tmp, cache_file) < 0)
+ if (rename ((char *) tmp, (char *) cache_file) < 0)
goto bail3;
- unlink (lck);
+ unlink ((char *) lck);
cache->updated = FcFalse;
return FcTrue;
bail4:
fclose (f);
bail3:
- unlink (tmp);
+ unlink ((char *) tmp);
bail2:
- unlink (lck);
+ unlink ((char *) lck);
bail1:
free (lck);
bail0:
}
FcBool
-FcFileCacheReadDir (FcFontSet *set, const char *cache_file)
+FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file)
{
FcPattern *font;
FILE *f;
- char *path;
- char *base;
- char file[8192];
+ FcChar8 *path;
+ FcChar8 *base;
+ FcChar8 file_buf[8192], *file;
int id;
- char name[8192];
+ FcChar8 name_buf[8192], *name;
FcBool ret = FcFalse;
if (FcDebug () & FC_DBG_CACHE)
printf ("FcFileCacheReadDir cache_file \"%s\"\n", cache_file);
}
- f = fopen (cache_file, "r");
+ f = fopen ((char *) cache_file, "r");
if (!f)
{
if (FcDebug () & FC_DBG_CACHE)
goto bail0;
}
- base = strrchr (cache_file, '/');
+ base = (FcChar8 *) strrchr ((char *) cache_file, '/');
if (!base)
goto bail1;
base++;
memcpy (path, cache_file, base - cache_file);
base = path + (base - cache_file);
- while (FcFileCacheReadString (f, file, sizeof (file)) &&
+ file = 0;
+ name = 0;
+ while ((file = FcFileCacheReadString (f, file_buf, sizeof (file_buf))) &&
FcFileCacheReadInt (f, &id) &&
- FcFileCacheReadString (f, name, sizeof (name)))
+ (name = FcFileCacheReadString (f, name_buf, sizeof (name_buf))))
{
font = FcNameParse (name);
if (font)
if (!FcFontSetAdd (set, font))
goto bail2;
}
+ if (file != file_buf)
+ free (file);
+ if (name != name_buf)
+ free (name);
+ file = name = 0;
}
if (FcDebug () & FC_DBG_CACHE)
{
ret = FcTrue;
bail2:
free (path);
+ if (file && file != file_buf)
+ free (file);
+ if (name && name != name_buf)
+ free (name);
bail1:
fclose (f);
bail0:
}
FcBool
-FcFileCacheWriteDir (FcFontSet *set, const char *cache_file)
+FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file)
{
FcPattern *font;
FILE *f;
- char *name;
- char *file, *base;
+ FcChar8 *name;
+ const FcChar8 *file, *base;
int n;
int id;
FcBool ret;
if (FcDebug () & FC_DBG_CACHE)
printf ("FcFileCacheWriteDir cache_file \"%s\"\n", cache_file);
- f = fopen (cache_file, "w");
+ f = fopen ((char *) cache_file, "w");
if (!f)
{
if (FcDebug () & FC_DBG_CACHE)
font = set->fonts[n];
if (FcPatternGetString (font, FC_FILE, 0, &file) != FcResultMatch)
goto bail1;
- base = strrchr (file, '/');
+ base = (FcChar8 *) strrchr ((char *) file, '/');
if (base)
base = base + 1;
else
bail1:
fclose (f);
bail0:
- unlink (cache_file);
+ unlink ((char *) cache_file);
return FcFalse;
}
config->configFiles[0] = 0;
config->cache = 0;
- if (!FcConfigSetCache (config, "~/" FC_USER_CACHE_FILE))
+ if (!FcConfigSetCache (config, (FcChar8 *) ("~/" FC_USER_CACHE_FILE)))
goto bail3;
config->blanks = 0;
}
static void
-FcConfigDestroyStrings (char **strings)
+FcConfigDestroyStrings (FcChar8 **strings)
{
- char **s;
+ FcChar8 **s;
for (s = strings; s && *s; s++)
free (*s);
}
static FcBool
-FcConfigAddString (char ***strings, char *string)
+FcConfigAddString (FcChar8 ***strings, FcChar8 *string)
{
int n;
- char **s;
+ FcChar8 **s;
n = 0;
for (s = *strings; s && *s; s++)
n++;
- s = malloc ((n + 2) * sizeof (char *));
+ s = malloc ((n + 2) * sizeof (FcChar8 *));
if (!s)
return FcFalse;
s[n] = string;
s[n+1] = 0;
- memcpy (s, *strings, n * sizeof (char *));
+ memcpy (s, *strings, n * sizeof (FcChar8 *));
free (*strings);
*strings = s;
return FcTrue;
{
FcFontSet *fonts;
FcFileCache *cache;
- char **d;
+ FcChar8 **d;
fonts = FcFontSetCreate ();
if (!fonts)
FcBool
FcConfigAddDir (FcConfig *config,
- const char *d)
+ const FcChar8 *d)
{
- char *dir;
- char *h;
+ FcChar8 *dir;
+ FcChar8 *h;
if (*d == '~')
{
- h = getenv ("HOME");
+ h = (FcChar8 *) getenv ("HOME");
if (!h)
return FcFalse;
- dir = (char *) malloc (strlen (h) + strlen (d));
+ dir = (FcChar8 *) malloc (strlen ((char *) h) + strlen ((char *) d));
if (!dir)
return FcFalse;
- strcpy (dir, h);
- strcat (dir, d+1);
+ strcpy ((char *) dir, (char *) h);
+ strcat ((char *) dir, (char *) d+1);
}
else
{
- dir = (char *) malloc (strlen (d) + 1);
+ dir = (FcChar8 *) malloc (strlen ((char *) d) + 1);
if (!dir)
return FcFalse;
strcpy (dir, d);
return FcTrue;
}
-char **
+FcChar8 **
FcConfigGetDirs (FcConfig *config)
{
if (!config)
FcBool
FcConfigAddConfigFile (FcConfig *config,
- const char *f)
+ const FcChar8 *f)
{
- char *file;
+ FcChar8 *file;
file = FcConfigFilename (f);
if (!file)
return FcFalse;
return FcTrue;
}
-char **
+FcChar8 **
FcConfigGetConfigFiles (FcConfig *config)
{
if (!config)
FcBool
FcConfigSetCache (FcConfig *config,
- const char *c)
+ const FcChar8 *c)
{
- char *new;
- char *h;
+ FcChar8 *new;
+ FcChar8 *h;
if (*c == '~')
{
- h = getenv ("HOME");
+ h = (FcChar8 *) getenv ("HOME");
if (!h)
return FcFalse;
- new = (char *) malloc (strlen (h) + strlen (c));
+ new = (FcChar8 *) malloc (strlen ((char *) h) + strlen ((char *) c));
if (!new)
return FcFalse;
- strcpy (new, h);
- strcat (new, c+1);
+ strcpy ((char *) new, (char *) h);
+ strcat ((char *) new, (char *) c+1);
}
else
{
return FcTrue;
}
-char *
+FcChar8 *
FcConfigGetCache (FcConfig *config)
{
if (!config)
FcValue v, vl, vr;
FcResult r;
FcMatrix *m;
- FcChar8 *s;
switch (e->op) {
case FcOpInteger:
* Locate any test associated with this field
*/
for (t = s->test, i = 0; t; t = t->next, i++)
- if (!FcStrCmpIgnoreCase (t->field, e->field))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) t->field, (FcChar8 *) e->field))
break;
switch (e->op) {
case FcOpAssign:
* Append the new list of values after the current value
*/
FcConfigAdd (&st[i].elt->values, thisValue, FcTrue, l);
+ /*
+ * Delete the marked value
+ */
+ FcConfigDel (&st[i].elt->values, thisValue);
/*
* Adjust any pointers into the value list to ensure
* future edits occur at the same place
if (st[i].value == thisValue)
st[i].value = nextValue;
}
- /*
- * Delete the marked value
- */
- FcConfigDel (&st[i].elt->values, thisValue);
break;
}
/* fall through ... */
#define FONTCONFIG_FILE "fonts.conf"
#endif
-static char *
-FcConfigFileExists (const char *dir, const char *file)
+static FcChar8 *
+FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
{
- char *path;
+ FcChar8 *path;
if (!dir)
- dir = "";
- path = malloc (strlen (dir) + 1 + strlen (file) + 1);
+ dir = (FcChar8 *) "";
+ path = malloc (strlen ((char *) dir) + 1 + strlen ((char *) file) + 1);
if (!path)
return 0;
strcpy (path, dir);
/* make sure there's a single separating / */
- if ((!path[0] || path[strlen(path)-1] != '/') && file[0] != '/')
- strcat (path, "/");
- strcat (path, file);
+ if ((!path[0] || path[strlen((char *) path)-1] != '/') && file[0] != '/')
+ strcat ((char *) path, "/");
+ strcat ((char *) path, (char *) file);
- if (access (path, R_OK) == 0)
+ if (access ((char *) path, R_OK) == 0)
return path;
free (path);
return 0;
}
-static char **
+static FcChar8 **
FcConfigGetPath (void)
{
- char **path;
- char *env, *e, *colon;
- char *dir;
+ FcChar8 **path;
+ FcChar8 *env, *e, *colon;
+ FcChar8 *dir;
int npath;
int i;
npath = 2; /* default dir + null */
- env = getenv ("FONTCONFIG_PATH");
+ env = (FcChar8 *) getenv ("FONTCONFIG_PATH");
if (env)
{
e = env;
if (*e++ == ':')
npath++;
}
- path = calloc (npath, sizeof (char *));
+ path = calloc (npath, sizeof (FcChar8 *));
if (!path)
goto bail0;
i = 0;
e = env;
while (*e)
{
- colon = strchr (e, ':');
+ colon = (FcChar8 *) strchr ((char *) e, ':');
if (!colon)
- colon = e + strlen (e);
+ colon = e + strlen ((char *) e);
path[i] = malloc (colon - e + 1);
if (!path[i])
goto bail1;
}
}
- dir = FONTCONFIG_PATH;
- path[i] = malloc (strlen (dir) + 1);
+ dir = (FcChar8 *) FONTCONFIG_PATH;
+ path[i] = malloc (strlen ((char *) dir) + 1);
if (!path[i])
goto bail1;
strcpy (path[i], dir);
}
static void
-FcConfigFreePath (char **path)
+FcConfigFreePath (FcChar8 **path)
{
- char **p;
+ FcChar8 **p;
for (p = path; *p; p++)
free (*p);
free (path);
}
-char *
-FcConfigFilename (const char *url)
+FcChar8 *
+FcConfigFilename (const FcChar8 *url)
{
- char *file, *dir, **path, **p;
+ FcChar8 *file, *dir, **path, **p;
if (!url || !*url)
{
- url = getenv ("FONTCONFIG_FILE");
+ url = (FcChar8 *) getenv ("FONTCONFIG_FILE");
if (!url)
- url = FONTCONFIG_FILE;
+ url = (FcChar8 *) FONTCONFIG_FILE;
}
+ file = 0;
switch (*url) {
case '~':
- dir = getenv ("HOME");
+ dir = (FcChar8 *) getenv ("HOME");
if (dir)
file = FcConfigFileExists (dir, url + 1);
else
FcBool
FcConfigAppFontAddFile (FcConfig *config,
- const char *file)
+ const FcChar8 *file)
{
FcFontSet *set;
FcBool
FcConfigAppFontAddDir (FcConfig *config,
- const char *dir)
+ const FcChar8 *dir)
{
FcFontSet *set;
int l;
const FcCharNode *prev;
FcCharNode node;
- FcChar8 i;
+ FcChar32 i;
prev = &fcs->node;
l = fcs->levels;
static FcCharLeaf *
FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4)
{
- int l;
- FcCharNode *prev, node;
- FcChar8 i;
+ int l;
+ FcCharNode *prev, node;
+ FcChar32 i;
if (!FcCharSetCheckLevel (fcs, ucs4))
return FcFalse;
int shift = ((level - 1) << 3);
FcChar32 inc = 1 << shift;
FcChar32 mask = ~(inc - 1);
- FcChar8 byte = (*ucs4 >> shift) & 0xff;
+ FcChar32 byte = (*ucs4 >> shift) & 0xff;
FcCharLeaf *leaf;
for (;;)
break;
/* step to next branch, resetting lower indices */
*ucs4 = (*ucs4 & mask) + inc;
- byte++;
+ byte = (byte + 1) & 0xff;
if (byte == 0)
break;
}
* it's not exactly human readable output. As a special case, 0 is encoded as a space
*/
-static FcChar8 charToValue[256] = {
+static 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,
{
int i;
FcChar32 v;
- FcChar8 c;
+ FcChar32 c;
if (*string == ' ')
{
v = 0;
for (i = 0; i < 5; i++)
{
- if (!(c = *string++))
+ if (!(c = (FcChar32) (unsigned char) *string++))
return 0;
c = charToValue[c];
if (c == 0xff)
#endif
typedef struct _FcCharEnt {
- FcChar16 bmp;
- FcChar8 encode;
+ FcChar16 bmp;
+ unsigned char encode;
} FcCharEnt;
typedef struct _FcCharMap {
return FcTrue;
/* fall through ... */
default:
+ break;
}
return FcFalse;
}
#define FC_INVALID_FONT_FILE "."
FcBool
-FcFileScan (FcFontSet *set,
- FcFileCache *cache,
- FcBlanks *blanks,
- const char *file,
- FcBool force)
+FcFileScan (FcFontSet *set,
+ FcFileCache *cache,
+ FcBlanks *blanks,
+ const FcChar8 *file,
+ FcBool force)
{
int id;
- char *name;
+ FcChar8 *name;
FcPattern *font;
FcBool ret = FcTrue;
int count;
else
{
/* negative cache files not containing fonts */
- FcFileCacheUpdate (cache, file, id, FC_INVALID_FONT_FILE);
+ FcFileCacheUpdate (cache, file, id, (FcChar8 *) FC_INVALID_FONT_FILE);
}
}
}
}
FcBool
-FcDirScan (FcFontSet *set,
- FcFileCache *cache,
- FcBlanks *blanks,
- const char *dir,
- FcBool force)
+FcDirScan (FcFontSet *set,
+ FcFileCache *cache,
+ FcBlanks *blanks,
+ const FcChar8 *dir,
+ FcBool force)
{
DIR *d;
struct dirent *e;
- char *file;
- char *base;
+ FcChar8 *file;
+ FcChar8 *base;
FcBool ret = FcTrue;
- file = (char *) malloc (strlen (dir) + 1 + 256 + 1);
+ file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + 256 + 1);
if (!file)
return FcFalse;
- strcpy (file, dir);
- strcat (file, "/");
- base = file + strlen (file);
+ strcpy ((char *) file, (char *) dir);
+ strcat ((char *) file, "/");
+ base = file + strlen ((char *) file);
if (!force)
{
- strcpy (base, FC_DIR_CACHE_FILE);
+ strcpy ((char *) base, FC_DIR_CACHE_FILE);
if (FcFileCacheReadDir (set, file))
{
}
}
- d = opendir (dir);
+ d = opendir ((char *) dir);
if (!d)
{
free (file);
{
if (e->d_name[0] != '.')
{
- strcpy (base, e->d_name);
+ strcpy ((char *) base, (char *) e->d_name);
FcFileScan (set, cache, blanks, file, force);
}
}
}
FcBool
-FcDirSave (FcFontSet *set, const char *dir)
+FcDirSave (FcFontSet *set, const FcChar8 *dir)
{
- char *file;
- char *base;
+ FcChar8 *file;
+ FcChar8 *base;
FcBool ret;
- file = (char *) malloc (strlen (dir) + 1 + 256 + 1);
+ file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + 256 + 1);
if (!file)
return FcFalse;
- strcpy (file, dir);
- strcat (file, "/");
- base = file + strlen (file);
- strcpy (base, FC_DIR_CACHE_FILE);
+ strcpy ((char *) file, (char *) dir);
+ strcat ((char *) file, "/");
+ base = file + strlen ((char *) file);
+ strcpy ((char *) base, FC_DIR_CACHE_FILE);
ret = FcFileCacheWriteDir (set, file);
free (file);
return ret;
static const struct {
int bit;
- char *name;
+ FcChar8 *name;
} FcCodePageRange[] = {
- { 0, FC_LANG_LATIN_1 },
- { 1, FC_LANG_LATIN_2_EASTERN_EUROPE },
- { 2, FC_LANG_CYRILLIC },
- { 3, FC_LANG_GREEK },
- { 4, FC_LANG_TURKISH },
- { 5, FC_LANG_HEBREW },
- { 6, FC_LANG_ARABIC },
- { 7, FC_LANG_WINDOWS_BALTIC },
- { 8, FC_LANG_VIETNAMESE },
+ { 0, (FcChar8 *) FC_LANG_LATIN_1 },
+ { 1, (FcChar8 *) FC_LANG_LATIN_2_EASTERN_EUROPE },
+ { 2, (FcChar8 *) FC_LANG_CYRILLIC },
+ { 3, (FcChar8 *) FC_LANG_GREEK },
+ { 4, (FcChar8 *) FC_LANG_TURKISH },
+ { 5, (FcChar8 *) FC_LANG_HEBREW },
+ { 6, (FcChar8 *) FC_LANG_ARABIC },
+ { 7, (FcChar8 *) FC_LANG_WINDOWS_BALTIC },
+ { 8, (FcChar8 *) FC_LANG_VIETNAMESE },
/* 9-15 reserved for Alternate ANSI */
- { 16, FC_LANG_THAI },
- { 17, FC_LANG_JAPANESE },
- { 18, FC_LANG_SIMPLIFIED_CHINESE },
- { 19, FC_LANG_KOREAN_WANSUNG },
- { 20, FC_LANG_TRADITIONAL_CHINESE },
- { 21, FC_LANG_KOREAN_JOHAB },
+ { 16, (FcChar8 *) FC_LANG_THAI },
+ { 17, (FcChar8 *) FC_LANG_JAPANESE },
+ { 18, (FcChar8 *) FC_LANG_SIMPLIFIED_CHINESE },
+ { 19, (FcChar8 *) FC_LANG_KOREAN_WANSUNG },
+ { 20, (FcChar8 *) FC_LANG_TRADITIONAL_CHINESE },
+ { 21, (FcChar8 *) FC_LANG_KOREAN_JOHAB },
/* 22-28 reserved for Alternate ANSI & OEM */
- { 29, FC_LANG_MACINTOSH },
- { 30, FC_LANG_OEM },
- { 31, FC_LANG_SYMBOL },
+ { 29, (FcChar8 *) FC_LANG_MACINTOSH },
+ { 30, (FcChar8 *) FC_LANG_OEM },
+ { 31, (FcChar8 *) FC_LANG_SYMBOL },
/* 32-47 reserved for OEM */
- { 48, FC_LANG_IBM_GREEK },
- { 49, FC_LANG_MSDOS_RUSSIAN },
- { 50, FC_LANG_MSDOS_NORDIC },
- { 51, FC_LANG_ARABIC_864 },
- { 52, FC_LANG_MSDOS_CANADIAN_FRENCH },
- { 53, FC_LANG_HEBREW_862 },
- { 54, FC_LANG_MSDOS_ICELANDIC },
- { 55, FC_LANG_MSDOS_PORTUGUESE },
- { 56, FC_LANG_IBM_TURKISH },
- { 57, FC_LANG_IBM_CYRILLIC },
- { 58, FC_LANG_LATIN_2 },
- { 59, FC_LANG_MSDOS_BALTIC },
- { 60, FC_LANG_GREEK_437_G },
- { 61, FC_LANG_ARABIC_ASMO_708 },
- { 62, FC_LANG_WE_LATIN_1 },
- { 63, FC_LANG_US },
+ { 48, (FcChar8 *) FC_LANG_IBM_GREEK },
+ { 49, (FcChar8 *) FC_LANG_MSDOS_RUSSIAN },
+ { 50, (FcChar8 *) FC_LANG_MSDOS_NORDIC },
+ { 51, (FcChar8 *) FC_LANG_ARABIC_864 },
+ { 52, (FcChar8 *) FC_LANG_MSDOS_CANADIAN_FRENCH },
+ { 53, (FcChar8 *) FC_LANG_HEBREW_862 },
+ { 54, (FcChar8 *) FC_LANG_MSDOS_ICELANDIC },
+ { 55, (FcChar8 *) FC_LANG_MSDOS_PORTUGUESE },
+ { 56, (FcChar8 *) FC_LANG_IBM_TURKISH },
+ { 57, (FcChar8 *) FC_LANG_IBM_CYRILLIC },
+ { 58, (FcChar8 *) FC_LANG_LATIN_2 },
+ { 59, (FcChar8 *) FC_LANG_MSDOS_BALTIC },
+ { 60, (FcChar8 *) FC_LANG_GREEK_437_G },
+ { 61, (FcChar8 *) FC_LANG_ARABIC_ASMO_708 },
+ { 62, (FcChar8 *) FC_LANG_WE_LATIN_1 },
+ { 63, (FcChar8 *) FC_LANG_US },
};
#define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
FcPattern *
-FcFreeTypeQuery (const char *file,
- int id,
- FcBlanks *blanks,
- int *count)
+FcFreeTypeQuery (const FcChar8 *file,
+ int id,
+ FcBlanks *blanks,
+ int *count)
{
- FT_Face face;
- FcPattern *pat;
- int slant;
- int weight;
- int i;
- FcCharSet *cs;
- FT_Library ftLibrary;
- const char *family;
- TT_OS2 *os2;
+ FT_Face face;
+ FcPattern *pat;
+ int slant;
+ int weight;
+ int i;
+ FcCharSet *cs;
+ FT_Library ftLibrary;
+ const FcChar8 *family;
+ TT_OS2 *os2;
if (FT_Init_FreeType (&ftLibrary))
return 0;
- if (FT_New_Face (ftLibrary, file, id, &face))
+ if (FT_New_Face (ftLibrary, (char *) file, id, &face))
goto bail;
*count = face->num_faces;
if (!FcPatternAddInteger (pat, FC_WEIGHT, weight))
goto bail1;
- family = face->family_name;
+ family = (FcChar8 *) face->family_name;
if (!family)
{
- family = strrchr (file, '/');
+ family = (FcChar8 *) strrchr ((char *) file, '/');
if (family)
family++;
else
if (face->style_name)
{
- if (!FcPatternAddString (pat, FC_STYLE, face->style_name))
+ if (!FcPatternAddString (pat, FC_STYLE, (FcChar8 *) face->style_name))
goto bail1;
}
if (!FcPatternAddInteger (pat, FC_INDEX, id))
goto bail1;
- if (!FcPatternAddString (pat, FC_SOURCE, "FreeType"))
+ if (!FcPatternAddString (pat, FC_SOURCE, (FcChar8 *) "FreeType"))
goto bail1;
#if 0
config = FcConfigCreate ();
if (!config)
goto bail0;
- if (!FcConfigAddDir (config, FC_FALLBACK_FONTS))
+ if (!FcConfigAddDir (config, (FcChar8 *) FC_FALLBACK_FONTS))
goto bail1;
FcConfigSetCurrent (config);
return FcTrue;
union {
int ival;
double dval;
- char *sval;
+ FcChar8 *sval;
FcMatrix *mval;
FcBool bval;
FcCharSet *cval;
char *field;
- char *constant;
+ FcChar8 *constant;
struct {
struct _FcExpr *left, *right;
} tree;
typedef struct _FcFileCacheEnt {
struct _FcFileCacheEnt *next;
unsigned int hash;
- char *file;
+ FcChar8 *file;
int id;
time_t time;
- char *name;
+ FcChar8 *name;
FcBool referenced;
} FcFileCacheEnt;
* cache file must be consulted before the directories are scanned,
* and those directives may occur in any order
*/
- char **dirs; /* directories containing fonts */
- char *cache; /* name of per-user cache file */
+ FcChar8 **dirs; /* directories containing fonts */
+ FcChar8 *cache; /* name of per-user cache file */
/*
* Set of allowed blank chars -- used to
* trim fonts of bogus glyphs
* Names of all of the configuration files used
* to create this configuration
*/
- char **configFiles; /* config files loaded */
+ FcChar8 **configFiles; /* config files loaded */
/*
* Substitution instructions for patterns and fonts;
* maxObjects is used to allocate appropriate intermediate storage
FcFileCache *
FcFileCacheCreate (void);
-char *
+FcChar8 *
FcFileCacheFind (FcFileCache *cache,
- const char *file,
+ const FcChar8 *file,
int id,
int *count);
void
FcFileCacheLoad (FcFileCache *cache,
- const char *cache_file);
+ const FcChar8 *cache_file);
FcBool
-FcFileCacheUpdate (FcFileCache *cache,
- const char *file,
- int id,
- const char *name);
+FcFileCacheUpdate (FcFileCache *cache,
+ const FcChar8 *file,
+ int id,
+ const FcChar8 *name);
FcBool
FcFileCacheSave (FcFileCache *cache,
- const char *cache_file);
+ const FcChar8 *cache_file);
FcBool
-FcFileCacheReadDir (FcFontSet *set, const char *cache_file);
+FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file);
FcBool
-FcFileCacheWriteDir (FcFontSet *set, const char *cache_file);
+FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file);
/* fccfg.c */
FcBool
-FcConfigAddDir (FcConfig *config,
- const char *d);
+FcConfigAddDir (FcConfig *config,
+ const FcChar8 *d);
FcBool
-FcConfigAddConfigFile (FcConfig *config,
- const char *f);
+FcConfigAddConfigFile (FcConfig *config,
+ const FcChar8 *f);
FcBool
FcConfigSetCache (FcConfig *config,
- const char *c);
+ const FcChar8 *c);
FcBool
FcConfigAddBlank (FcConfig *config,
FcDebug (void);
/* fcdir.c */
-FcBool
-FcFileScan (FcFontSet *set,
- FcFileCache *cache,
- FcBlanks *blanks,
- const char *file,
- FcBool force);
-
-FcBool
-FcDirScan (FcFontSet *set,
- FcFileCache *cache,
- FcBlanks *blanks,
- const char *dir,
- FcBool force);
-
-FcBool
-FcDirSave (FcFontSet *set, const char *dir);
/* fcfont.c */
int
FcExprCreateDouble (double d);
FcExpr *
-FcExprCreateString (const char *s);
+FcExprCreateString (const FcChar8 *s);
FcExpr *
FcExprCreateMatrix (const FcMatrix *m);
FcExprCreateField (const char *field);
FcExpr *
-FcExprCreateConst (const char *constant);
+FcExprCreateConst (const FcChar8 *constant);
FcExpr *
FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
/* fcmatch.c */
/* fcname.c */
-FcBool
-FcNameConstant (char *string, int *result);
FcBool
-FcNameBool (char *v, FcBool *result);
+FcNameBool (FcChar8 *v, FcBool *result);
FcBool
FcNameBufChar (FcNameBuf *buf, FcChar8 c);
FcMatrixFree (FcMatrix *mat);
/* fcstr.c */
-char *
-FcStrPlus (const char *s1, const char *s2);
+FcChar8 *
+FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
void
-FcStrFree (char *s);
+FcStrFree (FcChar8 *s);
#endif /* _FC_INT_H_ */
for (i = 0; i < NUM_MATCHER; i++)
{
- if (!FcStrCmpIgnoreCase (_FcMatchers[i].object, object))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) _FcMatchers[i].object,
+ (FcChar8 *) object))
break;
}
if (i == NUM_MATCHER)
{
for (i2 = 0; i2 < fnt->num; i2++)
{
- if (!FcStrCmpIgnoreCase (pat->elts[i1].object,
- fnt->elts[i2].object))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) pat->elts[i1].object,
+ (FcChar8 *) fnt->elts[i2].object))
{
if (!FcCompareValueList (pat->elts[i1].object,
pat->elts[i1].values,
for (i = 0; i < l->ntypes; i++)
{
t = &l->types[i];
- if (!FcStrCmpIgnoreCase (object, t->object))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) object, (FcChar8 *) t->object))
return t;
}
}
}
static const FcConstant _FcBaseConstants[] = {
- { "light", "weight", FC_WEIGHT_LIGHT, },
- { "medium", "weight", FC_WEIGHT_MEDIUM, },
- { "demibold", "weight", FC_WEIGHT_DEMIBOLD, },
- { "bold", "weight", FC_WEIGHT_BOLD, },
- { "black", "weight", FC_WEIGHT_BLACK, },
-
- { "roman", "slant", FC_SLANT_ROMAN, },
- { "italic", "slant", FC_SLANT_ITALIC, },
- { "oblique", "slant", FC_SLANT_OBLIQUE, },
-
- { "proportional", "spacing", FC_PROPORTIONAL, },
- { "mono", "spacing", FC_MONO, },
- { "charcell", "spacing", FC_CHARCELL, },
-
- { "rgb", "rgba", FC_RGBA_RGB, },
- { "bgr", "rgba", FC_RGBA_BGR, },
- { "vrgb", "rgba", FC_RGBA_VRGB },
- { "vbgr", "rgba", FC_RGBA_VBGR },
+ { (FcChar8 *) "light", "weight", FC_WEIGHT_LIGHT, },
+ { (FcChar8 *) "medium", "weight", FC_WEIGHT_MEDIUM, },
+ { (FcChar8 *) "demibold", "weight", FC_WEIGHT_DEMIBOLD, },
+ { (FcChar8 *) "bold", "weight", FC_WEIGHT_BOLD, },
+ { (FcChar8 *) "black", "weight", FC_WEIGHT_BLACK, },
+
+ { (FcChar8 *) "roman", "slant", FC_SLANT_ROMAN, },
+ { (FcChar8 *) "italic", "slant", FC_SLANT_ITALIC, },
+ { (FcChar8 *) "oblique", "slant", FC_SLANT_OBLIQUE, },
+
+ { (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
+ { (FcChar8 *) "mono", "spacing", FC_MONO, },
+ { (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
+
+ { (FcChar8 *) "rgb", "rgba", FC_RGBA_RGB, },
+ { (FcChar8 *) "bgr", "rgba", FC_RGBA_BGR, },
+ { (FcChar8 *) "vrgb", "rgba", FC_RGBA_VRGB },
+ { (FcChar8 *) "vbgr", "rgba", FC_RGBA_VBGR },
};
#define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0])
}
const FcConstant *
-FcNameGetConstant (char *string)
+FcNameGetConstant (FcChar8 *string)
{
const FcConstantList *l;
int i;
}
FcBool
-FcNameConstant (char *string, int *result)
+FcNameConstant (FcChar8 *string, int *result)
{
const FcConstant *c;
}
FcBool
-FcNameBool (char *v, FcBool *result)
+FcNameBool (FcChar8 *v, FcBool *result)
{
char c0, c1;
}
static FcValue
-FcNameConvert (FcType type, char *string, FcMatrix *m)
+FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
{
FcValue v;
switch (v.type) {
case FcTypeInteger:
if (!FcNameConstant (string, &v.u.i))
- v.u.i = atoi (string);
+ v.u.i = atoi ((char *) string);
break;
case FcTypeString:
v.u.s = string;
v.u.b = FcFalse;
break;
case FcTypeDouble:
- v.u.d = strtod (string, 0);
+ v.u.d = strtod ((char *) string, 0);
break;
case FcTypeMatrix:
v.u.m = m;
- sscanf (string, "%lg %lg %lg %lg", &m->xx, &m->xy, &m->yx, &m->yy);
+ sscanf ((char *) string, "%lg %lg %lg %lg", &m->xx, &m->xy, &m->yx, &m->yy);
break;
case FcTypeCharSet:
v.u.c = FcNameParseCharSet (string);
return v;
}
-static const char *
-FcNameFindNext (const char *cur, const char *delim, char *save, char *last)
+static const FcChar8 *
+FcNameFindNext (const FcChar8 *cur, const char *delim, FcChar8 *save, FcChar8 *last)
{
- char c;
+ FcChar8 c;
while ((c = *cur))
{
}
FcPattern *
-FcNameParse (const char *name)
+FcNameParse (const FcChar8 *name)
{
- char *save;
+ FcChar8 *save;
FcPattern *pat;
double d;
- char *e;
- char delim;
+ FcChar8 *e;
+ FcChar8 delim;
FcValue v;
FcMatrix m;
const FcObjectType *t;
const FcConstant *c;
- save = malloc (strlen (name) + 1);
+ save = malloc (strlen ((char *) name) + 1);
if (!save)
goto bail0;
pat = FcPatternCreate ();
for (;;)
{
name = FcNameFindNext (name, "-,:", save, &delim);
- d = strtod (save, &e);
+ d = strtod ((char *) save, (char **) &e);
if (e != save)
{
if (!FcPatternAddDouble (pat, FC_SIZE, d))
{
if (delim == '=' || delim == '_')
{
- t = FcNameGetObjectType (save);
+ t = FcNameGetObjectType ((char *) save);
for (;;)
{
name = FcNameFindNext (name, ":,", save, &delim);
case FcTypeString:
return FcNameUnparseString (buf, v.u.s, escape);
case FcTypeBool:
- return FcNameUnparseString (buf, v.u.b ? "True" : "False", 0);
+ return FcNameUnparseString (buf, v.u.b ? (FcChar8 *) "True" : (FcChar8 *) "False", 0);
case FcTypeMatrix:
sprintf ((char *) temp, "%g %g %g %g",
v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
static FcBool
FcNameUnparseValueList (FcNameBuf *buf,
FcValueList *v,
- char *escape)
+ FcChar8 *escape)
{
while (v)
{
if (!FcNameUnparseValue (buf, v->value, escape))
return FcFalse;
if ((v = v->next))
- if (!FcNameUnparseString (buf, ",", 0))
+ if (!FcNameUnparseString (buf, (FcChar8 *) ",", 0))
return FcFalse;
}
return FcTrue;
e = FcPatternFind (pat, FC_FAMILY, FcFalse);
if (e)
{
- if (!FcNameUnparseValueList (&buf, e->values, FC_ESCAPE_FIXED))
+ if (!FcNameUnparseValueList (&buf, e->values, (FcChar8 *) FC_ESCAPE_FIXED))
goto bail0;
}
e = FcPatternFind (pat, FC_SIZE, FcFalse);
if (e)
{
- if (!FcNameUnparseString (&buf, "-", 0))
+ if (!FcNameUnparseString (&buf, (FcChar8 *) "-", 0))
goto bail0;
- if (!FcNameUnparseValueList (&buf, e->values, FC_ESCAPE_FIXED))
+ if (!FcNameUnparseValueList (&buf, e->values, (FcChar8 *) FC_ESCAPE_FIXED))
goto bail0;
}
for (l = _FcObjectTypes; l; l = l->next)
e = FcPatternFind (pat, o->object, FcFalse);
if (e)
{
- if (!FcNameUnparseString (&buf, ":", 0))
+ if (!FcNameUnparseString (&buf, (FcChar8 *) ":", 0))
goto bail0;
- if (!FcNameUnparseString (&buf, o->object, FC_ESCAPE_VARIABLE))
+ if (!FcNameUnparseString (&buf, (FcChar8 *) o->object, (FcChar8 *) FC_ESCAPE_VARIABLE))
goto bail0;
- if (!FcNameUnparseString (&buf, "=", 0))
+ if (!FcNameUnparseString (&buf, (FcChar8 *) "=", 0))
goto bail0;
if (!FcNameUnparseValueList (&buf, e->values,
- FC_ESCAPE_VARIABLE))
+ (FcChar8 *) FC_ESCAPE_VARIABLE))
goto bail0;
}
}
/* match existing */
for (i = 0; i < p->num; i++)
{
- if (!FcStrCmpIgnoreCase (object, p->elts[i].object))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) object, (FcChar8 *) p->elts[i].object))
return &p->elts[i];
}
FcBool
-FcPatternAddString (FcPattern *p, const char *object, const char *s)
+FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s)
{
FcValue v;
v.type = FcTypeString;
- v.u.s = (char *) s;
+ v.u.s = s;
return FcPatternAdd (p, object, v, FcTrue);
}
}
FcResult
-FcPatternGetString (FcPattern *p, const char *object, int id, char ** s)
+FcPatternGetString (FcPattern *p, const char *object, int id, FcChar8 const ** s)
{
FcValue v;
FcResult r;
return r;
if (v.type != FcTypeString)
return FcResultTypeMismatch;
- *s = (char *) v.u.s;
+ *s = v.u.s;
return FcResultMatch;
}
#include <string.h>
#include "fcint.h"
-char *
-FcStrCopy (const char *s)
+FcChar8 *
+FcStrCopy (const FcChar8 *s)
{
- char *r;
+ FcChar8 *r;
if (!s)
return 0;
- r = (char *) malloc (strlen (s) + 1);
+ r = (FcChar8 *) malloc (strlen ((char *) s) + 1);
if (!r)
return 0;
- FcMemAlloc (FC_MEM_STRING, strlen (s) + 1);
- strcpy (r, s);
+ FcMemAlloc (FC_MEM_STRING, strlen ((char *) s) + 1);
+ strcpy ((char *) r, (char *) s);
return r;
}
-char *
-FcStrPlus (const char *s1, const char *s2)
+FcChar8 *
+FcStrPlus (const FcChar8 *s1, const FcChar8 *s2)
{
- int l = strlen (s1) + strlen (s2) + 1;
- char *s = malloc (l);
+ int l = strlen ((char *)s1) + strlen ((char *) s2) + 1;
+ FcChar8 *s = malloc (l);
if (!s)
return 0;
FcMemAlloc (FC_MEM_STRING, l);
- strcpy (s, s1);
- strcat (s, s2);
+ strcpy ((char *) s, (char *) s1);
+ strcat ((char *) s, (char *) s2);
return s;
}
void
-FcStrFree (char *s)
+FcStrFree (FcChar8 *s)
{
- FcMemFree (FC_MEM_STRING, strlen (s) + 1);
+ FcMemFree (FC_MEM_STRING, strlen ((char *) s) + 1);
free (s);
}
int
-FcStrCmpIgnoreCase (const char *s1, const char *s2)
+FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2)
{
- char c1, c2;
+ FcChar8 c1, c2;
for (;;)
{
FcEntityLoader (const char *url, const char *id, xmlParserCtxtPtr ctxt)
{
xmlParserInputPtr ret;
- char *file;
+ FcChar8 *file;
- file = FcConfigFilename (url);
+ file = FcConfigFilename ((FcChar8 *) url);
if (!file)
return 0;
- ret = xmlNewInputFromFile (ctxt, file);
+ ret = xmlNewInputFromFile (ctxt, (char *) file);
free (file);
return ret;
}
xmlDocPtr
-FcConfigLoad (const char *file)
+FcConfigLoad (const FcChar8 *file)
{
xmlDocPtr doc;
xmlExternalEntityLoader previous;
previous = xmlGetExternalEntityLoader ();
xmlSetExternalEntityLoader (FcEntityLoader);
- doc = xmlParseFile (file);
+ doc = xmlParseFile ((char *) file);
xmlSetExternalEntityLoader (previous);
return doc;
}
{
test->next = 0;
test->qual = qual;
- test->field = FcStrCopy (field);
+ test->field = (char *) FcStrCopy ((FcChar8 *) field);
test->op = compare;
test->expr = expr;
}
}
FcExpr *
-FcExprCreateString (const char *s)
+FcExprCreateString (const FcChar8 *s)
{
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
if (e)
{
e->op = FcOpField;
- e->u.field = FcStrCopy (field);
+ e->u.field = (char *) FcStrCopy ((FcChar8 *) field);
}
return e;
}
FcExpr *
-FcExprCreateConst (const char *constant)
+FcExprCreateConst (const FcChar8 *constant)
{
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
case FcOpBool:
break;
case FcOpField:
- FcStrFree (e->u.field);
+ FcStrFree ((FcChar8 *) e->u.field);
break;
case FcOpConst:
FcStrFree (e->u.constant);
char *
FcConfigSaveField (const char *field)
{
- return FcStrCopy (field);
+ return (char *) FcStrCopy ((FcChar8 *) field);
}
static void
va_end (args);
}
-static char *
+static xmlChar *
FcConfigContent (xmlDocPtr doc,
xmlNodePtr node)
{
- char *content;
+ xmlChar *content;
content = xmlNodeListGetString (doc, node->children, 1);
if (!content)
return content;
}
-static char *
+static xmlChar *
FcConfigAttr (xmlDocPtr doc,
xmlAttrPtr attr)
{
- char *content;
+ xmlChar *content;
content = xmlNodeListGetString (doc, attr->children, 1);
if (!content)
#define NUM_OPS (sizeof fcOps / sizeof fcOps[0])
static FcOp
-FcConfigLexOp (const char *op)
+FcConfigLexOp (const xmlChar *op)
{
int i;
}
static FcBool
-FcConfigLexBool (const char *bool)
+FcConfigLexBool (const xmlChar *bool)
{
if (*bool == 't' || *bool == 'T')
return FcTrue;
xmlDocPtr doc,
xmlNodePtr dir)
{
- char *content = FcConfigContent (doc, dir);
+ xmlChar *content = FcConfigContent (doc, dir);
if (!content)
return FcFalse;
- return FcConfigAddDir (config, content);
+ return FcConfigAddDir (config, (FcChar8 *) content);
}
static FcBool
xmlDocPtr doc,
xmlNodePtr dir)
{
- char *content = FcConfigContent (doc, dir);
+ xmlChar *content = FcConfigContent (doc, dir);
if (!content)
return FcFalse;
- return FcConfigSetCache (config, content);
+ return FcConfigSetCache (config, (FcChar8 *) content);
}
static FcBool
xmlDocPtr doc,
xmlNodePtr inc)
{
- char *content = FcConfigContent (doc, inc);
+ xmlChar *content = FcConfigContent (doc, inc);
xmlAttr *attr;
FcBool complain = FcTrue;
if (!strcmp (attr->name, "ignore_missing"))
complain = !FcConfigLexBool (FcConfigAttr (doc, attr));
}
- return FcConfigParseAndLoad (config, content, complain);
+ return FcConfigParseAndLoad (config, (FcChar8 *) content, complain);
}
static FcBool
continue;
if (!strcmp (node->name, "int"))
{
- ucs4 = (FcChar32) strtol (FcConfigContent (doc, node), 0, 0);
+ ucs4 = (FcChar32) strtol ((char *) FcConfigContent (doc, node), 0, 0);
if (!config->blanks)
{
config->blanks = FcBlanksCreate ();
static FcMatrix m;
enum { m_xx, m_xy, m_yx, m_yy, m_done } matrix_state = m_xx;
double v;
- char *text;
+ xmlChar *text;
FcMatrixInit (&m);
text = FcConfigContent (doc, node);
if (!text)
continue;
- v = strtod (text, 0);
+ v = strtod ((char *) text, 0);
switch (matrix_state) {
case m_xx: m.xx = v; break;
case m_xy: m.xy = v; break;
switch (op) {
case FcOpInteger:
- l = FcExprCreateInteger (strtol (FcConfigContent (doc, expr), 0, 0));
+ l = FcExprCreateInteger (strtol ((char *) FcConfigContent (doc, expr), 0, 0));
break;
case FcOpDouble:
- l = FcExprCreateDouble (strtod (FcConfigContent (doc, expr), 0));
+ l = FcExprCreateDouble (strtod ((char *) FcConfigContent (doc, expr), 0));
break;
case FcOpString:
- l = FcExprCreateString (FcConfigContent (doc, expr));
+ l = FcExprCreateString ((FcChar8 *) FcConfigContent (doc, expr));
break;
case FcOpMatrix:
l = FcExprCreateMatrix (FcConfigParseMatrix (doc, expr));
/* not sure what to do here yet */
break;
case FcOpField:
- l = FcExprCreateField (FcConfigContent (doc, expr));
+ l = FcExprCreateField ((char *) FcConfigContent (doc, expr));
break;
case FcOpConst:
- l = FcExprCreateConst (FcConfigContent (doc, expr));
+ l = FcExprCreateConst ((FcChar8 *) FcConfigContent (doc, expr));
break;
case FcOpQuest:
for (node = expr->children; node; node = node->next)
xmlAttrPtr attr;
FcQual qual = FcQualAny;
FcOp op = FcOpEqual;
- char *field = 0;
+ xmlChar *field = 0;
FcExpr *expr = 0;
for (attr = test->properties; attr; attr = attr->next)
continue;
if (!strcmp (attr->name, "qual"))
{
- char *qual_name = FcConfigAttr (doc, attr);
+ xmlChar *qual_name = FcConfigAttr (doc, attr);
if (!qual_name)
;
- else if (!strcmp (qual_name, "any"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) qual_name, (FcChar8 *) "any"))
qual = FcQualAny;
- else if (!strcmp (qual_name, "all"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) qual_name, (FcChar8 *) "all"))
qual = FcQualAll;
}
- else if (!strcmp (attr->name, "name"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) attr->name, (FcChar8 *) "name"))
{
field = FcConfigAttr (doc, attr);
}
- else if (!strcmp (attr->name, "compare"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) attr->name, (FcChar8 *) "compare"))
{
- char *compare = FcConfigAttr (doc, attr);
+ xmlChar *compare = FcConfigAttr (doc, attr);
if (!compare || (op = FcConfigLexOp (compare)) == FcOpInvalid)
{
FcConfigParseError ("Invalid comparison %s",
- compare ? compare : "<missing>");
+ compare ? (char *) compare : "<missing>");
return 0;
}
}
return 0;
}
- return FcTestCreate (qual, field, op, expr);
+ return FcTestCreate (qual, (char *) field, op, expr);
}
static FcExpr *
xmlNodePtr edit)
{
xmlAttrPtr attr;
- char *name = 0;
+ xmlChar *name = 0;
FcOp mode = FcOpAssign;
FcExpr *e;
FcEdit *ed;
{
if (attr->type != XML_ATTRIBUTE_NODE)
continue;
- if (!strcmp (attr->name, "name"))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) attr->name, (FcChar8 *) "name"))
name = FcConfigAttr (doc, attr);
- else if (!strcmp (attr->name, "mode"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) attr->name, (FcChar8 *) "mode"))
mode = FcConfigLexOp (FcConfigAttr (doc, attr));
}
e = FcConfigParseExprList (doc, edit->children);
- ed = FcEditCreate (name, mode, e);
+ ed = FcEditCreate ((char *) name, mode, e);
if (!ed)
FcExprDestroy (e);
return ed;
xmlAttrPtr attr;
FcTest *tests = 0, **prevTest = &tests, *test;
FcEdit *edits = 0, **prevEdit = &edits, *edit;
- FcMatchKind kind;
+ FcMatchKind kind = FcMatchPattern;
FcBool found_kind = FcFalse;
for (node = match->children; node; node = node->next)
{
if (node->type != XML_ELEMENT_NODE)
continue;
- if (!strcmp (node->name, "test"))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "test"))
{
test = FcConfigParseTest (doc, node);
if (!test)
*prevTest = test;
prevTest = &test->next;
}
- else if (!strcmp (node->name, "edit"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "edit"))
{
edit = FcConfigParseEdit (doc, node);
if (!edit)
{
if (attr->type != XML_ATTRIBUTE_NODE)
continue;
- if (!strcmp (attr->name, "target"))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) attr->name, (FcChar8 *) "target"))
{
- char *target = FcConfigAttr (doc, attr);
+ xmlChar *target = FcConfigAttr (doc, attr);
if (!target)
{
FcConfigParseError ("Missing match target");
break;
}
- else if (!strcmp (target, "pattern"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) target, (FcChar8 *) "pattern"))
{
kind = FcMatchPattern;
found_kind = FcTrue;
}
- else if (!strcmp (target, "font"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) target, (FcChar8 *) "font"))
{
kind = FcMatchFont;
found_kind = FcTrue;
return 0;
next = FcConfigParseFamilies (doc, family->next);
- if (family->type == XML_ELEMENT_NODE && !strcmp (family->name, "family"))
+ if (family->type == XML_ELEMENT_NODE &&
+ !FcStrCmpIgnoreCase ((FcChar8 *) family->name, (FcChar8 *) "family"))
{
- this = FcExprCreateString (FcConfigContent (doc, family));
+ this = FcExprCreateString ((FcChar8 *) FcConfigContent (doc, family));
if (!this)
goto bail;
if (next)
{
xmlNodePtr node;
FcExpr *prefer = 0, *accept = 0, *def = 0;
- FcExpr *family;
+ FcExpr *family = 0;
FcEdit *edit = 0, *next;
FcTest *test;
{
if (node->type != XML_ELEMENT_NODE)
continue;
- if (!strcmp (node->name, "family"))
- family = FcExprCreateString (FcConfigContent (doc, node));
- else if (!strcmp (node->name, "prefer"))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "family"))
+ family = FcExprCreateString ((FcChar8 *) FcConfigContent (doc, node));
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "prefer"))
prefer = FcConfigParseFamilies (doc, node->children);
- else if (!strcmp (node->name, "accept"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "accept"))
accept = FcConfigParseFamilies (doc, node->children);
- else if (!strcmp (node->name, "default"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "default"))
def = FcConfigParseFamilies (doc, node->children);
}
+ if (!family)
+ return FcFalse;
if (prefer)
{
{
if (node->type != XML_ELEMENT_NODE)
continue;
- if (!strcmp (node->name, "dir"))
+ if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "dir"))
{
if (!FcConfigParseDir (config, doc, node))
break;
}
- else if (!strcmp (node->name, "cache"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "cache"))
{
if (!FcConfigParseCache (config, doc, node))
break;
}
- else if (!strcmp (node->name, "include"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "include"))
{
if (!FcConfigParseInclude (config, doc, node))
break;
}
- else if (!strcmp (node->name, "config"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "config"))
{
if (!FcConfigParseConfig (config, doc, node))
break;
}
- else if (!strcmp (node->name, "match"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "match"))
{
if (!FcConfigParseMatch (config, doc, node))
break;
}
- else if (!strcmp (node->name, "alias"))
+ else if (!FcStrCmpIgnoreCase ((FcChar8 *) node->name, (FcChar8 *) "alias"))
{
if (!FcConfigParseAlias (config, doc, node))
break;
FcBool
FcConfigParseAndLoad (FcConfig *config,
- const char *file,
+ const FcChar8 *file,
FcBool complain)
{
xmlDocPtr doc;