|
|
1.1 ! root 1: #include <jerq.h> ! 2: #include <jerqio.h> ! 3: #include <font.h> ! 4: #define ISIZE(n) ((n+1)*sizeof(Fontchar)) ! 5: ! 6: /* ! 7: * read a font from an input stream ! 8: * <font header> ! 9: * <f->info> ! 10: * <f->bits> no bitmap header!! ! 11: * ! 12: * WARNING! This code believes it knows what the Font structure looks like ! 13: */ ! 14: ! 15: static int (*inch)(), (*ouch)(); ! 16: ! 17: Font * ! 18: infont(incharg) ! 19: int (*incharg)(); ! 20: { ! 21: /* ! 22: * Following line changed for the DMD! ! 23: * ! 24: */ ! 25: short n; ! 26: register Font *f; ! 27: register Bitmap *b; ! 28: char *temp; ! 29: ! 30: inch = incharg; ! 31: temp = (char *)&n; ! 32: if(ninch(2, &temp)) ! 33: return((Font *)0); ! 34: if((f = (Font *) alloc(sizeof(Font)+ISIZE(n-1))) == (Font *)0) ! 35: return(f); ! 36: f->n = n; ! 37: temp = 2 + (char *)f; ! 38: if(ninch(6, &temp)) /* 6 == sizeof(height+ascent+unused) */ ! 39: goto err; ! 40: temp = (char *)f->info; ! 41: if(ninch(ISIZE(n), &temp)) ! 42: goto err; ! 43: if((b = balloc(Rect(0, 0, f->info[n].x, f->height))) == (Bitmap *)0) ! 44: goto err; ! 45: f->bits = b; ! 46: if(ninch(sizeof(Word)*f->height*b->width, (char **)&(b->base))) ! 47: goto berr; ! 48: return(f); ! 49: ! 50: berr: ! 51: bfree(f->bits); ! 52: err: ! 53: free(f); ! 54: return((Font *)0); ! 55: } ! 56: ! 57: static ! 58: ninch(n, base) ! 59: register n; ! 60: register char **base; ! 61: { ! 62: register x, i; ! 63: ! 64: i = 0; ! 65: do { ! 66: x = (*inch)(); ! 67: (*base)[i++] = x; ! 68: if(x == -1) ! 69: return(1); ! 70: } while (--n > 0); ! 71: return(0); ! 72: } ! 73: ! 74: ffree(f) ! 75: register Font *f; ! 76: { ! 77: if (f != (Font *) NULL) { ! 78: bfree(f->bits); ! 79: free(f); ! 80: } ! 81: } ! 82: ! 83: outfont(f,oucharg) ! 84: register Font *f; ! 85: int (*oucharg)(); ! 86: { ! 87: register Bitmap *b = f->bits; ! 88: char *temp; ! 89: ! 90: ouch = oucharg; ! 91: if( ! 92: (temp = (char *)f, nouch(8, &temp)) || ! 93: (temp = (char *)f->info, nouch(ISIZE(f->n), &temp)) || ! 94: nouch(sizeof(Word)*f->height*b->width, (char **)&b->base) ! 95: ) ! 96: { ! 97: return(-1); ! 98: } ! 99: else ! 100: { ! 101: return(0); ! 102: } ! 103: } ! 104: ! 105: static ! 106: nouch(n,base) ! 107: register n; ! 108: register char **base; ! 109: { ! 110: register i = 0; ! 111: do { ! 112: if((*ouch)((*base)[i++]) == -1) ! 113: return(-1); ! 114: } while (--n > 0); ! 115: return(0); ! 116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.