Back to index

tetex-bin  3.0
Defines | Functions
vf.c File Reference
#include "dvipng.h"

Go to the source code of this file.

Defines

#define VF_ID   202
#define LONG_CHAR   242

Functions

int32_t SetVF (int32_t c)
void InitVF (struct font_entry *tfontp)
void DoneVF (struct font_entry *tfontp)

Define Documentation

#define LONG_CHAR   242

Definition at line 29 of file vf.c.

#define VF_ID   202

Definition at line 28 of file vf.c.


Function Documentation

void DoneVF ( struct font_entry tfontp)

Definition at line 129 of file vf.c.

{
  int c=FIRSTFNTCHAR;

  UnMmapFile(&(tfontp->fmmap));
  while(c<=LASTFNTCHAR) {
    if (tfontp->chr[c]!=NULL) {
      free(tfontp->chr[c]);
      tfontp->chr[c]=NULL;
    }
    c++;
  }
  FreeFontNumP(tfontp->vffontnump);
  tfontp->vffontnump=NULL;
  tfontp->name[0]='\0';
}

Here is the call graph for this function:

Here is the caller graph for this function:

void InitVF ( struct font_entry tfontp)

Definition at line 53 of file vf.c.

{
  unsigned char* position;
  int length;
  struct char_entry *tcharptr;  
  uint32_t c=0;
  struct font_num *tfontnump;  /* temporary font_num pointer   */
  
  DEBUG_PRINT((DEBUG_DVI|DEBUG_VF),("\n  OPEN FONT:\t'%s'", tfontp->name));
  Message(BE_VERBOSE,"<%s>", tfontp->name);
  if (MmapFile(tfontp->name,&(tfontp->fmmap)))
    Fatal("font file %s unusable", tfontp->name);
  position=(unsigned char*)tfontp->fmmap.mmap;
  if (*(position) != PRE) 
    Fatal("unknown font format in file <%s> !\n",currentfont->name);
  if (*(position+1) != VF_ID) 
      Fatal( "wrong version of vf file!  (%d should be 202)\n",
            (int)*(position+1));
  DEBUG_PRINT(DEBUG_VF,("\n  VF_PRE:\t'%.*s'", 
              (int)*(position+2), position+3));
  position = position+3 + *(position+2);
  c=UNumRead(position, 4);
  DEBUG_PRINT(DEBUG_VF,(" %d", c));
  CheckChecksum (tfontp->c, c, tfontp->name);
  tfontp->designsize = UNumRead(position+4,4);
  DEBUG_PRINT(DEBUG_VF,(" %d", tfontp->designsize));
  tfontp->type = FONT_TYPE_VF;
  tfontp->vffontnump=NULL;
  /* Read font definitions */
  position += 8;
  while(*position >= FNT_DEF1 && *position <= FNT_DEF4) {
    DEBUG_PRINT(DEBUG_VF,("\n  @%ld VF:\t%s", 
                       (long)position - (long)tfontp->fmmap.mmap, 
                       dvi_commands[*position]));
    FontDef(position,tfontp);      
    length = dvi_commandlength[*position];
    position += length + *(position + length-1) + *(position+length-2);
  }
  /* Default font is the first defined */
  tfontnump = tfontp->vffontnump;
  while (tfontnump->next != NULL) {
    tfontnump = tfontnump->next;
  }
  tfontp->defaultfont=tfontnump->k;
  
  /* Read char definitions */
  while(*position < FNT_DEF1) {
    DEBUG_PRINT(DEBUG_VF,("\n@%ld VF CHAR:\t", 
                       (long)position - (long)tfontp->fmmap.mmap));
    tcharptr=xmalloc(sizeof(struct char_entry));
    switch (*position) {
    case LONG_CHAR:
      tcharptr->length = UNumRead(position+1,4);
      c = UNumRead(position+5,4);
      tcharptr->tfmw = UNumRead(position+9,4);
      position += 13;
      break;
    default:
      tcharptr->length = UNumRead(position,1);
      c = UNumRead(position+1,1);
      tcharptr->tfmw = UNumRead(position+2,3);
      position += 5;
    }
    DEBUG_PRINT(DEBUG_VF,("%d %d %d",tcharptr->length,c,tcharptr->tfmw));
    tcharptr->tfmw = (int32_t) 
      ((int64_t) tcharptr->tfmw * tfontp->s / (1 << 20));
    DEBUG_PRINT(DEBUG_VF,(" (%d)",tcharptr->tfmw));
    if (c > NFNTCHARS) /* Only positive for now */
      Fatal("vf character exceeds numbering limit");
    tfontp->chr[c] = tcharptr;
    tcharptr->data=position;
    position += tcharptr->length;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 31 of file vf.c.

{
  struct font_entry* currentvf;
  unsigned char *command,*end;
  struct char_entry* ptr=currentfont->chr[c];

  currentvf=currentfont;
  BeginVFMacro(currentvf);
  command = ptr->data;
  end = command + ptr->length;
  while (command < end)  {
    DEBUG_PRINT(DEBUG_DVI,("\n  VF MACRO:\t%s ", dvi_commands[*command]));
    DrawCommand(command,currentvf);
    command += CommandLength(command);
  } 
  EndVFMacro();
  currentfont=currentvf;
  return(ptr->tfmw);
}

Here is the call graph for this function:

Here is the caller graph for this function: