Add an error() function to fnt2fon and sfnt2fnt.

This commit is contained in:
Vincent Béron 2005-12-07 12:44:17 +01:00 committed by Alexandre Julliard
parent a056a9a89c
commit 2e5da5f421
2 changed files with 45 additions and 22 deletions

View File

@ -61,6 +61,23 @@ static void usage(char **argv)
return;
}
#ifndef __GNUC__
#define __attribute__(X)
#endif
static void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
static void error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "Error: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(1);
}
int main(int argc, char **argv)
{
int i, j;
@ -99,8 +116,7 @@ int main(int argc, char **argv)
}
fread(&ver, sizeof(short), 1, fp);
if(ver != 0x200 && ver != 0x300) {
fprintf(stderr, "invalid fnt file %s ver %d\n", argv[i+1], ver);
exit(1);
error("invalid fnt file %s ver %d", argv[i+1], ver);
}
fread(file_lens + i, sizeof(int), 1, fp);
fseek(fp, 0x44, SEEK_SET);

View File

@ -61,6 +61,23 @@ static void usage(char **argv)
return;
}
#ifndef __GNUC__
#define __attribute__(X)
#endif
static void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
static void error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "Error: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(1);
}
static int lookup_charset(int enc)
{
/* FIXME: make winelib app and use TranslateCharsetInfo */
@ -130,33 +147,25 @@ static void fill_fontinfo(FT_Face face, int enc, FILE *fp, int dpi, unsigned cha
FT_SfntName sfntname;
TT_OS2 *os2;
cptable = wine_cp_get_table(enc);
if(!cptable) {
fprintf(stderr, "Can't find codepage %d\n", enc);
exit(1);
}
if(!cptable)
error("Can't find codepage %d\n", enc);
if(cptable->info.char_size != 1) {
/* for double byte charsets we actually want to use cp1252 */
cptable = wine_cp_get_table(1252);
if(!cptable) {
fprintf(stderr, "Can't find codepage 1252\n");
exit(1);
}
if(!cptable)
error("Can't find codepage 1252\n");
}
ppem = face->size->metrics.y_ppem;
start = sizeof(FNT_HEADER) + sizeof(FONTINFO16);
if(FT_Load_Char(face, 0xc5, FT_LOAD_DEFAULT)) {
fprintf(stderr, "Can't find Aring\n");
exit(1);
}
if(FT_Load_Char(face, 0xc5, FT_LOAD_DEFAULT))
error("Can't find Aring\n");
ascent = face->glyph->metrics.height >> 6;
descent = ppem - ascent;
if(FT_Load_Char(face, 'M', FT_LOAD_DEFAULT)) {
fprintf(stderr, "Can't find M\n");
exit(1);
}
if(FT_Load_Char(face, 'M', FT_LOAD_DEFAULT))
error("Can't find M\n");
il = ascent - (face->glyph->metrics.height >> 6);
/* Hack: Courier has no internal leading, nor do any Chinese fonts */
@ -344,10 +353,8 @@ int main(int argc, char **argv)
def_char = atoi(argv[5]);
avg_width = atoi(argv[6]);
if(FT_Init_FreeType(&lib)) {
fprintf(stderr, "ft init failure\n");
exit(1);
}
if(FT_Init_FreeType(&lib))
error("ft init failure\n");
if(FT_New_Face(lib, argv[1], 0, &face)) {
fprintf(stderr, "Can't open face\n");