#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <libgen.h>
#include "fcint.h"
#include <ft2build.h>
#include FT_FREETYPE_H
{ 20, (const FcChar8 *) "zh-tw" },
};
-#define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
+#define NUM_CODE_PAGE_RANGE (int) (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
FcBool
FcFreeTypeIsExclusiveLang (const FcChar8 *lang)
}
typedef struct {
- FT_UShort platform_id;
- FT_UShort encoding_id;
- char *fromcode;
+ const FT_UShort platform_id;
+ const FT_UShort encoding_id;
+ const char fromcode[12];
} FcFtEncoding;
#define TT_ENCODING_DONT_CARE 0xffff
{ TT_PLATFORM_ISO, TT_ISO_ID_8859_1, "ISO-8859-1" },
};
-#define NUM_FC_FT_ENCODING (sizeof (fcFtEncoding) / sizeof (fcFtEncoding[0]))
+#define NUM_FC_FT_ENCODING (int) (sizeof (fcFtEncoding) / sizeof (fcFtEncoding[0]))
typedef struct {
- FT_UShort platform_id;
- FT_UShort language_id;
- char *lang;
+ const FT_UShort platform_id;
+ const FT_UShort language_id;
+ const char lang[8];
} FcFtLanguage;
#define TT_LANGUAGE_DONT_CARE 0xffff
static const FcFtLanguage fcFtLanguage[] = {
- { TT_PLATFORM_APPLE_UNICODE, TT_LANGUAGE_DONT_CARE, 0 },
+ { TT_PLATFORM_APPLE_UNICODE, TT_LANGUAGE_DONT_CARE, "" },
{ TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ENGLISH, "en" },
{ TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FRENCH, "fr" },
{ TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GERMAN, "de" },
{ TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES,"pap" },
};
-#define NUM_FC_FT_LANGUAGE (sizeof (fcFtLanguage) / sizeof (fcFtLanguage[0]))
+#define NUM_FC_FT_LANGUAGE (int) (sizeof (fcFtLanguage) / sizeof (fcFtLanguage[0]))
typedef struct {
FT_UShort language_id;
- char *fromcode;
+ char fromcode[12];
} FcMacRomanFake;
static const FcMacRomanFake fcMacRomanFake[] = {
static FcChar8 *
FcFontCapabilities(FT_Face face);
-#define NUM_FC_MAC_ROMAN_FAKE (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0]))
+#define NUM_FC_MAC_ROMAN_FAKE (int) (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0]))
#if HAVE_ICONV && HAVE_ICONV_H
#define USE_ICONV 1
static FcChar8 *
FcSfntNameTranscode (FT_SfntName *sname)
{
- int i;
- char *fromcode;
+ int i;
+ const char *fromcode;
#if USE_ICONV
iconv_t cd;
#endif
{
int f;
- fromcode = 0;
+ fromcode = NULL;
for (f = 0; f < NUM_FC_MAC_ROMAN_FAKE; f++)
if (fcMacRomanFake[f].language_id == sname->language_id)
{
return utf8;
}
-static FcChar8 *
+static const FcChar8 *
FcSfntNameLanguage (FT_SfntName *sname)
{
int i;
if (fcFtLanguage[i].platform_id == sname->platform_id &&
(fcFtLanguage[i].language_id == TT_LANGUAGE_DONT_CARE ||
fcFtLanguage[i].language_id == sname->language_id))
- return (FcChar8 *) fcFtLanguage[i].lang;
+ {
+ if (fcFtLanguage[i].lang[0] == '\0')
+ return NULL;
+ else
+ return (FcChar8 *) fcFtLanguage[i].lang;
+ }
return 0;
}
(const FcChar8 *) "hanyang" }
};
-#define NUM_NOTICE_FOUNDRIES (sizeof (FcNoticeFoundries) / sizeof (FcNoticeFoundries[0]))
+#define NUM_NOTICE_FOUNDRIES (int) (sizeof (FcNoticeFoundries) / sizeof (FcNoticeFoundries[0]))
static const FcChar8 *
FcNoticeFoundry(const FT_String *notice)
{ (const FT_Char *) "Y&Y", (const FcChar8 *) "y&y"}
};
-#define NUM_VENDOR_FOUNDRIES (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0]))
+#define NUM_VENDOR_FOUNDRIES (int) (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0]))
static const FcChar8 *
FcVendorFoundry(const FT_Char vendor[4])
{ (FC8) "heavy", FC_WEIGHT_HEAVY },
};
-#define NUM_WEIGHT_CONSTS (sizeof (weightConsts) / sizeof (weightConsts[0]))
+#define NUM_WEIGHT_CONSTS (int) (sizeof (weightConsts) / sizeof (weightConsts[0]))
#define FcIsWeight(s) FcStringIsConst(s,weightConsts,NUM_WEIGHT_CONSTS)
#define FcContainsWeight(s) FcStringContainsConst (s,weightConsts,NUM_WEIGHT_CONSTS)
{ (FC8) "expanded", FC_WIDTH_EXPANDED }, /* must be after *expanded */
};
-#define NUM_WIDTH_CONSTS (sizeof (widthConsts) / sizeof (widthConsts[0]))
+#define NUM_WIDTH_CONSTS (int) (sizeof (widthConsts) / sizeof (widthConsts[0]))
#define FcIsWidth(s) FcStringIsConst(s,widthConsts,NUM_WIDTH_CONSTS)
#define FcContainsWidth(s) FcStringContainsConst (s,widthConsts,NUM_WIDTH_CONSTS)
{ (FC8) "oblique", FC_SLANT_OBLIQUE },
};
-#define NUM_SLANT_CONSTS (sizeof (slantConsts) / sizeof (slantConsts[0]))
+#define NUM_SLANT_CONSTS (int) (sizeof (slantConsts) / sizeof (slantConsts[0]))
#define FcIsSlant(s) FcStringIsConst(s,slantConsts,NUM_SLANT_CONSTS)
#define FcContainsSlant(s) FcStringContainsConst (s,slantConsts,NUM_SLANT_CONSTS)
}
static FcBool
-FcStringInPatternElement (FcPattern *pat, char *elt, FcChar8 *string)
+FcStringInPatternElement (FcPattern *pat, const char *elt, FcChar8 *string)
{
int e;
FcChar8 *old;
for (snamei = 0; snamei < snamec; snamei++)
{
FcChar8 *utf8;
- FcChar8 *lang;
- char *elt = 0, *eltlang = 0;
+ const FcChar8 *lang;
+ const char *elt = 0, *eltlang = 0;
int *np = 0, *nlangp = 0;
if (FT_Get_Sfnt_Name (face, snamei, &sname) != 0)
printf ("Saving unique fullname %s\n", full);
}
- if (!FcPatternAddString (pat, FC_FILE, file))
+ if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)FcStrCopy(file))))
goto bail1;
+ FcPatternAddFullFname (pat, (const char *)file);
+
if (!FcPatternAddInteger (pat, FC_INDEX, id))
goto bail1;
{ ft_encoding_apple_roman, &AppleRoman, (1 << 16) - 1 },
};
-#define NUM_DECODE (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0]))
+#define NUM_DECODE (int) (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0]))
static const FcChar32 prefer_unicode[] = {
0x20ac, /* EURO SIGN */
};
-#define NUM_PREFER_UNICODE (sizeof (prefer_unicode) / sizeof (prefer_unicode[0]))
+#define NUM_PREFER_UNICODE (int) (sizeof (prefer_unicode) / sizeof (prefer_unicode[0]))
FcChar32
FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map)
return FcFalse;
}
-static FcChar8 *
+static const FcChar8 *
FcUcs4ToGlyphName (FcChar32 ucs4)
{
int i = (int) (ucs4 % FC_GLYPHNAME_HASH);
int r = 0;
- FcGlyphName *gn;
+ const FcGlyphName *gn;
while ((gn = ucs_to_name[i]))
{
FcChar32 h = FcHashGlyphName (name);
int i = (int) (h % FC_GLYPHNAME_HASH);
int r = 0;
- FcGlyphName *gn;
+ const FcGlyphName *gn;
while ((gn = name_to_ucs[i]))
{
* any defined order within the font
*/
static FT_UInt
-FcFreeTypeGlyphNameIndex (FT_Face face, FcChar8 *name)
+FcFreeTypeGlyphNameIndex (FT_Face face, const FcChar8 *name)
{
FT_UInt gindex;
FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2];
- for (gindex = 0; gindex < face->num_glyphs; gindex++)
+ for (gindex = 0; gindex < (FT_UInt) face->num_glyphs; gindex++)
{
if (FT_Get_Glyph_Name (face, gindex, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0)
if (!strcmp ((char *) name, (char *) name_buf))
if (fcFontDecoders[decode].map)
{
charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map);
- if (charcode == ~0)
+ if (charcode == ~0U)
continue;
}
else
*/
if (FcFreeTypeUseNames (face))
{
- FcChar8 *name = FcUcs4ToGlyphName (ucs4);
+ const FcChar8 *name = FcUcs4ToGlyphName (ucs4);
if (name)
{
glyphindex = FcFreeTypeGlyphNameIndex (face, name);
{
FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2];
- for (glyph = 0; glyph < face->num_glyphs; glyph++)
+ for (glyph = 0; glyph < (FT_UInt) face->num_glyphs; glyph++)
{
if (FT_Get_Glyph_Name (face, glyph, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0)
{