Back to index

tetex-bin  3.0
Functions
dvi.h File Reference
#include "error.h"
#include "numbers.h"
#include "pdfdev.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

error_t dvi_init (char *dvi_filename, char *pdf_filename, double mag, double x_offset, double y_offset)
void dvi_set_verbose (void)
void dvi_set_debug (void)
void dvi_close (void)
double dvi_tell_mag (void)
double dvi_unit_size (void)
void dvi_vf_init (int dev_font_id)
void dvi_vf_finish (void)
void dvi_set_font (int font_id)
void dvi_set (SIGNED_QUAD ch)
void dvi_rule (SIGNED_QUAD width, SIGNED_QUAD height)
void dvi_right (SIGNED_QUAD x)
void dvi_put (SIGNED_QUAD ch)
void dvi_push (void)
void dvi_pop (void)
void dvi_w0 (void)
void dvi_w (SIGNED_QUAD ch)
void dvi_x0 (void)
void dvi_x (SIGNED_QUAD ch)
void dvi_down (SIGNED_QUAD y)
void dvi_y (SIGNED_QUAD ch)
void dvi_y0 (void)
void dvi_z (SIGNED_QUAD ch)
void dvi_z0 (void)
double dvi_dev_xpos (void)
double dvi_dev_ypos (void)
unsigned dvi_npages (void)
void dvi_do_page (unsigned n)
int dvi_locate_font (char *name, spt_t ptsize)
void dvi_compute_boxes (unsigned char boxes)

Function Documentation

Definition at line 1181 of file dvi.c.

