Back to index

tetex-bin  3.0
Classes | Typedefs | Functions | Variables
font_routines.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  font_struct
struct  move_struct

Typedefs

typedef struct font_struct font
typedef struct move_struct move

Functions

void clear_map_font (int)
void init_map_font (int)
void set_font_name (string)
void set_font_area (string)
void set_font_check_sum (unsigned)
void set_font_at (fix)
void set_font_design_size (fix)
void set_vtitle (string)
void init_map (void)
void end_map (void)
void set_select_font (unsigned)
void set_set_char (unsigned)
void set_set_rule (fix, fix)
void set_move (unsigned, fix)
void set_push (void)
void set_pop (void)
void set_special (string)
void set_special_hex (string)
unsigned get_hex (unsigned char)
void append_command (unsigned, unsigned)
void append_command_2 (unsigned, unsigned, unsigned, unsigned)
void append_to_packet_fix (unsigned, fix)
void move_table_init (void)
void font_table_init (void)
void packet_table_init (void)
void packet_table_end (void)
void out_ovf (unsigned)
void out_ovf_4 (unsigned)
int ovf_get_arg (unsigned char **, unsigned, boolean)
void input_command (unsigned *, int *)
void input_ovf_fonts (void)
void input_ovf_chars (void)
void input_ovf_file (void)
void in_ovf_4 (int *)
void in_ovf_unsigned_4 (unsigned *)

Variables

fontfont_table
unsigned no_fonts
unsigned cur_font_index
fontcur_font
unsigned char * cur_packet
string vtitle
unsigned packet_table_size
unsigned char * packet_table
unsigned packet_ptr

Class Documentation

struct font_struct

Definition at line 24 of file font_routines.h.

Class Members
string font_area
fix font_at
boolean font_at_defined
unsigned font_checksum
boolean font_checksum_defined
double font_dsize
boolean font_dsize_defined
string font_name
int font_number
unsigned char * ovf_packet
unsigned ovf_packet_length
struct move_struct

Definition at line 38 of file font_routines.h.

Class Members
unsigned h
unsigned v
fix wfix
fix xfix
fix yfix
fix zfix

Typedef Documentation

typedef struct font_struct font
typedef struct move_struct move

Function Documentation

void append_command ( unsigned  ,
unsigned   
)

Definition at line 258 of file font_routines.c.

{
    if ((cmd_1 != DVI_SET_1) && (cmd_1 != DVI_FNT_1) &&
        (cmd_1 != DVI_FNT_DEF_1) && (cmd_1 != DVI_XXX_1)) {
        internal_error_1("append_command (cmd_1=%d)", cmd_1);
    }
    if (actual < 0x100) {
        append_to_packet(cmd_1);
        append_to_packet(actual);
    } else if (actual < 0x10000) {
        append_to_packet(cmd_1 + 1);
        append_to_packet(actual >> 8);
        append_to_packet(actual & 0xff);
    } else if (actual < 0x1000000) {
        append_to_packet(cmd_1 + 2);
        append_to_packet(actual >> 16);
        append_to_packet((actual >> 8) & 0xff);
        append_to_packet(actual & 0xff);
    } else {
        append_to_packet(cmd_1 + 3);
/* BUG: Should deal with negative numbers */
        append_to_packet((actual >> 24) & 0xff);
        append_to_packet((actual >> 16) & 0xff);
        append_to_packet((actual >> 8) & 0xff);
        append_to_packet(actual & 0xff);
    }
    
}

Here is the call graph for this function:

Here is the caller graph for this function:

void append_command_2 ( unsigned  ,
unsigned  ,
unsigned  ,
unsigned   
)

Definition at line 246 of file font_routines.c.

