--- ray/src/common/font.c 2003/05/13 17:58:32 2.14 +++ ray/src/common/font.c 2021/11/19 21:56:48 2.21 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: font.c,v 2.14 2003/05/13 17:58:32 greg Exp $"; +static const char RCSid[] = "$Id: font.c,v 2.21 2021/11/19 21:56:48 greg Exp $"; #endif /* * Polygonal font handling routines @@ -7,8 +7,11 @@ static const char RCSid[] = "$Id: font.c,v 2.14 2003/0 #include "copyright.h" -#include "standard.h" +#include +#include "paths.h" +#include "rtio.h" +#include "rterror.h" #include "font.h" #define galloc(nv) (GLYPH *)malloc(sizeof(GLYPH)+2*sizeof(GORD)*(nv)) @@ -20,16 +23,17 @@ static FONT *fontlist = NULL; /* list of loaded fonts FONT * -getfont(fname) /* return font fname */ -char *fname; +getfont( /* return font fname */ + char *fname +) { FILE *fp; - char *pathname, *err; + char *pathname, *err = NULL; unsigned wsum, hsum, ngly; int gn, ngv, gv; - register GLYPH *g; + GLYPH *g; GORD *gp; - register FONT *f; + FONT *f; for (f = fontlist; f != NULL; f = f->next) if (!strcmp(f->name, fname)) { @@ -39,7 +43,7 @@ char *fname; /* load the font file */ if ((pathname = getpath(fname, getrlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find font file \"%s\"", fname); - error(USER, errmsg); + error(SYSTEM, errmsg); } f = (FONT *)calloc(1, sizeof(FONT)); if (f == NULL) @@ -117,23 +121,25 @@ fonterr: error(USER, errmsg); memerr: error(SYSTEM, "out of memory in fontglyph"); + return NULL; /* pro forma return */ } void -freefont(fnt) /* release a font (free all if NULL) */ -FONT *fnt; +freefont( /* release a font (free all if NULL) */ + FONT *fnt +) { FONT head; - register FONT *fl, *f; - register int i; + FONT *fl, *f; + int i; /* check reference count */ - if (fnt != NULL && (fnt->nref-- > 1 | retainfonts)) + if (fnt != NULL && ((fnt->nref-- > 1) | retainfonts)) return; head.next = fontlist; fl = &head; while ((f = fl->next) != NULL) - if ((fnt == NULL | fnt == f)) { + if ((fnt == NULL) | (fnt == f)) { fl->next = f->next; for (i = 0; i < 256; i++) if (f->fg[i] != NULL) @@ -147,10 +153,11 @@ FONT *fnt; int -uniftext(sp, tp, f) /* uniformly space text line */ -register short *sp; /* returned character spacing */ -register char *tp; /* text line */ -register FONT *f; /* font */ +uniftext( /* uniformly space text line */ + short *sp, /* returned character spacing */ + char *tp, /* text line */ + FONT *f /* font */ +) { int linelen; @@ -165,14 +172,15 @@ register FONT *f; /* font */ int -squeeztext(sp, tp, f, cis) /* squeeze text line */ -short *sp; /* returned character spacing */ -char *tp; /* text line */ -FONT *f; /* font */ -int cis; /* intercharacter spacing */ +squeeztext( /* squeeze text line */ + short *sp, /* returned character spacing */ + char *tp, /* text line */ + FONT *f, /* font */ + int cis /* intercharacter spacing */ +) { int linelen; - register GLYPH *gp; + GLYPH *gp; linelen = 0; gp = NULL; @@ -200,14 +208,15 @@ int cis; /* intercharacter spacing */ int -proptext(sp, tp, f, cis, nsi) /* space line proportionally */ -short *sp; /* returned character spacing */ -char *tp; /* text line */ -FONT *f; /* font */ -int cis; /* target intercharacter spacing */ -int nsi; /* minimum number of spaces for indent */ +proptext( /* space line proportionally */ + short *sp, /* returned character spacing */ + char *tp, /* text line */ + FONT *f, /* font */ + int cis, /* target intercharacter spacing */ + int nsi /* minimum number of spaces for indent */ +) { - register char *end, *tab; + char *end, *tab = NULL; GLYPH *gp; short *nsp; int alen, len, width;