Subversion Repositories wimsdev

Rev

Rev 1818 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 2002-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18. /* dvi 2 gif driver, tfm loader */
  19. #include "texgif.h"
  20.  
  21. struct tfm tfm;
  22.  
  23. short int tfmhd[12];
  24.  
  25. #define tfmlf tfmhd[0]
  26. #define tfmlh tfmhd[1]
  27. #define tfmbc tfmhd[2]
  28. #define tfmec tfmhd[3]
  29. #define tfmnw tfmhd[4]
  30. #define tfmnh tfmhd[5]
  31. #define tfmnd tfmhd[6]
  32. #define tfmni tfmhd[7]
  33. #define tfmnl tfmhd[8]
  34. #define tfmnk tfmhd[9]
  35. #define tfmne tfmhd[10]
  36. #define tfmnp tfmhd[11]
  37.  
  38. void loadtfm(char *fname)
  39. {
  40.     int i, k, t, len, charcnt;
  41.     char namebuf[1024];
  42.     int32_t *wpbase;
  43.     int32_t *headp, *fp, *fip, *wp, *hp, *dp;
  44.     unsigned char *tfmbuf, *ftp;
  45.  
  46.     memset(&tfm,0,sizeof(tfm));
  47.     snprintf(namebuf,sizeof(namebuf),"%s/%s.tfm",tmpdir,fname);
  48.     call_sh("cp `kpsewhich %s.tfm` %s",fname,tmpdir);
  49.     len=getfile(namebuf,&tfmbuf); unlink(namebuf);
  50.     if(len<0) {
  51.         error("Error reading tfm file.");
  52.     }
  53.     for(i=0;i<12;i++) tfmhd[i]=texint(tfmbuf+2*i,2);
  54.     tfm.bc=tfmbc; tfm.ec=tfmec;
  55.     charcnt=tfmec-tfmbc+1;
  56.     if(charcnt<=0) return;
  57.     wpbase=(int32_t *) tfmbuf;
  58.     headp=wpbase+6;             /* header */
  59.     fp=headp+tfmlh;             /* font info */
  60.     wp=fp+charcnt;              /* width table */
  61.     hp=wp+tfmnw;                /* height table */
  62.     dp=hp+tfmnh;                /* depth table */
  63.     tfm.checksum=headp[0];
  64.     tfm.designsize=texint(headp+1,4);
  65.     for(i=0, t=tfmbc;i<charcnt; i++,t++) {
  66.         fip=fp+i; ftp=(unsigned char *) fip;
  67.         k=*ftp; tfm.f[t].w=texint(wp+k,4); ftp++;
  68.         k=((*ftp)>>4)&15; tfm.f[t].h=texint(hp+k,4);
  69.         k=(*ftp)&15; tfm.f[t].d=texint(dp+k,4);
  70.     }
  71.     free(tfmbuf);
  72. }
  73.  
  74.