/* * For a character style, the UPE.chpx can be constructed by starting with * the first UPE from the based-on style (std.istdBase). */ void wvInitCHPXFromIstd(CHPX *chpx, U16 istdBase, STSH *stsh) { if (istdBase == istdNil) wvInitCHPX(chpx); else { if (istdBase >= stsh->Stshi.cstd) { wvError( ("ISTD out of bounds, requested %d of %d\n", istdBase, stsh->Stshi.cstd)); wvInitCHPX(chpx); /*it can't hurt to try and start with a blank istd */ return; } else wvCopyCHPX(chpx, &(stsh->std[istdBase].grupe[0].chpx)); } }
/* Character properties * -basically just like PAPX FKPs above * however, rather than an array of BX structs in rgbx, * there is an array of bytes (giving the word offset to the CHPX) in rgb * -JB */ void wvGetCHPX_FKP (wvVersion ver, CHPX_FKP * fkp, U32 pn, wvStream * fd) { int i; U8 page[WV_PAGESIZE]; U16 pos = 0; /*size_t bytes_read; */ /* [email protected] */ /* there seem to be a lot of repeat calls... */ /* pn=0 is safe because thats the index block, not a CHPX_FKP */ if (pn != 0 && pn == wvCHPX_pn_previous) { memcpy (fkp, &wvCHPX_FKP_previous, sizeof (CHPX_FKP)); return; } wvStream_goto (fd, pn * WV_PAGESIZE); /*bytes_read= */ wvStream_read (page, WV_PAGESIZE, 1, fd); fkp->crun = (U8) page[WV_PAGESIZE - 1]; wvTrace (("chpx fkp gone to %x\n", pn * WV_PAGESIZE + (WV_PAGESIZE - 1))); wvTrace (("crun is %d\n", fkp->crun)); fkp->rgfc = (U32 *) wvMalloc (sizeof (U32) * (fkp->crun + 1)); fkp->rgb = (U8 *) wvMalloc (sizeof (U8) * (fkp->crun)); fkp->grpchpx = (CHPX *) wvMalloc (sizeof (CHPX) * (fkp->crun)); wvStream_goto (fd, pn * WV_PAGESIZE); wvTrace (("offset is %x\n", pn * WV_PAGESIZE)); for (i = 0; i < fkp->crun + 1; i++) { fkp->rgfc[i] = bread_32ubit (&(page[pos]), &pos); wvTrace (("rgfc is %x\n", fkp->rgfc[i])); } for (i = 0; i < fkp->crun; i++) fkp->rgb[i] = bread_8ubit (&(page[pos]), &pos); for (i = 0; i < fkp->crun; i++) { if (fkp->rgb[i] == 0) { wvTrace (("i is %d, using clear chpx\n", i)); wvInitCHPX (&(fkp->grpchpx[i])); } else { wvTrace ( ("chpx index i is %d, offset is %x\n", i, (pn * WV_PAGESIZE) + (fkp->rgb[i] * 2))); pos = fkp->rgb[i] * 2; wvGetCHPX (ver, &(fkp->grpchpx[i]), page, &pos); } } if (wvCHPX_pn_previous != 0) internal_wvReleaseCHPX_FKP (&wvCHPX_FKP_previous); memcpy (&wvCHPX_FKP_previous, fkp, sizeof (CHPX_FKP)); wvCHPX_pn_previous = pn; }