{
  int i;
  /* We add comment in dvi_close instead of dvi_init so user has
     a change to overwrite it.  The docinfo dictionary is
     treated as a write-once record */

  /* Do some house cleaning */
  MFCLOSE (dvi_file);
  for (i=0; i<num_def_fonts; i++) {
    RELEASE (def_fonts[i].name);
  }
  if (def_fonts)
    RELEASE (def_fonts);
  RELEASE (page_loc);
  num_loaded_fonts = 0;
  if (loaded_fonts)
    RELEASE (loaded_fonts);
  num_pages = 0;
  dvi_file = NULL;
  dev_close_all_fonts();
  vf_close_all_fonts();
  tfm_close_all();
  dev_close();
  pdf_doc_close();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dvi_compute_boxes ( unsigned char  boxes)

Definition at line 100 of file dvi.c.

{
  compute_boxes = boxes;
}

Here is the caller graph for this function:

double dvi_dev_xpos ( void  )

Definition at line 396 of file dvi.c.

                          {
  return dvi_state.h*dvi2pts;
}

Here is the caller graph for this function:

double dvi_dev_ypos ( void  )

Definition at line 400 of file dvi.c.

{
  return -(dvi_state.v*dvi2pts);
}

Here is the caller graph for this function:

void dvi_do_page ( unsigned  n)

Definition at line 948 of file dvi.c.

{
  unsigned char opcode;
  /* Position to beginning of page */
  if (debug) fprintf (stderr, "Seeking to page %d @ %ld\n", n,
                       page_loc[n]);
  seek_absolute (dvi_file, page_loc[n]);
  dvi_stack_depth = 0;
  for (;;) {
    /* The most likely opcodes are individual setchars.  These are
       buffered for speed */
    s_len = 0;
    while ((opcode = fgetc (dvi_file)) <= SET_CHAR_127 &&
          s_len < S_BUFFER_SIZE) {
      s_buffer[s_len++] = opcode;
    }
    if (s_len > 0) {
      do_string (s_buffer, s_len);
    }
    if (s_len == S_BUFFER_SIZE)
      continue;
    /* If we are here, we have an opcode that is something
       other than SET_CHAR */
    if (opcode >= FNT_NUM_0 && opcode <= FNT_NUM_63) {
      do_fnt (opcode - FNT_NUM_0);
      continue;
    }
    switch (opcode)
      {
      case SET1:
       do_set1();
       break;
      case SET2:
       do_set2();
       break;
      case SET3:
      case SET4:
       ERROR ("Multibyte (>16 bits) character in DVI file.  I can't handle this!");
       break;
      case SET_RULE:
       do_setrule();
       break;
      case PUT1:
       do_put1();
       break;
      case PUT2:
       do_put2();
       break;
      case PUT3:
      case PUT4:
       ERROR ("Multibyte character (>16 bits) in DVI file.  I can't handle this!");
       break;
      case PUT_RULE:
       do_putrule();
       break;
      case NOP:
       break;
      case BOP:
       do_bop();
       break;
      case EOP:
       do_eop();
       return;
      case PUSH:
       dvi_push();
       /* The following line needs to go here instead of in
          dvi_push() since logical structure of document is
          oblivous to virtual fonts. For example the last line on a
          page could be at stack level 3 and the page footer should
          be at stack level 3.  However, if the page footer contains
          virtual fonts (or other nested constructions), it could
          fool the link breaker into thinking it was a continuation
          of the link */
       dev_stack_depth (dvi_stack_depth);
       break;
      case POP:
       dvi_pop();
       /* Above explanation holds for following line too */
       dev_stack_depth (dvi_stack_depth);
       break;
      case RIGHT1:
       do_right1();
       break;
      case RIGHT2:
       do_right2();
       break;
      case RIGHT3:
       do_right3();
       break;
      case RIGHT4:
       do_right4();
       break;
      case W0:
       dvi_w0();
       break;
      case W1:
       do_w1();
       break;
      case W2:
       do_w2();
       break;
      case W3:
       do_w3();
       break;
      case W4:
       do_w4();
       break;
      case X0:
       dvi_x0();
       break;
      case X1:
       do_x1();
       break;
      case X2:
       do_x2();
       break;
      case X3:
       do_x3();
       break;
      case X4:
       do_x4();
       break;
      case DOWN1:
       do_down1();
       break;
      case DOWN2:
       do_down2();
       break;
      case DOWN3:
       do_down3();
       break;
      case DOWN4:
       do_down4();
       break;
      case Y0:
       dvi_y0();
       break;
      case Y1:
       do_y1();
       break;
      case Y2:
       do_y2();
       break;
      case Y3:
       do_y3();
       break;
      case Y4:
       do_y4();
       break;
      case Z0:
       dvi_z0();
       break;
      case Z1:
       do_z1();
       break;
      case Z2:
       do_z2();
       break;
      case Z3:
       do_z3();
       break;
      case Z4:
       do_z4();
       break;
      case FNT1:
       do_fnt1();
       break;
      case FNT2:
       do_fnt2();
       break;
      case FNT3:
       do_fnt3();
       break;
      case FNT4:
       do_fnt4();
       break;
      case XXX1:
       do_xxx1();
       break;
      case XXX2:
       do_xxx2();
       break;
      case XXX3:
       do_xxx3();
       break;
      case XXX4:
       do_xxx4();
       break;
      case FNT_DEF1:
       do_fntdef1();
       break;
      case FNT_DEF2:
       do_fntdef2();
       break;
      case FNT_DEF3:
       do_fntdef3();
       break;
      case FNT_DEF4:
       do_fntdef4();
       break;
      case PRE:
      case POST:
      case POST_POST:
       ERROR("Unexpected preamble or postamble in dvi file");
       break;
      default:
       ERROR("Unexpected opcode or DVI file ended prematurely");
      }
  }
}

Here is the caller graph for this function:

Definition at line 416 of file dvi.c.

{
  dvi_state.v += y;
}

Here is the caller graph for this function:

error_t dvi_init ( char *  dvi_filename,
char *  pdf_filename,
double  mag,
double  x_offset,
double  y_offset 
)

Definition at line 1160 of file dvi.c.

{
  if (!(dvi_file = MFOPEN (dvi_filename, FOPEN_RBIN_MODE))) {
    ERROR ("dvi_init:  Specified DVI file doesn't exist");
    return (FATAL_ERROR);
  }
  /* DVI files are most easily read backwards by searching
     for post_post and then post opcode */
  find_post ();
  get_dvi_info();
  do_scales(mag);
  dev_init(dvi2pts, x_offset, y_offset);
  get_page_info();
  pdf_doc_init (pdf_filename);
  get_comment();
  get_dvi_fonts();
  clear_state();
  return (NO_ERROR);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int dvi_locate_font ( char *  name,
spt_t  ptsize 
)

Definition at line 356 of file dvi.c.

{
  int thisfont;
  int font_id;
  if (debug) {
    fprintf (stderr, "dvi_locate_font: fontname: (%s) ptsize: %ld, dvi_id: %d\n",
            tex_name, ptsize, num_loaded_fonts);
  }
  if (verbose)
    fprintf (stderr, "<%s@%.2fpt", tex_name, ptsize*dvi2pts);
  need_more_fonts (1);
  /* This routine needs to be recursive/reentrant.  Load current high water
     mark into an automatic variable  */
  thisfont = num_loaded_fonts++;
  loaded_fonts[thisfont].tfm_id = tfm_open (tex_name);
  loaded_fonts[thisfont].source = VF; /* This will be reset later if 
                                 it was really generated by the
                                 dvi file */
  font_id = vf_locate_font (tex_name, ptsize);
  loaded_fonts[thisfont].font_id = font_id;
  if (loaded_fonts[thisfont].font_id >= 0) {
    if (verbose)
      fprintf (stderr, "(VF)");
    loaded_fonts[thisfont].type = VIRTUAL;
  } else {
    loaded_fonts[thisfont].type = PHYSICAL;
    font_id = dev_locate_font (tex_name, ptsize);
    loaded_fonts[thisfont].font_id = font_id;
    if (loaded_fonts[thisfont].font_id < 0) {
      fprintf (stderr, "%s: Can't locate a Type 1, TTF, PK, or virtual font file\n", tex_name);
      ERROR ("Not sure how to proceed.  For now this is fatal\n\
Maybe in the future, I'll substitute some other font.");
    }
  }
  loaded_fonts[thisfont].size = ptsize;
  if (verbose)
    fprintf (stderr, ">");
  return (thisfont);
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned dvi_npages ( void  )

Definition at line 110 of file dvi.c.

{
  return num_pages;
}

Here is the caller graph for this function:

void dvi_pop ( void  )

Definition at line 600 of file dvi.c.

{
  if (debug) {
    fprintf (stderr, "Popping off stack of depth %d\n",
            dvi_stack_depth);
  }
  if (dvi_stack_depth > 0) {
    dvi_state = dvi_stack[--dvi_stack_depth];
  } else
    ERROR ("dvi_pop: Tried to pop an empty stack");
  do_moveto (dvi_state.h, dvi_state.v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 587 of file dvi.c.

{
  if (debug) {
    fprintf (stderr, "Pushing onto stack of depth %d\n",
            dvi_stack_depth);
  }
  if (dvi_stack_depth < DVI_MAX_STACK_DEPTH) {
    dvi_stack[dvi_stack_depth++] = dvi_state;
  }
  else
    ERROR ("DVI stack exceeded");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 502 of file dvi.c.

{
  spt_t width, height = 0, depth = 0;
  struct loaded_font *p;
  unsigned char lch;
  if (current_font < 0) {
    ERROR ("dvi_put:  No font selected");
  }
  p = loaded_fonts+current_font;
  switch (p->type) {
  case PHYSICAL:
    width = tfm_get_fw_width (p->tfm_id, ch);
    width = sqxfw (p->size, width);
    /* Treat a single character as a one byte string and use the
       string routine.  The possibly multi-byte character must
       be converted to a single-byte string */
    if (ch > 255) {
      ERROR ("Tried to set a multibyte character in a non-virtual font");
    }
    lch = (unsigned char) ch;
    dev_set_string (dvi_state.h, -dvi_state.v, &lch, 1, width, p->font_id);
    if (compute_boxes) {
      height = tfm_get_fw_height (p->tfm_id, ch);
      depth = tfm_get_fw_depth (p->tfm_id, ch);
      height = sqxfw (p->size, height);
      depth = sqxfw (p->size, depth);
      dev_expand_box (width, height, depth);
    }
    break;
  case VIRTUAL:    
    vf_set_char (ch, p->font_id);
    break;
  }
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 411 of file dvi.c.

{
  dvi_state.h += x;
}

Here is the caller graph for this function:

void dvi_rule ( SIGNED_QUAD  width,
SIGNED_QUAD  height 
)

Definition at line 539 of file dvi.c.

{
  do_moveto (dvi_state.h, dvi_state.v);
  dev_rule (dvi_state.h, -dvi_state.v,
           width, height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 461 of file dvi.c.

{
  spt_t width, height = 0, depth = 0;
  struct loaded_font *p;
  unsigned char lch;
  if (current_font < 0) {
    ERROR ("dvi_set:  No font selected");
  }
  /* The division by dvi2pts seems strange since we actually know the
     "dvi" size of the fonts contained in the DVI file.  In other
     words, we converted from DVI units to pts and back again!
     The problem comes from fonts defined in VF files where we don't know the DVI
     size.  It's keeping me sane to keep *point sizes* of *all* fonts in
     the dev.c file and convert them back if necessary */ 
  p = loaded_fonts+current_font;
  width = tfm_get_fw_width (p->tfm_id, ch);
  width = sqxfw (p->size, width);
  switch (p->type) {
  case PHYSICAL:
    if (ch > 255) {
      ERROR ("Tried to set a multibyte character in a non-virtual font");
    }
    lch = (unsigned char) ch;
    dev_set_string (dvi_state.h, -dvi_state.v, &lch, 1, width, p->font_id);
    if (compute_boxes) {
      height = tfm_get_fw_height (p->tfm_id, ch);
      depth = tfm_get_fw_depth (p->tfm_id, ch);
      height = sqxfw (p->size, height);
      depth = sqxfw (p->size, depth);
      dev_expand_box (width, height, depth);
    }
    break;
  case VIRTUAL:
    {
      vf_set_char (ch, p->font_id);
      break;
    }
  }
  dvi_state.h += width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 105 of file dvi.c.

{
  debug = 1;
}
void dvi_set_font ( int  font_id)

Definition at line 816 of file dvi.c.

Here is the caller graph for this function:

Definition at line 93 of file dvi.c.

{
  if (verbose < 255) {
  verbose += 1;
  }
}

Here is the caller graph for this function:

double dvi_tell_mag ( void  )

Definition at line 188 of file dvi.c.

{
  return total_mag;
}

Here is the caller graph for this function:

double dvi_unit_size ( void  )

Definition at line 351 of file dvi.c.

{
  return dvi2pts;
}

Here is the caller graph for this function:

Definition at line 1231 of file dvi.c.

{
  dvi_pop();
  if (num_saved_fonts > 0) 
    current_font = saved_dvi_font[--num_saved_fonts];
  else
    ERROR ("Tried to pop an empty font stack");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dvi_vf_init ( int  dev_font_id)

Definition at line 1218 of file dvi.c.

{
  dvi_push ();
  dvi_state.w = 0; dvi_state.x = 0;
  dvi_state.y = 0; dvi_state.z = 0;
  if (num_saved_fonts < MAX_VF_NESTING) {
    saved_dvi_font[num_saved_fonts++] = current_font;
  } else
    ERROR ("Virtual fonts nested too deeply!");
  current_font = dev_font_id;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 634 of file dvi.c.

{
  dvi_state.w = ch;
  dvi_right (ch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dvi_w0 ( void  )

Definition at line 640 of file dvi.c.

{
  dvi_right (dvi_state.w);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 665 of file dvi.c.

{
  dvi_state.x = ch;
  dvi_right (ch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dvi_x0 ( void  )

Definition at line 671 of file dvi.c.

{
  dvi_right (dvi_state.x);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 716 of file dvi.c.

{
  dvi_state.y = ch;
  dvi_down (ch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dvi_y0 ( void  )

Definition at line 722 of file dvi.c.

{
  dvi_down (dvi_state.y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 747 of file dvi.c.

{
  dvi_state.z = ch;
  dvi_down (ch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dvi_z0 ( void  )

Definition at line 753 of file dvi.c.

{
  dvi_down (dvi_state.z);
}

Here is the call graph for this function:

Here is the caller graph for this function: