/* This has to be extended in the future to return a list of possible font names, as the FFN spec mentions. It currently on does the first one. */ char * wvGetFontnameFromCode(FFN_STTBF *item, int fontcode) { if (fontcode >= item->nostrings) return NULL; return wvWideStrToMB(item->ffn[fontcode].xszFfn); }
void wvGetFFN_STTBF(FFN_STTBF *item, U32 offset, U32 len, wvStream *fd) { int i; wvTrace(("reading fonts...\n")); wvTrace(("seeking to %x, len %d\n", offset, len)); if (len == 0) { item->nostrings = 0; item->ffn = NULL; } else { wvStream_goto(fd, offset); item->extendedflag = read_16ubit(fd); if (item->extendedflag == 0xFFFF) item->nostrings = read_16ubit(fd); else item->nostrings = item->extendedflag; item->extradatalen = read_16ubit(fd); item->ffn = (FFN *)wvMalloc(item->nostrings * sizeof(FFN)); for (i = 0; i < item->nostrings; i++) { #ifdef DEBUG char *dbg; #endif wvGetFFN(&(item->ffn[i]), fd); #ifdef DEBUG dbg = wvWideStrToMB(item->ffn[i].xszFfn); wvTrace(("font %d: %s\n", i, dbg)); if (dbg) wvFree(dbg); #endif } } wvTrace(("done reading fonts.\n")); }
void wvGetFFN_STTBF6 (FFN_STTBF * item, U32 offset, U32 len, wvStream * fd) { U32 count = 0; int noffn = 0; wvTrace (("reading fonts 6...\n")); wvTrace (("seeking to %x, len %d\n", offset, len)); if (len == 0) { item->nostrings = 0; item->ffn = NULL; return; } wvStream_goto (fd, offset); item->extendedflag = 0; item->nostrings = 5; /* lets just set a val to start off with */ item->extradatalen = 0; item->ffn = (FFN *) wvMalloc (item->nostrings * sizeof (FFN)); if (len != read_16ubit (fd)) wvError (("FFN STTBF lens differ\n")); count += 2; while (count < len) { #ifdef DEBUG char *dbg; #endif if (noffn == item->nostrings) { /* need to extend the array just in case */ item->nostrings += 5; item->ffn = (FFN *) realloc (item->ffn, item->nostrings * sizeof (FFN)); } wvGetFFN6 (&(item->ffn[noffn]), fd); count += (item->ffn[noffn].cbFfnM1 + 1); #ifdef DEBUG dbg = wvWideStrToMB (item->ffn[noffn].xszFfn); wvTrace (("font %d: %s\n", noffn, dbg)); if (dbg) wvFree (dbg); #endif noffn++; } if (item->nostrings != noffn) item->nostrings = noffn; wvTrace (("done reading fonts 6.\n")); }