{
    if ((actual < 0) || (actual > 0x7fffffff))
        internal_error_1("append_command (actual=%d)", actual);
    if ((cmd_0 + actual) <= max_n)
        append_to_packet(cmd_0 + actual);
    else
        append_command(cmd_1, actual);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void append_to_packet_fix ( unsigned  ,
fix   
)

Definition at line 356 of file font_routines.c.

{
    unsigned k;
    unsigned negative=FALSE;
    int t;

    if (design_units != UNITY)
        fval = zround(((double)fval) / ((double)design_units) * 1048576.0);
    if (fval<0) {
        negative = TRUE;
        fval = -1 - fval;
    }
    if (cmd == 0) {
        k = 4; t = 0x1000000;
    } else {
        t = 0x7f; k = 1;
        while (fval>t) {
            t = (t<<8) | 0xff; k++;
        }
        append_to_packet(cmd+k-1); t = t/0x80 + 1;
    }
    do {
        if (negative == TRUE) {
            append_to_packet(0xff - fval/t);
            fval = (fval/t)*t + t-1-fval;
            negative = FALSE;
        } else {
            append_to_packet((fval/t) & 0xff);
        }
        k--; t = t >> 8; 
    } while (k != 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 67 of file font_routines.c.

{
    if (cur_font==NULL) internal_error_0("clear_map_font");
    cur_font->font_number = font_number;
    cur_font->font_name = NULL;
    cur_font->font_area = NULL;
    cur_font->font_at = 0;
    cur_font->font_checksum = 0;
    cur_font->font_dsize = 10*UNITY;
    cur_font->font_at_defined = FALSE;
    cur_font->font_checksum_defined = FALSE;
    cur_font->font_dsize_defined = FALSE;
    cur_font->ovf_packet = NULL;
    cur_font->ovf_packet_length = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void end_map ( void  )

Definition at line 238 of file font_routines.c.

{
    current_character->ovf_packet = cur_packet;
    current_character->ovf_packet_length = packet_ptr;
    packet_table_end();
}

Here is the call graph for this function:

Definition at line 49 of file font_routines.c.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned get_hex ( unsigned  char)

Definition at line 436 of file font_routines.c.

{
    if ((c>='0') || (c<='9')) return(c-'0');
    if ((c>='A') || (c<='F')) return(c-'A'+10);
    internal_error_1("get_hex (a=%c)", c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void in_ovf_4 ( int )

Definition at line 626 of file font_routines.c.

{
    *value = (((*ovf_ptr)    & 0xff) << 24) |
             (((*(ovf_ptr+1)) & 0xff) << 16) |
             (((*(ovf_ptr+2)) & 0xff) <<  8) |
              ((*(ovf_ptr+3)) & 0xff);
    ovf_ptr += 4;
}

Here is the caller graph for this function:

void in_ovf_unsigned_4 ( unsigned *  )

Definition at line 636 of file font_routines.c.

{
    *value = (((*ovf_ptr)    & 0xff) << 24) |
             (((*(ovf_ptr+1)) & 0xff) << 16) |
             (((*(ovf_ptr+2)) & 0xff) <<  8) |
              ((*(ovf_ptr+3)) & 0xff);
    ovf_ptr += 4;
}

Here is the caller graph for this function:

Definition at line 231 of file font_routines.c.

Here is the call graph for this function:

Definition at line 84 of file font_routines.c.

{
    unsigned i=0;

    while (i<no_fonts) {
        if (font_number == font_table[i].font_number) {
             warning_1("MAPFONT index (D %d) previously defined; "
              "old definition ignored", font_number);
            cur_font = &font_table[i];
            if (cur_font->font_area != NULL) 
                free(cur_font->font_area);
            if (cur_font->font_name != NULL) 
                free(cur_font->font_name);
            if (cur_font->ovf_packet != NULL) 
                free(cur_font->ovf_packet);
            clear_map_font(font_number);
            break;
        }
        i++;
    }
    if (i==no_fonts) {
        font_no_incr();
        cur_font = &font_table[i];
        clear_map_font(font_number);
    }
    packet_table_init();
    append_command(DVI_FNT_DEF_1, i);
    cur_font_index = i;
    cur_font = &font_table[i];
    cur_font->ovf_packet = cur_packet;
    cur_font->ovf_packet_length = packet_ptr;
    packet_table_end();

}

Here is the call graph for this function:

void input_command ( unsigned *  ,
int  
)

Definition at line 310 of file font_routines.c.

{
    unsigned the_cmd = *ovf_ptr & 0xff;

    ovf_ptr++;
    if ((the_cmd>=DVI_SET_CHAR_0) && (the_cmd<=DVI_SET_CHAR_127)) {
       (*cmd)=DVI_SET_1;
       (*actual) = the_cmd;
    } else if ((the_cmd>=DVI_SET_1) && (the_cmd<=DVI_SET_4)) {
       (*cmd)=DVI_SET_1; 
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_SET_1 + 1, FALSE);
    } else if ((the_cmd>=DVI_FNT_NUM_0) && (the_cmd<=DVI_FNT_NUM_63)) {
       (*cmd)=DVI_FNT_1;
       (*actual) = the_cmd - DVI_FNT_NUM_0;
    } else if ((the_cmd>=DVI_FNT_1) && (the_cmd<=DVI_FNT_4)) {
       (*cmd)=DVI_FNT_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_FNT_1 + 1, FALSE);
    } else if ((the_cmd>=DVI_FNT_DEF_1) && (the_cmd<=DVI_FNT_DEF_4)) {
       (*cmd)=DVI_FNT_DEF_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_FNT_DEF_1 + 1, FALSE);
    } else if ((the_cmd>=DVI_XXX_1) && (the_cmd<=DVI_XXX_4)) {
       (*cmd)=DVI_XXX_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_XXX_1 + 1, FALSE);
    } else if ((the_cmd>=DVI_RIGHT_1) && (the_cmd<=DVI_RIGHT_4)) {
       (*cmd)=DVI_RIGHT_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_RIGHT_1 + 1, TRUE);
    } else if ((the_cmd>=DVI_DOWN_1) && (the_cmd<=DVI_DOWN_4)) {
       (*cmd)=DVI_DOWN_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_DOWN_1 + 1, TRUE);
    } else if ((the_cmd>=DVI_W_1) && (the_cmd<=DVI_W_4)) {
       (*cmd)=DVI_W_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_W_1 + 1, TRUE);
    } else if ((the_cmd>=DVI_X_1) && (the_cmd<=DVI_X_4)) {
       (*cmd)=DVI_X_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_X_1 + 1, TRUE);
    } else if ((the_cmd>=DVI_Y_1) && (the_cmd<=DVI_Y_4)) {
       (*cmd)=DVI_Y_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_Y_1 + 1, TRUE);
    } else if ((the_cmd>=DVI_Z_1) && (the_cmd<=DVI_Z_4)) {
       (*cmd)=DVI_Z_1;
       (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_Z_1 + 1, TRUE);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 732 of file font_routines.c.

{
    int pl,cc,wd;

    while ((*ovf_ptr & 0xff) <= VF_LONG_CHAR) {
        if ((*ovf_ptr & 0xff) == VF_LONG_CHAR) {
            ovf_ptr++;
            in_ovf_4(&pl);
            in_ovf_4(&cc);
            in_ovf_4(&wd);
        } else {
            in_ovf(&pl);
            in_ovf(&cc);
            in_ovf_3(&wd);
        }
        ensure_existence(cc);
        current_secondary_character->ovf_packet_length = pl;
        current_secondary_character->ovf_packet = ovf_ptr;
        ovf_ptr += pl;
    }
    while (ovf_ptr < (ovf+length_ovf)) {
        if ((*ovf_ptr & 0xff) != DVI_POST)
            fatal_error_0("Not a VF or OVF file; final bytes should be 248");
        ovf_ptr++;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 662 of file font_routines.c.

{
    ovf_ptr = ovf;
    if ((*ovf_ptr & 0xff) != DVI_PRE)
       fatal_error_0("Not a VF or OVF file; first byte should be 247");
    ovf_ptr++;
    if ((*ovf_ptr & 0xff) != VF_ID)
       fatal_error_0("Not a VF or OVF file; second byte should be 202");
    ovf_ptr++;
    vtitle_length = *ovf_ptr & 0xff;
    ovf_ptr++;
    vtitle = (char *) xmalloc(vtitle_length+1);
    strncpy(vtitle, (const char *)ovf_ptr, vtitle_length);
    vtitle[vtitle_length] = '\0';
    ovf_ptr += vtitle_length;
    print_vtitle(vtitle);
    in_ovf_unsigned_4(&vf_check_sum);
    in_ovf_unsigned_4(&vf_design_size);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 684 of file font_routines.c.

{
    int cur_font_area_length;
    int cur_font_name_length;
    char *cur_font_name;
    char *cur_font_area;
    unsigned cur_font_check_sum;
    int cur_font_at;
    int cur_font_dsize;
    unsigned cmd;

    font_table_init();
    while (((*ovf_ptr & 0xff) >= DVI_FNT_DEF_1) &&
           ((*ovf_ptr & 0xff) <= DVI_FNT_DEF_4)) {
      cur_font_index = no_fonts;
      cur_font = &(font_table[cur_font_index]);
      font_no_incr();
      input_command(&cmd, &(cur_font->font_number));
      print_map_font(cur_font->font_number);
      in_ovf_unsigned_4(&cur_font_check_sum);
      cur_font_at = ovf_get_arg(&ovf_ptr, 4, FALSE);
      cur_font_dsize = ovf_get_arg(&ovf_ptr, 4, FALSE);
      in_ovf(&cur_font_area_length);
      in_ovf(&cur_font_name_length);
      cur_font_area = NULL;
      if (cur_font_area_length != 0) {
          cur_font_area = (char *)xmalloc(cur_font_area_length+1);
          strncpy(cur_font_area, (const char *)ovf_ptr, cur_font_area_length);
          cur_font_area[cur_font_area_length] = '\0';
          ovf_ptr += cur_font_area_length;
          print_font_area(cur_font_area);
      }
      cur_font_name = NULL;
      if (cur_font_name_length != 0) {
          cur_font_name = (char *)xmalloc(cur_font_name_length+1);
          strncpy(cur_font_name, (const char *)ovf_ptr, cur_font_name_length);
          cur_font_name[cur_font_name_length] = '\0';
          ovf_ptr += cur_font_name_length;
          print_font_name(cur_font_name);
      }
      print_font_check_sum(cur_font_check_sum);
      print_font_at(cur_font_at);
      print_font_design_size(cur_font_dsize);
      right();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 395 of file font_routines.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void out_ovf ( unsigned  )

Definition at line 555 of file font_routines.c.

{
    fputc(i,file_ovf);
    file_ovf_count++;
}

Here is the caller graph for this function:

void out_ovf_4 ( unsigned  )

Definition at line 562 of file font_routines.c.

{
    fputc(i>>24,        file_ovf);
    fputc((i>>16)&0xff, file_ovf);
    fputc((i>>8)&0xff,  file_ovf);
    fputc(i&0xff,       file_ovf);
    file_ovf_count += 4;
}

Here is the caller graph for this function:

int ovf_get_arg ( unsigned char **  ,
unsigned  ,
boolean   
)

Definition at line 290 of file font_routines.c.

{
    int a, b;

    if (k>4) internal_error_1("ovf_get_arg (k=%d)", k);
    a = b = (int) ((**ptr) & 0xff);
    (*ptr)++;
    if ((is_signed==TRUE) || (k==4)) { /* 4-byte numbers are signed */
       if (b > 0x7f) { a = a - 0x100; }
    }
    while (k>1) {
       b = (**ptr) & 0xff;
       (*ptr)++;
       a = 0x100 * a + b;
       k--;
    }
    return a;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 407 of file font_routines.c.

Here is the caller graph for this function:

Definition at line 204 of file font_routines.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file font_routines.c.

{
    if (cur_font==NULL) {
        internal_error_0("set_font_area");
    }
    if (cur_font->font_area != NULL) {
        warning_0("FONTAREA previously defined; old value ignored");
        free(cur_font->font_area);
        cur_font->font_area=NULL;
    }
    cur_font->font_area = area;
}

Here is the call graph for this function:

Definition at line 161 of file font_routines.c.

{
    if (cur_font==NULL) {
        internal_error_0("set_font_at");
    }
    if (cur_font->font_at_defined != FALSE) {
        warning_0("FONTAT previously defined; old value ignored");
    }
    cur_font->font_at = at;
    cur_font->font_at_defined = TRUE;
}

Here is the call graph for this function:

void set_font_check_sum ( unsigned  )

Definition at line 148 of file font_routines.c.

{
    if (cur_font==NULL) {
        internal_error_0("set_font_check_sum");
    }
    if (cur_font->font_checksum_defined != FALSE) {
        warning_0("FONTCHECKSUM previously defined; old value ignored");
    }
    cur_font->font_checksum = cs;
    cur_font->font_checksum_defined = TRUE;
}

Here is the call graph for this function:

Definition at line 174 of file font_routines.c.

{
    if (cur_font==NULL) {
        internal_error_0("set_font_design_size");
    }
    if (cur_font->font_dsize_defined != FALSE) {
        warning_0("FONTDSIZE previously defined; old value ignored");
    }
    cur_font->font_dsize = ds;
    cur_font->font_dsize_defined = TRUE;
}

Here is the call graph for this function:

Definition at line 120 of file font_routines.c.

{
    if (cur_font==NULL) {
        internal_error_0("set_font_name");
    }
    if (cur_font->font_name != NULL) {
        warning_0("FONTNAME previously defined; old value ignored");
        free(cur_font->font_name);
        cur_font->font_name=NULL;
    }
    cur_font->font_name = name;
}

Here is the call graph for this function:

void set_move ( unsigned  ,
fix   
)

Definition at line 468 of file font_routines.c.

{
    if (cur_move == NULL) {
        internal_error_0("set_move");
    }
    if (direction == M_LEFT) {
        fval = -fval;
        direction = M_RIGHT;
    } else if (direction == M_UP) {
        fval = -fval;
        direction = M_DOWN;
    }
    if (direction == M_RIGHT) { /* horizontal movement */
        if (cur_move->h == 0) {
            cur_move->wfix = fval; cur_move->h++;
            append_to_packet_fix(DVI_W_1, fval);
        } else if (fval == cur_move->wfix) {
            append_to_packet(DVI_W_0);
        } else if (cur_move->h == 1) {
            cur_move->xfix = fval; cur_move->h++;
            append_to_packet_fix(DVI_X_1, fval);
        } else if (fval == cur_move->xfix) {
            append_to_packet(DVI_X_0);
        } else {
            append_to_packet_fix(DVI_RIGHT_1, fval);
        }
    } else {                  /* vertical movement */
        if (cur_move->v == 0) {
            cur_move->yfix = fval; cur_move->v++;
            append_to_packet_fix(DVI_Y_1, fval);
        } else if (fval == cur_move->yfix) {
            append_to_packet(DVI_Y_0);
        } else if (cur_move->v == 1) {
            cur_move->zfix = fval; cur_move->v++;
            append_to_packet_fix(DVI_Z_1, fval);
        } else if (fval == cur_move->zfix) {
            append_to_packet(DVI_Z_0);
        } else {
            append_to_packet_fix(DVI_DOWN_1, fval);
        }
    }
}

Here is the call graph for this function:

void set_pop ( void  )

Definition at line 521 of file font_routines.c.

Here is the call graph for this function:

Definition at line 512 of file font_routines.c.

Here is the call graph for this function:

void set_select_font ( unsigned  )

Definition at line 444 of file font_routines.c.

Here is the call graph for this function:

void set_set_char ( unsigned  )

Definition at line 450 of file font_routines.c.

{
    if (cur_font==NULL) {
        warning_1("Character (H %X) cannot be typeset in undefined font", c);
    } else {
        append_command_2(DVI_SET_CHAR_0, DVI_SET_CHAR_127, DVI_SET_1, c);
    }
}   

Here is the call graph for this function:

void set_set_rule ( fix  ,
fix   
)

Definition at line 460 of file font_routines.c.

Here is the call graph for this function:

Definition at line 528 of file font_routines.c.

{
    unsigned len = strlen(special_string);
    unsigned i=0;

    append_command(DVI_XXX_1, len);
    for (i=0; i<len; i++) {
        append_to_packet(special_string[i]);
    }
}

Here is the call graph for this function:

Definition at line 540 of file font_routines.c.

{
    unsigned len = strlen(special_hex_string);
    unsigned i=0;

    append_command(DVI_XXX_1, len/2);
    for (i=0; i<len; i+=2) {
        append_to_packet(get_hex(special_hex_string[i])*16+
                         get_hex(special_hex_string[i+1]));
    }
}

Here is the call graph for this function:

Definition at line 189 of file font_routines.c.

{
    if (vtitle!=NULL) {
        warning_0("VTITLE previously defined; old value ignored");
        free(vtitle); vtitle = NULL;
    }
    vtitle = title;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 41 of file font_routines.c.

unsigned cur_font_index

Definition at line 42 of file font_routines.c.

unsigned char* cur_packet

Definition at line 57 of file font_routines.h.

Definition at line 38 of file font_routines.c.

unsigned no_fonts

Definition at line 40 of file font_routines.c.

unsigned packet_ptr

Definition at line 201 of file font_routines.c.

unsigned char* packet_table

Definition at line 199 of file font_routines.c.

Definition at line 198 of file font_routines.c.

Definition at line 186 of file font_routines.c.