Back to index

tetex-bin  3.0
Functions | Variables
fontfcn.c File Reference
#include <stdio.h>
#include <string.h>
#include "t1imager.h"
#include "util.h"
#include "fontfcn.h"
#include "fontmisc.h"

Go to the source code of this file.

Functions

xobject Type1Char ()
boolean Init_BuiltInEncoding ()
int SearchDictName (psdict *dictP, psobj *keyP)
boolean initFont ()
void resetFont (char *env)
int readFont (char *env)
xobject fontfcnB (XYspace S, unsigned char *code, int *lenP, int *mode)
Bool fontfcnA (char *env, int *mode)
void QueryFontLib (char *env, char *infoName, pointer infoValue, int *rcodeP)

Variables

char CurFontName [120]
char * CurFontEnv
char * vm_base = NULL
psfontFontP = NULL
psfont TheCurrentFont

Function Documentation

Bool fontfcnA ( char *  env,
int mode 
)

Definition at line 193 of file fontfcn.c.

{
  int rc;
 
  /* Has the FontP initialized?  If not, then   */
  /* Initialize  */
  if (FontP == NULL) {
    InitImager();
    if (!(initFont())) {
      /* we are really out of memory */
      *mode = SCAN_OUT_OF_MEMORY;
      return(FALSE);
    }
  }
 
  /* if the env is null, then use font already loaded */
 
  /* if the not same font name */
  if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {
    /* restore the virtual memory and eliminate old font, read new one */
    rc = readFont(env);
    if (rc != 0 ) {
      strcpy(CurFontName, "");    /* no font loaded */
      *mode = rc;
      return(FALSE);
    }
  }
  return(TRUE);
 
}

Here is the call graph for this function:

xobject fontfcnB ( XYspace  S,
unsigned char *  code,
int lenP,
int mode 
)

Definition at line 135 of file fontfcn.c.

{
#if 0
  path updateWidth();
#endif 
  psobj *charnameP; /* points to psobj that is name of character*/
  int   N;
  psdict *CharStringsDictP; /* dictionary with char strings     */
  psobj   CodeName;   /* used to store the translation of the name*/
  psobj  *SubrsArrayP;
  psobj  *theStringP;
 
  path  charpath;   /* the path for this character              */
 
  charnameP = &CodeName;
  charnameP->len = *lenP;
  charnameP->data.stringP = code;

  CharStringsDictP =  FontP->CharStringsP;
 
  /* search the chars string for this charname as key */
  N = SearchDictName(CharStringsDictP,charnameP);
  if (N<=0) {
    *mode = FF_PARSE_ERROR;
    return(NULL);
  }
  /* ok, the nth item is the psobj that is the string for this char */
  theStringP = &(CharStringsDictP[N].value);
 
  /* get the dictionary pointers to the Subrs  */
 
  SubrsArrayP = &(FontP->Subrs);
  /* scale the Adobe fonts to 1 unit high */
  S = Permanent(Scale(S, 1.0 , 1.0));
  /* call the type 1 routine to rasterize the character     */
  charpath = Type1Char(FontP,S,theStringP,SubrsArrayP,NULL,
               FontP->BluesP , mode);
  Destroy(S);
  /* if Type1Char reported an error, then return */
  if ( *mode == FF_PARSE_ERROR)  return(NULL);
  /* fill with winding rule unless path was requested */
  if (*mode != FF_PATH) {
    charpath =  Interior(charpath,WINDINGRULE+CONTINUITY);
  }
  return(charpath);
}

Here is the call graph for this function:

Definition at line 269 of file scanfont.c.

{
  StdEncArrayP = MakeEncodingArrayP(StdEnc);
  if (StdEncArrayP==NULL)
    return( FALSE);
  else
    return( TRUE);
}

Definition at line 83 of file fontfcn.c.

{

  if (!(vm_init())) return(FALSE);
  vm_base = vm_next_byte();
  if (!(Init_BuiltInEncoding())) return(FALSE);
  strcpy(CurFontName, "");    /* iniitialize to none */
  FontP = &TheCurrentFont;
  FontP->vm_start = vm_next_byte();
  FontP->FontFileName.len = 0;
  FontP->FontFileName.data.valueP = CurFontName;
  return(TRUE);
}

Here is the call graph for this function:

void QueryFontLib ( char *  env,
char *  infoName,
pointer  infoValue,
int rcodeP 
)

Definition at line 235 of file fontfcn.c.

{
  int rc,N,i;
  psdict *dictP;
  psobj  nameObj;
  psobj  *valueP;
 
  /* Has the FontP initialized?  If not, then   */
  /* Initialize  */
  if (FontP == NULL) {
    InitImager();
    if (!(initFont())) {
      *rcodeP = 1;
      return;
    }
  }
  /* if the env is null, then use font already loaded */
  /* if the not same font name, reset and load next font */
  if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {
    /* restore the virtual memory and eliminate old font */
    rc = readFont(env);
    if (rc != 0 ) {
      strcpy(CurFontName, "");    /* no font loaded */
      *rcodeP = 1;
      return;
    }
  }
  dictP = FontP->fontInfoP;
  objFormatName(&nameObj,strlen(infoName),infoName);
  N = SearchDictName(dictP,&nameObj);
  /* if found */
  if ( N > 0 ) {
    *rcodeP = 0;
    switch (dictP[N].value.type) {
       case OBJ_ARRAY:
         valueP = dictP[N].value.data.arrayP;
         if (strcmp(infoName,"FontMatrix") == 0) {
           /* 6 elments, return them as floats      */
           for (i=0;i<6;i++) {
             if (valueP->type == OBJ_INTEGER )
               ((float *)infoValue)[i] = valueP->data.integer;
             else
               ((float *)infoValue)[i] = valueP->data.real;
            valueP++;
           }
         }
         if (strcmp(infoName,"FontBBox") == 0) {
           /* 4 elments for Bounding Box.  all integers   */
           for (i=0;i<4;i++) {
             ((int *)infoValue)[i] = valueP->data.integer;
             valueP++;
           }
         break;
       case OBJ_INTEGER:
       case OBJ_BOOLEAN:
         *((int *)infoValue) = dictP[N].value.data.integer;
         break;
       case OBJ_REAL:
         *((float *)infoValue) = dictP[N].value.data.real;
         break;
       case OBJ_NAME:
       case OBJ_STRING:
         *((char **)infoValue) =  dictP[N].value.data.valueP;
         break;
       default:
         *rcodeP = 1;
         break;
     }
   }
  }
  else *rcodeP = 1;
}

Here is the call graph for this function:

int readFont ( char *  env)

Definition at line 123 of file fontfcn.c.

{
  int rcode;
 
  /* restore the virtual memory and eliminate old font */
  resetFont(env);
  /* This will load the font into the FontP */
  rcode = scan_font(FontP);
  return(rcode);
}

Here is the call graph for this function:

void resetFont ( char *  env)

Definition at line 97 of file fontfcn.c.

{
 
  vm_next =  FontP->vm_start;
  vm_free = vm_size - ( vm_next - vm_base);
  FontP->Subrs.len = 0;
  FontP->Subrs.data.stringP = NULL;
  FontP->CharStringsP = NULL;
  FontP->Private = NULL;
  FontP->fontInfoP = NULL;
  FontP->BluesP = NULL;
  /* This will load the font into the FontP */
  strcpy(CurFontName,env);
  FontP->FontFileName.len = strlen(CurFontName);
  FontP->FontFileName.data.valueP = CurFontName;
 
}

Here is the call graph for this function:

int SearchDictName ( psdict dictP,
psobj keyP 
)

Definition at line 62 of file fontfcn.c.

{
  int i,n;
 
 
  n =  dictP[0].key.len;
  for (i=1;i<=n;i++) {          /* scan the intire dictionary */
    if (
        (dictP[i].key.len  == keyP->len )
        &&
        (strncmp(dictP[i].key.data.valueP,
                 keyP->data.valueP,
                 keyP->len) == 0
        )
       ) return(i);
  }
  return(0);
}

Here is the call graph for this function:


Variable Documentation

char* CurFontEnv

Definition at line 50 of file fontfcn.c.

char CurFontName[120]

Definition at line 49 of file fontfcn.c.

Definition at line 52 of file fontfcn.c.

Definition at line 53 of file fontfcn.c.

char* vm_base = NULL

Definition at line 51 of file fontfcn.c.