Back to index

wims  3.65+svn20090927
Functions
font.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void mf2font (char *fontname, int density)
FONTloadfont (char *fname, int checksum, int density, FONT *ft)

Function Documentation

FONT* loadfont ( char *  fname,
int  checksum,
int  density,
FONT ft 
)

Definition at line 28 of file font.c.

{
    char namebuf[2048];
    char *fcache, *cc;
    long int l,l2;
    FILE *f;
    int newfont;
    
    newfont=0;
    for(cc=fname; isalnum(*cc); cc++); 
    if(*cc!=0) error("Bad font name.");
    snprintf(namebuf,sizeof(namebuf),"%s/%d/%s.font",fontdir,density,fname);
    f=fopen(namebuf,"r"); if(f==NULL) {
       renewfont: mf2font(fname,density);
       f=fopen(namebuf,"r"); newfont=1;
    }
    if(f==NULL) return NULL;
    fseek(f,0,SEEK_END); l=ftell(f); fseek(f,0,SEEK_SET);
    if(l<=0 || l>FILE_LENGTH_LIMIT) return NULL;
    fcache=xmalloc(l+16);
    l2=fread(fcache,1,l,f); if(l2!=l) {
       error("Error reading font file.");
    }
    memmove(&ft->checksum,fcache,sizeof(int));
    memmove(&ft->designsize,fcache+sizeof(int),sizeof(int));
    memmove(&ft->bc,fcache+2*sizeof(int),sizeof(int));
    memmove(&ft->ec,fcache+3*sizeof(int),sizeof(int));
    ft->cnt=ft->ec-ft->bc+1;
    cc=fcache+4*sizeof(int); ft->fh=(FONTHEADER *) cc;
    ft->data=fcache+4*sizeof(int)+ft->cnt*sizeof(FONTHEADER);
    ft->cache=fcache;
    fclose(f);
    if(checksum!=ft->checksum && checksum!=0 && ft->checksum!=0) {
       if(newfont) {
           fprintf(stderr,"%08X != %08X\n",checksum, ft->checksum);
           error("Font checksum discord.");
       }
       free(fcache); unlink(namebuf); goto renewfont;
    }
    return ft;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mf2font ( char *  fontname,
int  density 
)

Definition at line 20 of file font.c.

{
    loadtfm(fontname);
    makegf(fontname,density);
    loadgf(fontname,density);
    gf2font(fontname,density);
}

Here is the call graph for this function:

Here is the caller graph for this function: