Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions | Variables
dvipng.h File Reference
#include "config.h"
#include <gd.h>
#include "commands.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dvi_data
struct  dvi_color
struct  page_list
struct  filemmap
struct  encoding
struct  char_entry
struct  font_entry
struct  font_num
struct  internal_state

Defines

#define STRSIZE   255 /* stringsize for file specifications */
#define FIRSTFNTCHAR   0
#define LASTFNTCHAR   255
#define NFNTCHARS   LASTFNTCHAR+1
#define STACK_SIZE   100 /* DVI-stack size */
#define DEFAULT_GAMMA   1.0
#define MAKETEXPK   "mktexpk"
#define INT32_MIN   (-2147483647-1)
#define INT32_MAX   (2147483647)
#define true   (bool) 1
#define false   (bool) 0
#define MM_TO_PXL(x)   (int)(((x)*resolution*10)/254)
#define PT_TO_PXL(x)   (int)((int32_t)((x)*resolution*100l)/7224)
#define PT_TO_DVI(x)   (int32_t)((x)*65536l)
#define PIXROUND(num, den)   ((num)>0 ? ((num)+(den)/2)/(den) : -(((den)/2-(num))/(den)))
#define TEMPSTR(s, a)
#define DVI_TYPE   0
#define PAGE_POST   INT32_MAX
#define PAGE_LASTPAGE   INT32_MAX-1
#define PAGE_MAXPAGE   INT32_MAX-2 /* assume no pages out of this range */
#define PAGE_FIRSTPAGE   INT32_MIN
#define PAGE_MINPAGE   INT32_MIN+1 /* assume no pages out of this range */
#define FONT_TYPE_PK   1
#define FONT_TYPE_VF   2
#define FONT_TYPE_FT   3
#define FONT_TYPE_T1   4
#define EXTERN   extern
#define INIT(x)
#define BE_NONQUIET   1
#define BE_VERBOSE   (1<<1)
#define PARSE_STDIN   (1<<2)
#define EXPAND_BBOX   (1<<3)
#define TIGHT_BBOX   (1<<4)
#define CACHE_IMAGES   (1<<5)
#define RENDER_TRUECOLOR   (1<<6)
#define USE_FREETYPE   (1<<7)
#define USE_LIBT1   (1<<8)
#define REPORT_HEIGHT   (1<<9)
#define REPORT_DEPTH   (1<<10)
#define DVI_PAGENUM   (1<<11)
#define MODE_PICKY   (1<<12)
#define PAGE_GAVE_WARN   (1<<13)
#define PREVIEW_LATEX_TIGHTPAGE   (1<<14)
#define GIF_OUTPUT   (1<<15)
#define MODE_STRICT   (1<<16)
#define NO_GHOSTSCRIPT   (1<<17)
#define NO_GSSAFER   (1<<18)
#define BG_TRANSPARENT   (1<<19)
#define DEBUG_PRINT(a, b)
#define max(x, y)   if ((y)>(x)) x = y
#define min(x, y)   if ((y)<(x)) x = y
#define EXIT_FATAL   EXIT_FAILURE+1

Typedefs

typedef signed char int8_t
typedef unsigned char uint8_t
typedef short int16_t
typedef unsigned short uint16_t
typedef int int32_t
typedef unsigned int uint32_t
typedef long long int64_t
typedef unsigned long long uint64_t
typedef int bool
typedef int pixels
typedef int32_t subpixels
typedef int32_t dviunits

Functions

struct dvi_dataDVIOpen (char *, char *)
void DVIClose (struct dvi_data *)
bool DVIReOpen (struct dvi_data *)
struct page_listFindPage (struct dvi_data *, int32_t, bool)
struct page_listNextPage (struct dvi_data *, struct page_list *)
struct page_listPrevPage (struct dvi_data *, struct page_list *)
int SeekPage (struct dvi_data *, struct page_list *)
bool DVIFollowToggle (void)
unsigned char * DVIGetCommand (struct dvi_data *)
uint32_t CommandLength (unsigned char *)
bool DecodeArgs (int, char *[])
void DecodeString (char *)
bool MmapFile (char *filename, struct filemmap *fmmap)
void UnMmapFile (struct filemmap *fmmap)
void Message (int, char *fmt,...)
void Warning (char *fmt,...)
void Fatal (char *fmt,...)
int32_t SNumRead (unsigned char *, register int)
uint32_t UNumRead (unsigned char *, register int)
void CheckChecksum (uint32_t, uint32_t, const char *)
void InitPK (struct font_entry *newfontp)
void DonePK (struct font_entry *oldfontp)
void InitVF (struct font_entry *newfontp)
void DoneVF (struct font_entry *oldfontp)
void FontDef (unsigned char *, void *)
void ClearFonts (void)
void SetFntNum (int32_t, void *)
void FreeFontNumP (struct font_num *hfontnump)
bool ParsePages (char *)
void FirstPage (int32_t, bool)
void LastPage (int32_t, bool)
void ClearPpList (void)
void Reverse (bool)
struct page_listNextPPage (void *, struct page_list *)
void CreateImage (pixels width, pixels height)
void DestroyImage (void)
void DrawCommand (unsigned char *, void *)
void DrawPages (void)
void WriteImage (char *, int)
void LoadPK (int32_t, register struct char_entry *)
int32_t SetChar (int32_t)
dviunits SetGlyph (int32_t c, int32_t hh, int32_t vv)
void Gamma (double gamma)
int32_t SetVF (int32_t)
int32_t SetRule (int32_t, int32_t, int32_t, int32_t)
void SetSpecial (char *, int32_t, int32_t, int32_t)
void BeginVFMacro (struct font_entry *)
void EndVFMacro (void)
void handlepapersize (char *, int32_t *, int32_t *)
void stringrgb (char *colorstring, int *r, int *g, int *b)
void background (char *)
void initcolor (void)
void popcolor (void)
void pushcolor (char *)
void resetcolorstack (char *)
void StoreColorStack (struct page_list *tpagep)
void ReadColorStack (struct page_list *tpagep)
void StoreBackgroundColor (struct page_list *tpagep)
void ClearDvipsNam (void)
EXTERN bool makeTexPK INIT (_TRUE)
EXTERN uint32_t usermag INIT (0)
EXTERN struct font_entry *hfontptr INIT (NULL)
EXTERN uint32_t flags INIT (BE_NONQUIET|USE_FREETYPE|USE_LIBT1)
EXTERN int dpi INIT (100)
EXTERN bool userbordercolor INIT (FALSE)
EXTERN int32_t shrinkfactor INIT (4)
EXTERN int csp INIT (1)
EXTERN int exitcode INIT (EXIT_SUCCESS)

Variables

EXTERN struct internal_state current_state
EXTERN struct dvi_color
EXTERN struct font_entrycurrentfont

Class Documentation

struct dvi_data

Definition at line 148 of file dvipng.h.

Collaboration diagram for dvi_data:
Class Members
int32_t conv
uint32_t den
FILE * filep
struct font_num * fontnump
uint32_t mag
time_t mtime
char * name
struct dvi_data * next
uint32_t num
char * outname
struct page_list * pagelistp
int type
struct dvi_color

Definition at line 169 of file dvipng.h.

Class Members
int blue
int green
int red
struct page_list

Definition at line 173 of file dvipng.h.

Collaboration diagram for page_list:
Class Members
int32_t count
int csp
struct page_list * next
int offset
struct filemmap

Definition at line 199 of file dvipng.h.

Class Members
int fd
char * mmap
size_t size
struct encoding

Definition at line 21 of file encodings.c.

Collaboration diagram for encoding:
Class Members
char * charname
char * enc_name
pdf_obj * encoding_ref
char * glyphs
char * name
struct encoding * next
char * vec
struct char_entry

Definition at line 373 of file dvi2xx.h.

Class Members
unsigned char charsize
long4 cw
unsigned char * data
unsigned char flag_byte
pixels h
unsigned short height
uint32_t length
unsigned char * pkdata
dviunits tfmw
long4 tfmw
pixels w
struct char_entry where
unsigned short width
subpixels xOffset
short xOffset
subpixels yOffset
short yOffset
short yyOffset
struct font_num

Definition at line 293 of file dvipng.h.

Collaboration diagram for font_num:
Class Members
struct font_entry * fontp
int32_t k
struct font_num * next
struct internal_state

Definition at line 90 of file deflate.h.

Collaboration diagram for internal_state:
Class Members
ush bi_buf
int bi_valid
ush bl_count
long block_start
struct font_entry * currentfont
ushf * d_buf
Byte data_type
uch depth
int dummy
uInt good_match
uInt hash_bits
uInt hash_mask
uInt hash_shift
uInt hash_size
Posf * head
int heap
int heap_len
int heap_max
uInt ins_h
uchf * l_buf
int last_eob_len
int last_flush
uInt last_lit
int level
uInt lit_bufsize
uInt lookahead
int match_available
uInt match_length
uInt match_start
uInt matches
uInt max_chain_length
uInt max_lazy_match
Byte method
int nice_match
ulg opt_len
int pending
Bytef * pending_buf
ulg pending_buf_size
Bytef * pending_out
Posf * prev
uInt prev_length
IPos prev_match
ulg static_len
int status
int strategy
z_streamp strm
uInt strstart
uInt w_bits
uInt w_mask
uInt w_size
Bytef * window
ulg window_size
int wrap

Define Documentation

#define BE_NONQUIET   1

Definition at line 408 of file dvipng.h.

#define BE_VERBOSE   (1<<1)

Definition at line 409 of file dvipng.h.

#define BG_TRANSPARENT   (1<<19)

Definition at line 427 of file dvipng.h.

#define CACHE_IMAGES   (1<<5)

Definition at line 413 of file dvipng.h.

#define DEBUG_PRINT (   a,
  b 
)

Definition at line 446 of file dvipng.h.

#define DEFAULT_GAMMA   1.0

Definition at line 38 of file dvipng.h.

#define DVI_PAGENUM   (1<<11)

Definition at line 419 of file dvipng.h.

#define DVI_TYPE   0

Definition at line 147 of file dvipng.h.

#define EXIT_FATAL   EXIT_FAILURE+1

Definition at line 548 of file dvipng.h.

#define EXPAND_BBOX   (1<<3)

Definition at line 411 of file dvipng.h.

#define EXTERN   extern

Definition at line 350 of file dvipng.h.

#define false   (bool) 0

Definition at line 81 of file dvipng.h.

#define FIRSTFNTCHAR   0

Definition at line 32 of file dvipng.h.

#define FONT_TYPE_FT   3

Definition at line 253 of file dvipng.h.

#define FONT_TYPE_PK   1

Definition at line 251 of file dvipng.h.

#define FONT_TYPE_T1   4

Definition at line 254 of file dvipng.h.

#define FONT_TYPE_VF   2

Definition at line 252 of file dvipng.h.

#define GIF_OUTPUT   (1<<15)

Definition at line 423 of file dvipng.h.

#define INIT (   x)

Definition at line 351 of file dvipng.h.

#define INT32_MAX   (2147483647)

Definition at line 60 of file dvipng.h.

#define INT32_MIN   (-2147483647-1)

Definition at line 57 of file dvipng.h.

#define LASTFNTCHAR   255

Definition at line 33 of file dvipng.h.

#define MAKETEXPK   "mktexpk"

Definition at line 41 of file dvipng.h.

#define max (   x,
  y 
)    if ((y)>(x)) x = y

Definition at line 495 of file dvipng.h.

#define min (   x,
  y 
)    if ((y)<(x)) x = y

Definition at line 496 of file dvipng.h.

#define MM_TO_PXL (   x)    (int)(((x)*resolution*10)/254)

Definition at line 120 of file dvipng.h.

#define MODE_PICKY   (1<<12)

Definition at line 420 of file dvipng.h.

#define MODE_STRICT   (1<<16)

Definition at line 424 of file dvipng.h.

#define NFNTCHARS   LASTFNTCHAR+1

Definition at line 34 of file dvipng.h.

#define NO_GHOSTSCRIPT   (1<<17)

Definition at line 425 of file dvipng.h.

#define NO_GSSAFER   (1<<18)

Definition at line 426 of file dvipng.h.

#define PAGE_FIRSTPAGE   INT32_MIN

Definition at line 166 of file dvipng.h.

#define PAGE_GAVE_WARN   (1<<13)

Definition at line 421 of file dvipng.h.

#define PAGE_LASTPAGE   INT32_MAX-1

Definition at line 164 of file dvipng.h.

#define PAGE_MAXPAGE   INT32_MAX-2 /* assume no pages out of this range */

Definition at line 165 of file dvipng.h.

#define PAGE_MINPAGE   INT32_MIN+1 /* assume no pages out of this range */

Definition at line 167 of file dvipng.h.

#define PAGE_POST   INT32_MAX

Definition at line 163 of file dvipng.h.

#define PARSE_STDIN   (1<<2)

Definition at line 410 of file dvipng.h.

#define PIXROUND (   num,
  den 
)    ((num)>0 ? ((num)+(den)/2)/(den) : -(((den)/2-(num))/(den)))

Definition at line 129 of file dvipng.h.

#define PREVIEW_LATEX_TIGHTPAGE   (1<<14)

Definition at line 422 of file dvipng.h.

#define PT_TO_DVI (   x)    (int32_t)((x)*65536l)

Definition at line 122 of file dvipng.h.

#define PT_TO_PXL (   x)    (int)((int32_t)((x)*resolution*100l)/7224)

Definition at line 121 of file dvipng.h.

#define RENDER_TRUECOLOR   (1<<6)

Definition at line 414 of file dvipng.h.

#define REPORT_DEPTH   (1<<10)

Definition at line 418 of file dvipng.h.

#define REPORT_HEIGHT   (1<<9)

Definition at line 417 of file dvipng.h.

#define STACK_SIZE   100 /* DVI-stack size */

Definition at line 36 of file dvipng.h.

#define STRSIZE   255 /* stringsize for file specifications */

Definition at line 30 of file dvipng.h.

#define TEMPSTR (   s,
  a 
)
Value:
{ char* tmp=a; \
               if (tmp!=NULL) {\
                 s=alloca(strlen(tmp)+1);strcpy(s,tmp);free(tmp);\
               } else \
                 s=NULL;}

Definition at line 134 of file dvipng.h.

#define TIGHT_BBOX   (1<<4)

Definition at line 412 of file dvipng.h.

#define true   (bool) 1

Definition at line 80 of file dvipng.h.

#define USE_FREETYPE   (1<<7)

Definition at line 415 of file dvipng.h.

#define USE_LIBT1   (1<<8)

Definition at line 416 of file dvipng.h.


Typedef Documentation

typedef int bool

Definition at line 79 of file dvipng.h.

typedef int32_t dviunits

Definition at line 118 of file dvipng.h.

typedef short int16_t

Definition at line 48 of file dvipng.h.

typedef int int32_t

Definition at line 50 of file dvipng.h.

typedef long long int64_t

Definition at line 52 of file dvipng.h.

typedef signed char int8_t

Definition at line 46 of file dvipng.h.

typedef int pixels

Definition at line 116 of file dvipng.h.

typedef int32_t subpixels

Definition at line 117 of file dvipng.h.

typedef unsigned short uint16_t

Definition at line 49 of file dvipng.h.

typedef unsigned int uint32_t

Definition at line 51 of file dvipng.h.

typedef unsigned long long uint64_t

Definition at line 53 of file dvipng.h.

typedef unsigned char uint8_t

Definition at line 47 of file dvipng.h.


Function Documentation

void background ( char *  )

Definition at line 179 of file color.c.

{
  stringrgb(p, &cstack[0].red, &cstack[0].green, &cstack[0].blue);
  DEBUG_PRINT(DEBUG_COLOR,("\n  BACKGROUND:\t(%d %d %d) ",
                        cstack[0].red, cstack[0].green, cstack[0].blue));
}

Here is the call graph for this function:

void BeginVFMacro ( struct font_entry )

Definition at line 294 of file draw.c.

{
  if (sp >= STACK_SIZE)
    Fatal("stack overflow");
  stack[sp].h = h;
  stack[sp].v = v;
  stack[sp].w = w;
  stack[sp].x = x;
  stack[sp].y = y;
  stack[sp].z = z;
#ifndef NO_DRIFT
  stack[sp].hh = hh;
  stack[sp].vv = vv;
#endif
  sp++;
  w = x = y = z = 0;
  DEBUG_PRINT(DEBUG_DVI,("\n  START VF:\tPUSH, W = X = Y = Z = 0"));
  SetFntNum(currentvf->defaultfont,currentvf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CheckChecksum ( uint32_t  ,
uint32_t  ,
const char *   
)

Definition at line 28 of file font.c.

{
  /* Report a warning if both checksums are nonzero, they don't match,
     and the user hasn't turned it off.  */
  if (c1 && c2 && c1 != c2
#ifdef HAVE_LIBKPATHSEA
      && !kpse_tex_hush ("checksum")
#endif
      ) {
     Warning ("Checksum mismatch in %s", name) ;
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 107 of file color.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 335 of file font.c.

{
  struct font_entry *tmp;

  while(hfontptr!=NULL) {
    tmp=hfontptr->next;
    DoneFont(hfontptr);
    free(hfontptr);
    hfontptr=tmp;
  }
  if (dvi!=NULL)
    FreeFontNumP(dvi->fontnump);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 171 of file ppagelist.c.

{
  register struct pp_list *pl = ppages;

  while (pl) {
    ppages=ppages->next;
    free(pl);
    pl = ppages;
  }
  first=PAGE_FIRSTPAGE;
  last=PAGE_LASTPAGE;
  abspage = false;
  no_ppage=true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t CommandLength ( unsigned char *  )

Definition at line 222 of file dvi.c.

{ 
  /* generally 2^32+5 bytes max, but in practice 32 bit numbers suffice */
  uint32_t length=0;

  length = dvi_commandlength[*command];
  switch (*command)  {
  case XXX1: case XXX2: case XXX3: case XXX4: 
    length += UNumRead(command + 1,length - 1);
    break;
  case FNT_DEF1: case FNT_DEF2: case FNT_DEF3: case FNT_DEF4: 
    length += *(command + length - 1) + *(command + length - 2);
    break;
  case PRE: 
    length += *(command + length - 1);
    break;
  }
  return(length);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CreateImage ( pixels  width,
pixels  height 
)

Definition at line 32 of file set.c.

{
  int Background;

  if (page_imagep) 
    gdImageDestroy(page_imagep);
  if (x_width <= 0) x_width=1;
  if (y_width <= 0) y_width=1;
#ifdef HAVE_GDIMAGECREATETRUECOLOR
  if (flags & RENDER_TRUECOLOR) 
    page_imagep=gdImageCreateTrueColor(x_width,y_width);
  else
#endif
    page_imagep=gdImageCreate(x_width,y_width);
  /* Set bg color */
  Background = gdImageColorAllocate(page_imagep,
                                cstack[0].red,cstack[0].green,cstack[0].blue);
  if (flags & BG_TRANSPARENT) {
    gdImageColorTransparent(page_imagep,Background); 
  }
#ifdef HAVE_GDIMAGECREATETRUECOLOR
  if (flags & RENDER_TRUECOLOR) 
    /* Truecolor: there is no background color index, fill image instead. */
    gdImageFilledRectangle(page_imagep, 0, 0, 
                        x_width-1, y_width-1, Background);
#endif
}

Here is the caller graph for this function:

bool DecodeArgs ( int  ,
char *  [] 
)
void DecodeString ( char *  )

Definition at line 589 of file misc.c.

{
#define PARSEARGS 10
  char    *strv[PARSEARGS];
  int     strc=1;
  strv[0]=NULL;                       /* No program name */

  while (*string==' ' || *string=='\t' || *string=='\n') 
    string++;
  while (*string!='\0') {
    strv[strc++]=string;
    if (*string!='\'') {
      /* Normal split at whitespace */
      while (*string!=' ' && *string!='\t' && *string!='\n' && *string!='\0') 
       string++;
    } else {
      /* String delimiter found , so search for next */
      strv[strc-1]=++string;
      while (*string!='\'' && *string!='\0') 
       string++;
    }
    if (*string!='\0')
      *string++='\0';
    while (*string==' ' || *string=='\t' || *string=='\n') 
      string++;
  }
  if (strc>1) /* Nonempty */
    (void) DecodeArgs(strc,strv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 141 of file set.c.

{
  gdImageDestroy(page_imagep);
  page_imagep=NULL;
}

Here is the caller graph for this function:

void DonePK ( struct font_entry oldfontp)

Definition at line 395 of file pk.c.

{
  int c=FIRSTFNTCHAR;

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

Here is the call graph for this function:

Here is the caller graph for this function:

void DoneVF ( struct font_entry oldfontp)

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 DrawCommand ( unsigned char *  ,
void  
)

Definition at line 143 of file draw.c.

{
  dviunits temp;

  if (/*command >= SETC_000 &&*/ *command <= SETC_127) {
    temp = SetChar((int32_t)*command);
    h += temp;
#ifndef NO_DRIFT
    hh += PIXROUND(temp,dvi->conv*shrinkfactor);
    CHECK_MAXDRIFT(h,hh);
#endif
  } else if (*command >= FONT_00 && *command <= FONT_63) {
    SetFntNum((int32_t)*command - FONT_00,parent);
  } else switch (*command)  {
  case PUT1: case PUT2: case PUT3: case PUT4:
    DEBUG_PRINT(DEBUG_DVI,(" %d",
               UNumRead(command+1, dvi_commandlength[*command]-1)));
    (void) SetChar(UNumRead(command+1, dvi_commandlength[*command]-1));
    break;
  case SET1: case SET2: case SET3: case SET4:
    DEBUG_PRINT(DEBUG_DVI,(" %d",
               UNumRead(command+1, dvi_commandlength[*command]-1)));
    {
      temp = SetChar(UNumRead(command+1, dvi_commandlength[*command]-1));
      h += temp;
#ifndef NO_DRIFT
      hh += PIXROUND(temp,dvi->conv*shrinkfactor);
      CHECK_MAXDRIFT(h,hh);
#endif
    }    
    break;
  case SET_RULE:
    DEBUG_PRINT(DEBUG_DVI,(" %d %d",
               UNumRead(command+1, 4), UNumRead(command+5, 4)));
    temp = SetRule(DO_VFCONV(UNumRead(command+1, 4)),
                 DO_VFCONV(UNumRead(command+5, 4)),
                 hh, vv);
    h += temp;
#ifndef NO_DRIFT
    hh += PIXROUND(temp,dvi->conv*shrinkfactor);
    CHECK_MAXDRIFT(h,hh);
#endif
    break;
  case PUT_RULE:
    DEBUG_PRINT(DEBUG_DVI,(" %d %d",
               UNumRead(command+1, 4), UNumRead(command+5, 4)));
    (void) SetRule(DO_VFCONV(UNumRead(command+1, 4)),
                 DO_VFCONV(UNumRead(command+5, 4)),
                 hh, vv);
    break;
  case BOP:
    Fatal("BOP occurs within page");
    break;
  case EOP:
    break;
  case PUSH:
    if (sp >= STACK_SIZE)
      Fatal("stack overflow");
    stack[sp].h = h;
    stack[sp].v = v;
    stack[sp].w = w;
    stack[sp].x = x;
    stack[sp].y = y;
    stack[sp].z = z;
#ifndef NO_DRIFT
    stack[sp].hh = hh;
    stack[sp].vv = vv;
#endif
    sp++;
    break;
  case POP:
    --sp;
    if (sp < 0)
      Fatal("stack underflow");
    h = stack[sp].h;
    v = stack[sp].v;
    w = stack[sp].w;
    x = stack[sp].x;
    y = stack[sp].y;
    z = stack[sp].z;
#ifndef NO_DRIFT
    hh = stack[sp].hh;
    vv = stack[sp].vv;
#endif
    break;
  case RIGHT1: case RIGHT2: case RIGHT3: case RIGHT4:
    DEBUG_PRINT(DEBUG_DVI,(" %d",
               SNumRead(command+1, dvi_commandlength[*command]-1)));
    MoveRight(DO_VFCONV(SNumRead(command+1, dvi_commandlength[*command]-1)));
    break;
  case W1: case W2: case W3: case W4:
    w = SNumRead(command+1, dvi_commandlength[*command]-1);
    DEBUG_PRINT(DEBUG_DVI,(" %d",w));
  case W0:
    MoveRight(DO_VFCONV(w));
    break;
  case X1: case X2: case X3: case X4:
    x = SNumRead(command+1, dvi_commandlength[*command]-1);
    DEBUG_PRINT(DEBUG_DVI,(" %d",x));
  case X0:
    MoveRight(DO_VFCONV(x));
    break;
  case DOWN1: case DOWN2: case DOWN3: case DOWN4:
    DEBUG_PRINT(DEBUG_DVI,(" %d",
               SNumRead(command+1, dvi_commandlength[*command]-1)));
    MoveDown(DO_VFCONV(SNumRead(command+1, dvi_commandlength[*command]-1)));
    break;
  case Y1: case Y2: case Y3: case Y4:
    y = SNumRead(command+1, dvi_commandlength[*command]-1);
    DEBUG_PRINT(DEBUG_DVI,(" %d",y));
  case Y0:
    MoveDown(DO_VFCONV(y));
    break;
  case Z1: case Z2: case Z3: case Z4:
    z = SNumRead(command+1, dvi_commandlength[*command]-1);
    DEBUG_PRINT(DEBUG_DVI,(" %d",z));
  case Z0:
    MoveDown(DO_VFCONV(z));
    break;
  case FNT1: case FNT2: case FNT3: case FNT4:
    DEBUG_PRINT(DEBUG_DVI,(" %d",
               UNumRead(command+1, dvi_commandlength[*command]-1)));
    SetFntNum(UNumRead(command+1, dvi_commandlength[*command]-1),parent);
    break;
  case XXX1: case XXX2: case XXX3: case XXX4:
    DEBUG_PRINT(DEBUG_DVI,(" %d",
               UNumRead(command+1, dvi_commandlength[*command]-1)));
    SetSpecial((char*)command + dvi_commandlength[*command], 
              UNumRead(command+1, dvi_commandlength[*command]-1),
              hh,vv);
    break;
  case FNT_DEF1: case FNT_DEF2: case FNT_DEF3: case FNT_DEF4:
    if (((struct font_entry*)parent)->type==DVI_TYPE) {
      FontDef(command, parent); 
    } else {
      Fatal("%s within VF macro from %s",dvi_commands[*command],
           ((struct font_entry*)parent)->name);
    }
    break;
  case PRE: case POST: case POST_POST:
    Fatal("%s occurs within page",dvi_commands[*command]);
    break;
  case NOP:
    break;
  default:
    Fatal("%s is an undefined command",dvi_commands[*command]);
    break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 358 of file draw.c.

{
  struct page_list *dvi_pos;
  pixels x_width,y_width,x_offset,y_offset;

  dvi_pos=NextPPage(dvi,NULL);
  if (dvi_pos!=NULL) {
    while(dvi_pos!=NULL) {
      SeekPage(dvi,dvi_pos);
      x_max = y_max = INT32_MIN;
      x_min = y_min = INT32_MAX;
      DrawPage((dviunits)0,(dviunits)0);
      /* Store background color. Background color of a page is given
        by the color at EOP rather than the color at BOP. */
      StoreBackgroundColor(dvi_pos);
      /* Store pagesize */
      if (flags & PREVIEW_LATEX_TIGHTPAGE) {
       x_width_def=x_width_tightpage;
       y_width_def=y_width_tightpage;
       x_offset_def=x_offset_tightpage;
       y_offset_def=y_offset_tightpage;
      }
      if (x_width_def >= 0) { /* extend BBOX */
       min(x_min,-x_offset_def); 
       max(x_max,x_min + x_width_def);
       min(y_min,-y_offset_def);
       max(y_max,y_min + y_width_def);
      }
      if (x_width_def <= 0 || flags & EXPAND_BBOX) {
       x_width = x_max-x_min;
       y_width = y_max-y_min;
       x_offset = -x_min; /* offset by moving topleft corner */ 
       y_offset = -y_min; /* offset by moving topleft corner */
      } else {
       x_width=x_width_def;
       y_width=y_width_def;
       x_offset=x_offset_def;
       y_offset=y_offset_def;
      }
      DEBUG_PRINT(DEBUG_DVI,("\n  IMAGE:\t%dx%d",x_width,y_width));
      SeekPage(dvi,dvi_pos);
      CreateImage(x_width,y_width);
#ifdef DEBUG
      DEBUG_PRINT(DEBUG_DVI,("\n@%d PAGE START:\tBOP",dvi_pos->offset));
      {
       int i;
       for (i=0;i<10;i++) 
         DEBUG_PRINT(DEBUG_DVI,(" %d",dvi_pos->count[i]));
       DEBUG_PRINT(DEBUG_DVI,(" (%d)\n",dvi_pos->count[10]));
      }
#endif
      Message(BE_NONQUIET,"[%d", dvi_pos->count[(flags & DVI_PAGENUM)?0:10]);
      if (dvi_pos->count[(flags & DVI_PAGENUM)?0:10]!=dvi_pos->count[0])
       Message(BE_NONQUIET," (%d)", dvi_pos->count[0]);
      Message(REPORT_DEPTH," depth=%d", y_width-y_offset-1);
      Message(REPORT_HEIGHT," height=%d", y_offset+1);
      DrawPage(x_offset*dvi->conv*shrinkfactor,
              y_offset*dvi->conv*shrinkfactor);
      if ( ! (flags & MODE_PICKY && flags & PAGE_GAVE_WARN )) {
       WriteImage(dvi->outname,dvi_pos->count[(flags & DVI_PAGENUM)?0:10]);
#ifdef TIMING
       ++ndone;
#endif
      } else {
       exitcode=EXIT_FAILURE;
       Message(BE_NONQUIET," not rendered");
       DestroyImage();
      }
      Message(BE_NONQUIET,"] ");
      fflush(stdout);
      flags &= ~PAGE_GAVE_WARN;
      dvi_pos=NextPPage(dvi,dvi_pos);
    }
    Message(BE_NONQUIET,"\n");
    ClearPpList();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void DVIClose ( struct dvi_data )

Definition at line 408 of file dvi.c.

{
  if (dvi!=NULL) {
    fclose(dvi->filep);
    DelPageList(dvi);
    free(dvi->outname);
    free(dvi->name);
    free(dvi);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 42 of file dvi.c.

{
  return followmode = ! followmode;
}

Here is the caller graph for this function:

unsigned char* DVIGetCommand ( struct dvi_data )

Definition at line 167 of file dvi.c.

{ 
  static unsigned char command[STRSIZE];
  static unsigned char* lcommand = command;
  unsigned char *current = command;
  int length;
  uint32_t strlength=0;

  DEBUG_PRINT(DEBUG_DVI,("\n@%ld ", ftell(dvi->filep)));
  *(current++) = fgetc_follow(dvi->filep);
  length = dvi_commandlength[*command];
  if (length < 0)
    Fatal("undefined DVI op-code %d",*command);
  while(current < command+length) 
    *(current++) = fgetc_follow(dvi->filep);
  switch (*command)  {
  case XXX4:
    strlength =                   *(current - 4);
  case XXX3:
    strlength = strlength * 256 + *(current - 3);
  case XXX2: 
    strlength = strlength * 256 + *(current - 2);
  case XXX1:
    strlength = strlength * 256 + *(current - 1);
    break;
  case FNT_DEF1: case FNT_DEF2: case FNT_DEF3: case FNT_DEF4:
    strlength = *(current - 1) + *(current - 2);
    break;
  case PRE: 
    strlength = *(current - 1);
    break;
  }
  if (strlength > 0) { /* Read string */
    if (lcommand!=command) {
      free(lcommand);
      lcommand=command;
    }
    if (strlength + (uint32_t)length >  (uint32_t)STRSIZE) {
      /* string + command length exceeds that of buffer */
      if ((lcommand=malloc(length+strlength+1))==NULL) 
       Fatal("cannot allocate memory for DVI command");
      memcpy(lcommand,command,length);
      current = lcommand + length;
    }
    while(current < lcommand+length+strlength) 
      *(current++) = fgetc_follow(dvi->filep);
    return(lcommand);
  } else
    return(command);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct dvi_data* DVIOpen ( char *  ,
char *   
) [read]

Definition at line 99 of file dvi.c.

{
  char* tmpstring;
  struct dvi_data* dvi;

  if ((dvi = calloc(1,sizeof(struct dvi_data)))==NULL)
    Fatal("cannot allocate memory for dvi struct");

  dvi->type = DVI_TYPE;
  dvi->fontnump=NULL;

  dvi->name = malloc(strlen(dviname)+5);
  if (dvi->name==NULL)
    Fatal("cannot allocate space for DVI filename");
  strcpy(dvi->name, dviname);
  tmpstring = strrchr(dvi->name, '.');
  if (tmpstring == NULL || strcmp(tmpstring,".dvi") != 0) 
    strcat(dvi->name, ".dvi");
  
  if (outname==NULL) { 
    dvi->outname = malloc(strlen(basename(dviname))+7);
    if (dvi->outname==NULL) {
      free(dvi->name);
      free(dvi);
      Fatal("cannot allocate space for output filename");
    }
    strcpy(dvi->outname,basename(dviname));
    tmpstring = strrchr(dvi->outname, '.');
    if (tmpstring != NULL) 
      *tmpstring = '\0';
    strcat(dvi->outname, "%d.png");
  } else {
    dvi->outname = malloc(strlen(outname)+1);
    if (dvi->outname==NULL) {
      free(dvi->name);
      free(dvi);
      Fatal("cannot allocate space for output filename");
    }
    strcpy(dvi->outname,outname);
  }

  if ((dvi->filep = fopen(dvi->name,"rb")) == NULL) {
    /* do not insist on .dvi */
    tmpstring = strrchr(dvi->name, '.');
    *tmpstring='\0';
    dvi->filep = fopen(dvi->name,"rb");
  }
  while((dvi->filep == NULL) && followmode) {
    SLEEP;
    *tmpstring='.';
    if ((dvi->filep = fopen(dvi->name,"rb")) == NULL) {
      /* do not insist on .dvi */
      *tmpstring='\0';
      dvi->filep = fopen(dvi->name,"rb");
    }
  }
  if (dvi->filep == NULL) {
    free(dvi->name);
    free(dvi->outname);
    free(dvi);
    perror(dviname);
    exit (EXIT_FAILURE);
  }
  DEBUG_PRINT(DEBUG_DVI,("OPEN FILE\t%s", dvi->name));
  DVIInit(dvi);
  return(dvi);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool DVIReOpen ( struct dvi_data )

Definition at line 419 of file dvi.c.

{
  struct stat stat;
  fstat(fileno(dvi->filep), &stat);
  if (dvi->mtime != stat.st_mtime) {
    fclose(dvi->filep);
    dvi->filep=NULL;
    DelPageList(dvi);
    while(((dvi->filep = fopen(dvi->name,"rb")) == NULL) && followmode) {
      SLEEP;
    }
    if (dvi->filep == NULL) {
      perror(dvi->name);
      exit(EXIT_FAILURE);
    }
    Message(PARSE_STDIN,"Reopened file\n");
    DEBUG_PRINT(DEBUG_DVI,("\nREOPEN FILE\t%s", dvi->name));
    DVIInit(dvi);
    return(true);
  }
  return(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 314 of file draw.c.

{
  --sp;
  if (sp < 0)
    Fatal("stack underflow");
  h = stack[sp].h;
  v = stack[sp].v;
  w = stack[sp].w;
  x = stack[sp].x;
  y = stack[sp].y;
  z = stack[sp].z;
#ifndef NO_DRIFT
  hh = stack[sp].hh;
  vv = stack[sp].vv;
#endif
  DEBUG_PRINT(DEBUG_DVI,("\n  END VF:\tPOP                                  "));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Fatal ( char *  fmt,
  ... 
)

Definition at line 641 of file misc.c.

{
  va_list args;

  va_start(args, fmt);
  fflush(stdout);
  fprintf(stderr, "\n");
  fprintf(stderr, "%s: Fatal error, ", programname);
  vfprintf(stderr, fmt, args);
  
  fprintf(stderr, "\n\n");
  va_end(args);

  ClearFonts();
#ifdef HAVE_FT2
  if (libfreetype)
    (void) FT_Done_FreeType(libfreetype); /* at this point, ignore error */
#endif  
#ifdef HAVE_LIBT1
  if (libt1)
    (void) T1_CloseLib(); /* at this point, ignore error */
#endif  
  exit(EXIT_FATAL);
}

Here is the call graph for this function:

struct page_list* FindPage ( struct dvi_data ,
int32_t  ,
bool   
) [read]

Definition at line 375 of file dvi.c.

{
  struct page_list* page=NextPage(dvi, NULL);
  
  if (pagenum==PAGE_LASTPAGE || pagenum==PAGE_POST) {
    while(page!=NULL && page->count[0]!=PAGE_POST)
      page=NextPage(dvi,page);
    if (pagenum==PAGE_LASTPAGE)
      page=PrevPage(dvi,page);
  } else
    if (pagenum!=PAGE_FIRSTPAGE) 
      while(page != NULL && pagenum != page->count[abspage ? 0 : 10])
       page=NextPage(dvi,page);
  return(page);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FirstPage ( int32_t  ,
bool   
)

Definition at line 40 of file ppagelist.c.

void FontDef ( unsigned char *  ,
void  
)

Definition at line 68 of file font.c.

{
  int32_t k;
  uint32_t   c, s, d;
  uint8_t    a, l;
  unsigned char* current;
  struct font_entry *tfontptr; /* temporary font_entry pointer   */
  struct font_num *tfontnump = NULL;  /* temporary font_num pointer   */
  unsigned short i;

  current = command + 1;
  k = UNumRead(current, (int)*command - FNT_DEF1 + 1);
  current += (int)*command - FNT_DEF1 + 1;
  c = UNumRead(current, 4); /* checksum */
  s = UNumRead(current+4, 4); /* space size */
  d = UNumRead(current+8, 4); /* design size */
  a = UNumRead(current+12, 1); /* length for font name */
  l = UNumRead(current+13, 1); /* device length */
  if (((struct font_entry*)parent)->type==FONT_TYPE_VF) {
    DEBUG_PRINT(DEBUG_VF,(" %d %d %d",k,c,s));
    /* Rescale. s is relative to the actual scale /(1<<20) */
    s = (uint32_t)((uint64_t) s * (((struct font_entry*) parent)->s) 
                 / (1<<20));
    DEBUG_PRINT(DEBUG_VF,(" (%d) %d",s,d));
    /* Oddly, d differs in the DVI and the VF that my system produces */
    d = (uint32_t)((uint64_t) d * ((struct font_entry*)parent)->d
                 / ((struct font_entry*)parent)->designsize);
    DEBUG_PRINT(DEBUG_VF,(" (%d)",d));
    DEBUG_PRINT(DEBUG_VF,(" %d %d '%.*s'",a,l,a+l,current+14));
#ifdef DEBUG
  } else {
    DEBUG_PRINT(DEBUG_DVI,(" %d %d %d %d %d %d '%.*s'",k,c,s,d,a,l,
               a+l,current+14));
#endif
  }
  if (a+l > STRSIZE-1)
    Fatal("too long font name for font %ld\n",k);

  /* Find entry with this font number in use */
  switch (((struct font_entry*)parent)->type) {
  case FONT_TYPE_VF:
    tfontnump = ((struct font_entry*)parent)->vffontnump;
    break;
  case DVI_TYPE:
    tfontnump = ((struct dvi_data*)parent)->fontnump;
  }
  while (tfontnump != NULL && tfontnump->k != k) {
    tfontnump = tfontnump->next;
  }
  /* If found, return if it is correct */
  if (tfontnump!=NULL 
      && tfontnump->fontp->s == s 
      && tfontnump->fontp->d == d 
      && strncmp(tfontnump->fontp->n,(char*)current+14,a+l) == 0) {
    DEBUG_PRINT((DEBUG_DVI|DEBUG_VF),("\n  FONT %d:\tMatch found",k));
    return;
  }
  /* If not found, create new */
  if (tfontnump==NULL) {
    if ((tfontnump=malloc(sizeof(struct font_num)))==NULL) 
      Fatal("cannot allocate memory for new font number");
    tfontnump->k=k;
    switch (((struct font_entry*)parent)->type) {
    case FONT_TYPE_VF:
      tfontnump->next=((struct font_entry*)parent)->vffontnump;
      ((struct font_entry*)parent)->vffontnump=tfontnump;
      break;
    case DVI_TYPE:
      tfontnump->next=((struct dvi_data*)parent)->fontnump;
      ((struct dvi_data*)parent)->fontnump=tfontnump;
    }
  }

  /* Search font list for possible match */
  tfontptr = hfontptr;
  while (tfontptr != NULL 
        && (tfontptr->s != s 
            || tfontptr->d != d 
            || strncmp(tfontptr->n,(char*)current+14,a+l) != 0 ) ) {
    tfontptr = tfontptr->next;
  }
  /* If found, set its number and return */
  if (tfontptr!=NULL) {
    DEBUG_PRINT((DEBUG_DVI|DEBUG_VF),("\n  FONT %d:\tMatch found, number set",k));
    tfontnump->fontp = tfontptr; 
    return;
  }

  DEBUG_PRINT((DEBUG_DVI|DEBUG_VF),("\n  FONT %d:\tNew entry created",k));
  /* No fitting font found, create new entry. */
  if ((tfontptr = calloc(1,sizeof(struct font_entry))) == NULL)
    Fatal("can't malloc space for font_entry");
  tfontptr->next = hfontptr;
  hfontptr = tfontptr;
  tfontnump->fontp = tfontptr;
#ifndef MIKTEX
  tfontptr->fmmap.fd = 0;
#else  /* MIKTEX */
  tfontptr->fmmap.hFile = INVALID_HANDLE_VALUE;
#endif
  tfontptr->c = c; /* checksum */
  tfontptr->s = s; /* space size */
  tfontptr->d = d; /* design size */
  tfontptr->a = a; /* length for font name */
  tfontptr->l = l; /* device length */
  strncpy(tfontptr->n,(char*)current+14,a+l); /* full font name */
  tfontptr->n[a+l] = '\0';
  
  tfontptr->name[0] = '\0';
  for (i = FIRSTFNTCHAR; i <= LASTFNTCHAR; i++) {
    tfontptr->chr[i] = NULL;
  }

  tfontptr->dpi = 
    (uint32_t)((ActualFactor((uint32_t)(1000.0*tfontptr->s
                              /(double)tfontptr->d+0.5))
            * ActualFactor(dvi->mag) * dpi*shrinkfactor) + 0.5);
#ifdef HAVE_FT2_OR_LIBT1
  tfontptr->psfontmap=NULL;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FreeFontNumP ( struct font_num hfontnump)

Definition at line 325 of file font.c.

{
  struct font_num *tmp;
  while(hfontnump!=NULL) {
    tmp=hfontnump->next; 
    free(hfontnump);
    hfontnump=tmp;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Gamma ( double  gamma)

Definition at line 170 of file set.c.

{
  int i=0;
  
  while (i<=255) {
    gammatable[i]=255-(int)(pow((double)(255-i)/255.0,gamma)*255);
    DEBUG_PRINT(DEBUG_GLYPH,("\n  GAMMA GREYSCALE: %d -> %d ",i,gammatable[i]));
    i++;
  }
}

Here is the caller graph for this function:

void handlepapersize ( char *  ,
int32_t ,
int32_t  
)

Definition at line 64 of file papersiz.c.

{ 
   while (*p == ' ')
      p++ ;
   *x = myatodim(&p) ;
   while (*p == ' ' || *p == ',')
      p++ ;
   *y = myatodim(&p) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

EXTERN bool makeTexPK INIT ( _TRUE  )
EXTERN int borderwidth INIT ( )
EXTERN struct dvi_data *dvi INIT ( NULL  ) [read]
EXTERN int dpi INIT ( 100  )
EXTERN bool userbordercolor INIT ( FALSE  )
EXTERN int32_t shrinkfactor INIT ( )
EXTERN int csp INIT ( )
EXTERN int exitcode INIT ( EXIT_SUCCESS  )

Definition at line 42 of file color.c.

{
   csp = 1;
   cstack[0].red=255; 
   cstack[0].green=255; 
   cstack[0].blue=255; 
   cstack[1].red=0; 
   cstack[1].green=0; 
   cstack[1].blue=0; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void InitPK ( struct font_entry newfontp)

Definition at line 315 of file pk.c.

{
  unsigned char* position;
  struct char_entry *tcharptr; /* temporary char_entry pointer  */
  uint32_t    hppp, vppp, packet_length;
  uint32_t    c;

  DEBUG_PRINT((DEBUG_DVI|DEBUG_PK),("\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 (tfontp->fmmap.size < 2 || tfontp->fmmap.size < 3+*(position+2)+16) 
    Fatal("PK file %s ends prematurely",tfontp->name);
  if (*position++ != PK_PRE) 
    Fatal("unknown font format in file <%s> !\n",currentfont->name);
  if (*position++ != PK_ID) 
    Fatal( "wrong version of pk file!  (%d should be 89)\n",
          (int)*(position-1));
  DEBUG_PRINT(DEBUG_PK,("\n  PK_PRE:\t'%.*s'",(int)*position, position+1));
  position += *position + 1;

  tfontp->designsize = UNumRead(position, 4);
  DEBUG_PRINT(DEBUG_PK,(" %d", tfontp->designsize));
  tfontp->type = FONT_TYPE_PK;
  
  c = UNumRead(position+4, 4);
  DEBUG_PRINT(DEBUG_PK,(" %d", c));
  CheckChecksum (tfontp->c, c, tfontp->name);

  hppp = UNumRead(position+8, 4);
  vppp = UNumRead(position+12, 4);
  DEBUG_PRINT(DEBUG_PK,(" %d %d", hppp,vppp));
  if (hppp != vppp)
    Warning("aspect ratio is %d:%d (should be 1:1)!", hppp, vppp);
  tfontp->magnification = (uint32_t)((uint64_t)hppp * 7227 * 5 / 65536l + 50)/100;
  position+=16;
  /* Read char definitions */
  position = skip_specials(position);
  while (*position != PK_POST) {
    DEBUG_PRINT(DEBUG_PK,("\n  @%ld PK CHAR:\t%d",
                       (long)position - (long)tfontp->fmmap.mmap, *position));
    if ((tcharptr = malloc(sizeof(struct char_entry))) == NULL)
      Fatal("can't malloc space for char_entry");
    tcharptr->flag_byte = *position;
    tcharptr->data = NULL;
    tcharptr->tfmw = 0;
    if ((*position & 7) == 7) {
      packet_length = UNumRead(position+1,4);
      c = UNumRead(position+5, 4);
      position += 9;
    } else if (*position & 4) {
      packet_length = (*position & 3) * 65536l +
       UNumRead(position+1, 2);
      c = UNumRead(position+3, 1);
      position += 4;
    } else {
      packet_length = (*position & 3) * 256 +
       UNumRead(position+1, 1);
      c = UNumRead(position+2, 1);
      position += 3;
    }
  DEBUG_PRINT(DEBUG_PK,(" %d %d",packet_length,c));
  if (c > (LASTFNTCHAR))
    Fatal("Bad character (%d) in PK-File\n",(int)c);
  tcharptr->length = packet_length;
  tcharptr->pkdata = position;
  tfontp->chr[c]=tcharptr;
  position += packet_length;
  position = skip_specials(position);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void InitVF ( struct font_entry newfontp)

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:

void LastPage ( int32_t  ,
bool   
)

Definition at line 45 of file ppagelist.c.

{
  last=page;
  abspage |= data;
}
void LoadPK ( int32_t  ,
register struct char_entry  
)

Definition at line 124 of file pk.c.

{
  unsigned short   shrunk_width,shrunk_height;
  unsigned short   width,height;
  short   xoffset,yoffset;
  unsigned short   i_offset,j_offset;
  int   i,j,k,n;
  int   count=0;
  bool  paint_switch;
  unsigned char *pos,*buffer;

  DEBUG_PRINT(DEBUG_PK,("\n  LOAD PK CHAR\t%d",c));
  pos=ptr->pkdata;
  if ((ptr->flag_byte & 7) == 7) n=4;
  else if ((ptr->flag_byte & 4) == 4) n=2;
  else n=1;
  dyn_f = ptr->flag_byte / 16;
  paint_switch = ((ptr->flag_byte & 8) != 0);
  /*
   *  Read character preamble
   */
  if (n != 4) {
    ptr->tfmw = UNumRead(pos, 3);
    /* +n:   vertical escapement not used */
    pos+=3+n;
  } else {
    ptr->tfmw = UNumRead(pos, 4);
    /* +4:  horizontal escapement not used */
    /* +n:   vertical escapement not used */
    pos+=8+n;
  }
  DEBUG_PRINT(DEBUG_PK,(" %d",ptr->tfmw));
  ptr->tfmw = (dviunits)
    ((int64_t) ptr->tfmw * currentfont->s / 0x100000 );
  DEBUG_PRINT(DEBUG_PK,(" (%d)",ptr->tfmw));
  
  width   = UNumRead(pos, n);
  height  = UNumRead(pos+=n, n);
  DEBUG_PRINT(DEBUG_PK,(" %dx%d",width,height));

  if (width > 0x7fff || height > 0x7fff)
    Fatal("Character %d too large in file %s", c, currentfont->name);

  /* 
   * Hotspot issues: Shrinking to the topleft corner rather than the
     hotspot will displace glyphs a fraction of a pixel. We deal with
     this in as follows: The glyph is shrunk to its hotspot by
     offsetting the bitmap somewhat to put the hotspot in the lower
     left corner of a "shrink square". Shrinking to the topleft corner
     will then act as shrinking to the hotspot. This may enlarge the
     bitmap somewhat, of course.  (Also remember that the below
     calculation of i/j_offset is in integer arithmetics.)
     
     There will still be a displacement from rounding the dvi
     position, but vertically it will be equal for all glyphs on a
     line, so we displace a whole line vertically by fractions of a
     pixel. This is acceptible, IMHO. Sometime there will be support
     for subpixel positioning, horizontally. Will do for now, I
     suppose.
   */
  xoffset = SNumRead(pos+=n, n);
  i_offset = ( shrinkfactor - xoffset % shrinkfactor ) % shrinkfactor;
  width += i_offset;
  ptr->xOffset = xoffset+i_offset;

  yoffset = SNumRead(pos+=n, n);
  j_offset = ( shrinkfactor - (yoffset-(shrinkfactor-1)) % shrinkfactor )
    % shrinkfactor;
  height += j_offset;
  ptr->yOffset = yoffset+j_offset;

  DEBUG_PRINT(DEBUG_PK,(" (%dx%d)",width,height));
  /* 
     Extra marginal so that we do not crop the image when shrinking.
  */
  shrunk_width = (width + shrinkfactor - 1) / shrinkfactor;
  shrunk_height = (height + shrinkfactor - 1) / shrinkfactor;
  ptr->w = shrunk_width;
  ptr->h = shrunk_height;
  pos+=n;
  buffer = alloca(shrunk_width*shrunk_height*
                shrinkfactor*shrinkfactor*sizeof(char));
  (void)memset(buffer,0,shrunk_width*shrunk_height*
              shrinkfactor*shrinkfactor*sizeof(char));
  DEBUG_PRINT(DEBUG_GLYPH,("\nDRAW GLYPH %d\n", (int)c));
  /*
    Raster char
  */
  if (dyn_f == 14) { /* get raster by bits */
    int bitweight = 0;
    for (j = j_offset; j < (int) height; j++) {  /* get all rows */
      for (i = i_offset; i < (int) width; i++) {    /* get one row */
       bitweight /= 2;
       if (bitweight == 0) {
         count = *pos++;
         bitweight = 128;
       }
       if (count & bitweight) {
         buffer[i+j*width]=1;
#ifdef DEBUG
         DEBUG_PRINT(DEBUG_GLYPH,("+"));
       } else {
         DEBUG_PRINT(DEBUG_GLYPH,(" "));
#endif
       }
      }
      DEBUG_PRINT(DEBUG_GLYPH,("|\n"));
    }
  } else {           /* get packed raster */
    poshalf=0;
    repeatcount = 0;
    for(i=i_offset, j=j_offset; j<height; ) {
      count = pk_packed_num(&pos);
      while (count > 0) {
       if (i+count < width) {
         if (paint_switch) 
           for(k=0;k<count;k++) {
             buffer[k+i+j*width]=1;
             DEBUG_PRINT(DEBUG_GLYPH,("*"));
           }
#ifdef DEBUG
         else for(k=0;k<count;k++) 
           DEBUG_PRINT(DEBUG_GLYPH,(" "));
#endif
         i += count;
         count = 0;
       } else {
         if (paint_switch) 
           for(k=i;k<width;k++) {
             buffer[k+j*width]=1;
             DEBUG_PRINT(DEBUG_GLYPH,("#"));
           }
#ifdef DEBUG
         else for(k=i;k<width;k++) 
           DEBUG_PRINT(DEBUG_GLYPH,(" "));
#endif
         DEBUG_PRINT(DEBUG_GLYPH,("|\n"));
         j++;
         count -= width-i;
         /* Repeat row(s) */
         for (;repeatcount>0; repeatcount--,j++) {
           for (i = i_offset; i<width; i++) {
             buffer[i+j*width]=buffer[i+(j-1)*width];
#ifdef DEBUG
             if (buffer[i+j*width]>0) {
              DEBUG_PRINT(DEBUG_GLYPH,("="));
             } else {
              DEBUG_PRINT(DEBUG_GLYPH,(" "));
             }
#endif
           }
           DEBUG_PRINT(DEBUG_GLYPH,("|\n"));
         }
         i=i_offset;
       }
      }
      paint_switch = 1 - paint_switch;
    }
    if (i>i_offset)
      Fatal("Wrong number of bits stored:  char. <%c>(%d), font %s, Dyn: %d", 
           (char)c, (int)c, currentfont->name,dyn_f);
    if (j>height)
      Fatal("Bad pk file (%s), too many bits", currentfont->name);
  }
  /*
    Shrink raster while doing antialiasing. (See above. The
    single-glyph output seems better than what xdvi at 300 dpi,
    shrinkfactor 3 produces.)
  */
  if ((ptr->data = calloc(shrunk_width*shrunk_height,sizeof(char))) == NULL)
    Fatal("Unable to allocate image space for char <%c>\n", (char)c);
  for (j = 0; j < (int) height; j++) {    
    for (i = 0; i < (int) width; i++) {    
      /* if (((i % shrinkfactor) == 0) && ((j % shrinkfactor) == 0))
        ptr->data[i/shrinkfactor+j/shrinkfactor*shrunk_width] =
        buffer[i+j*width];
        else */
      ptr->data[i/shrinkfactor+j/shrinkfactor*shrunk_width] +=
       buffer[i+j*width];
    }
  }    
  for (j = 0; j < shrunk_height; j++) {   
    for (i = 0; i < shrunk_width; i++) {    
      ptr->data[i+j*shrunk_width] = ptr->data[i+j*shrunk_width]
       *255/shrinkfactor/shrinkfactor;
      DEBUG_PRINT(DEBUG_GLYPH,("%3u ",ptr->data[i+j*shrunk_width]));
    }
    DEBUG_PRINT(DEBUG_GLYPH,("|\n"));
  }     
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Message ( int  ,
char *  fmt,
  ... 
)

Definition at line 689 of file misc.c.

{
  va_list args;

  va_start(args, fmt);
  if ( flags & activeflags ) {
    vfprintf(stdout, fmt, args);
  }
  va_end(args);
}

Here is the caller graph for this function:

bool MmapFile ( char *  filename,
struct filemmap fmmap 
)

Definition at line 701 of file misc.c.

{
#ifndef MIKTEX
  struct stat stat;
#endif

  DEBUG_PRINT(DEBUG_DVI,("\n  OPEN FILE:\t'%s'", filename));
  fmmap->mmap=NULL;
#ifndef MIKTEX
  if ((fmmap->fd = open(filename,O_RDONLY)) == -1) {
    Warning("cannot open file <%s>", filename);
    return(true);
  }
  fstat(fmmap->fd,&stat);
  fmmap->size=stat.st_size;
# ifdef HAVE_MMAP
  fmmap->mmap = mmap(NULL,fmmap->size, PROT_READ, MAP_SHARED,fmmap->fd,0);
  if (fmmap->mmap == (char*)-1) {
    Warning("cannot mmap file <%s>",filename);
    fmmap->mmap=NULL;
    close(fmmap->fd);
    return(true);
  }
# else /* HAVE_MMAP */
  fmmap->mmap = malloc(fmmap->size);
  if (read(fmmap->fd,fmmap->mmap,fmmap->size)<fmmap->size) {
    Warning("too little data in <%s>",filename);
    free(fmmap->mmap);
    fmmap->mmap=NULL;
    close(fmmap->fd);
    return(true);
  }
  close(fmmap->fd);
# endif /* HAVE_MMAP */
#else /* MIKTEX */
  fmmap->hFile = CreateFile(filename, GENERIC_READ, 0, 0, OPEN_EXISTING,
                         FILE_FLAG_RANDOM_ACCESS, 0);
  if (fmmap->hFile == INVALID_HANDLE_VALUE) {
    Warning("cannot open file <%s>", filename);
    return(true);
  }
  fmmap->size = GetFileSize(hFile, 0);
  fmmap->hMap = CreateFileMapping(hFile, 0, PAGE_READONLY, 0, 0, 0);
  if (fmmap->hMap == 0) {
    CloseHandle (fmmap->hFile);
    Warning("cannot CreateFileMapping() file <%s>", filename);
    return(true);
  }
  fmmap->mmap = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
  if (fmmap->mmap == NULL) {
    Warning("cannot MapViewOfFile() file <%s>", filename);
    CloseHandle (fmmap->hMap);
    CloseHandle (fmmap->hFile);
    return(true);
  }
#endif  /* MIKTEX */
  return(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct page_list* NextPage ( struct dvi_data ,
struct page_list  
) [read]

Definition at line 331 of file dvi.c.

{
  struct page_list* tpagelistp;

  /* if page points to POST there is no next page */
  if (page!=NULL && page->count[0]==PAGE_POST) 
    return(NULL);

  /* If we have read past the last page in our current list or the
   *  list is empty, sneak a look at the next page
   */
  if (dvi->pagelistp==NULL
      || dvi->pagelistp->offset+45L < ftell(dvi->filep)) {
    tpagelistp=dvi->pagelistp;
    dvi->pagelistp=InitPage(dvi);
    dvi->pagelistp->next=tpagelistp;
  }

  if (page!=dvi->pagelistp) {
    /* also works if page==NULL, we'll get the first page then */
    tpagelistp=dvi->pagelistp;
    while(tpagelistp!=NULL && tpagelistp->next!=page)
      tpagelistp=tpagelistp->next;
  } else {
    /* dvi->pagelistp points to the last page we've read so far,
     * the last page that we know where it is, so to speak
     * So look at the next
     */
    (void)SeekPage(dvi,dvi->pagelistp);
    SkipPage(dvi);
    tpagelistp=dvi->pagelistp;
    dvi->pagelistp=InitPage(dvi);
    dvi->pagelistp->next=tpagelistp;
    tpagelistp=dvi->pagelistp;
  }
  return(tpagelistp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct page_list* NextPPage ( void ,
struct page_list  
) [read]

Definition at line 62 of file ppagelist.c.

{
  if (! reverse) { /*********** normal order */
    if (page == NULL) { /* first call: find first page */ 
      if (no_ppage)
       return(NULL);
      page=FindPage(dvi,first,abspage);
    } else              /* later calls: count up, except "last" page */ 
      page=(last==page->count[abspage ? 0 : 10]) ? NULL : NextPage(dvi,page);
    /* seek for pages in pagelist */ 
    while (page!=NULL && ! InPageList(page->count[0]))
      page=(last==page->count[abspage ? 0 : 10]) ? NULL : NextPage(dvi,page);
  } else { /******************** reverse order */
    if (page == NULL) { /* first call: find "last" page */ 
      if (no_ppage)
       return(NULL);
      page=FindPage(dvi,last,abspage);
    } else              /* later calls: count down, except "first" page */
      page=(first==page->count[abspage ? 0 : 10]) ? NULL : PrevPage(dvi,page);
    /* seek for pages in pagelist */ 
    while (page!=NULL && ! InPageList(page->count[0])) 
      page=(first==page->count[abspage ? 0 : 10]) ? NULL : PrevPage(dvi,page);
  }
  return(page);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool ParsePages ( char *  )

Definition at line 134 of file ppagelist.c.

{
  char *c;           /* conversion start */
  long int ps_low = PAGE_MINPAGE, ps_high = PAGE_MAXPAGE;

  while (*s==' ' || *s=='\t') s++;
  while (*s!='\0') {
    if (*s=='-' || *s==':') { /* range with no starting value */
      ps_low = PAGE_MINPAGE;
      c=s+1;
      ps_high = strtol(c,&s,10);
      if (c==s) ps_high=PAGE_MAXPAGE; /* no number */
      while (*s==' ' || *s=='\t') s++;
      if (*s=='-' || *s==':') { /* Oh, range with negative starting value */
       ps_low = -ps_high;
       c=s+1;
       ps_high = strtol(c,&s,10);
       if (c==s) ps_high=PAGE_MAXPAGE; /* no number */
      }
    } else { /* range with starting value, or singleton */
      c=s;
      ps_low = ps_high = strtol(c,&s,10);
      if (c==s) 
       return(true);
      if (*s=='-' || *s==':') { /* range */
       c=s+1;
       ps_high = strtol(c,&s,10);
       if (c==s) ps_high=PAGE_MAXPAGE; /* no number */
      }
    }
    ListPage(ps_low, ps_high);
    while (*s==' ' || *s=='\t' || *s==',') s++;
  }
  return(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 195 of file color.c.

{
  if (csp > 1) csp--; /* Last color is global */
  DEBUG_PRINT(DEBUG_COLOR,("\n  COLOR POP\t"))
}

Here is the caller graph for this function:

struct page_list* PrevPage ( struct dvi_data ,
struct page_list  
) [read]

Definition at line 369 of file dvi.c.

{
  return(page->next);
}

Here is the caller graph for this function:

void pushcolor ( char *  )

Definition at line 186 of file color.c.

{
  if ( ++csp == STACK_SIZE )
    Fatal("Out of color stack space") ;
  stringrgb(p, &cstack[csp].red, &cstack[csp].green, &cstack[csp].blue);
  DEBUG_PRINT(DEBUG_COLOR,("\n  COLOR PUSH:\t(%d %d %d) ",
                        cstack[csp].red, cstack[csp].green, cstack[csp].blue))
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ReadColorStack ( struct page_list tpagep)

Definition at line 226 of file color.c.

{
  int i=0;

  DEBUG_PRINT(DEBUG_COLOR,("\n  READ COLOR STACK:\t %d ", tpagep->csp));
  csp=tpagep->csp;
  while ( i <= tpagep->csp ) {
    DEBUG_PRINT(DEBUG_COLOR,("\n  COLOR STACK:\t %d (%d %d %d) ",i,
                          cstack[i].red, cstack[i].green, cstack[i].blue));
    cstack[i].red = tpagep->cstack[i].red;
    cstack[i].green = tpagep->cstack[i].green;
    cstack[i].blue = tpagep->cstack[i].blue;
    i++;
  }
}

Here is the caller graph for this function:

void resetcolorstack ( char *  )

Definition at line 201 of file color.c.

{
  if ( csp > 1 )
    Warning("Global color change within nested colors\n");
  csp=0;
  pushcolor(p) ;
  DEBUG_PRINT(DEBUG_COLOR,("\n  RESET COLOR:\tbottom of stack:"))
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Reverse ( bool  )

Definition at line 50 of file ppagelist.c.

{
  reverse=new;
}
int SeekPage ( struct dvi_data ,
struct page_list  
)

Definition at line 323 of file dvi.c.

{
  ReadColorStack(page);
  return(fseek(dvi->filep, 
              page->offset+((page->count[0]==PAGE_POST) ? 1L : 45L),
              SEEK_SET));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 96 of file draw.c.

{
  struct char_entry* ptr;

  if (currentfont==NULL) 
    Fatal("faulty DVI, trying to set character from null font");
  ptr = currentfont->chr[c];
#ifdef DEBUG
  switch (currentfont->type) {
  case FONT_TYPE_VF: DEBUG_PRINT(DEBUG_DVI,("\n  VF CHAR:\t")); break;
  case FONT_TYPE_PK: DEBUG_PRINT(DEBUG_DVI,("\n  PK CHAR:\t")); break;
  case FONT_TYPE_T1: DEBUG_PRINT(DEBUG_DVI,("\n  T1 CHAR:\t")); break;
  case FONT_TYPE_FT: DEBUG_PRINT(DEBUG_DVI,("\n  FT CHAR:\t")); break;
  }
  if (isprint(c))
    DEBUG_PRINT(DEBUG_DVI,("'%c' ",c));
  DEBUG_PRINT(DEBUG_DVI,("%d at (%d,%d) tfmw %d", c,hh,vv,ptr->tfmw));
#endif
  if (currentfont->type==FONT_TYPE_VF) {
    return(SetVF(c));
  } else if (ptr) {
    if (ptr->data == NULL) 
      switch(currentfont->type) {
      case FONT_TYPE_PK:    LoadPK(c, ptr); break;
#ifdef HAVE_LIBT1
      case FONT_TYPE_T1:    LoadT1(c, ptr); break;
#endif
#ifdef HAVE_FT2
      case FONT_TYPE_FT:    LoadFT(c, ptr); break;
#endif
      default:
       Fatal("undefined fonttype %d",currentfont->type);
      }
    if (page_imagep != NULL)
      return(SetGlyph(c, hh, vv));
    else {
      /* Expand bounding box if necessary */
      min(x_min,hh - ptr->xOffset/shrinkfactor);
      min(y_min,vv - ptr->yOffset/shrinkfactor);
      max(x_max,hh - ptr->xOffset/shrinkfactor + ptr->w);
      max(y_max,vv - ptr->yOffset/shrinkfactor + ptr->h);
      return(ptr->tfmw);
    }
  }
  return(0);
}

Here is the call graph for this function:

void SetFntNum ( int32_t  ,
void  
)

Definition at line 353 of file font.c.

{
  struct font_num *tfontnump=NULL;  /* temporary font_num pointer   */

  switch (((struct font_entry*)parent)->type) {
  case FONT_TYPE_VF:
    tfontnump = ((struct font_entry*)parent)->vffontnump;
    break;
  case DVI_TYPE:
    tfontnump = ((struct dvi_data*)parent)->fontnump;
  }
  while (tfontnump != NULL && tfontnump->k != k)
    tfontnump = tfontnump->next;
  if (tfontnump == NULL)
    Fatal("font %d undefined", k);

  currentfont = tfontnump->fontp;
  if (currentfont->name[0]=='\0')
    FontFind(currentfont);
}

Here is the call graph for this function:

dviunits SetGlyph ( int32_t  c,
int32_t  hh,
int32_t  vv 
)

Definition at line 183 of file set.c.

{
  register struct char_entry *ptr = currentfont->chr[c];
                                      /* temporary char_entry pointer */
  int red,green,blue;
  int *Color=alloca(sizeof(int)*(GREYS+1));
  int x,y;
  int pos=0;
  int bgColor,pixelgrey,pixelcolor;
  hh -= ptr->xOffset/shrinkfactor;
  vv -= ptr->yOffset/shrinkfactor;
  
  Color[0] = gdImageColorResolve(page_imagep,
                             cstack[0].red,cstack[0].green,cstack[0].blue);
  for( x=1; x<=GREYS ; x++) 
    Color[x] = -1;
  for( y=0; y<ptr->h; y++) {
    for( x=0; x<ptr->w; x++) {
      if (ptr->data[pos]>0) {
       pixelgrey=gammatable[(int)ptr->data[pos]];
       DEBUG_PRINT(DEBUG_GLYPH,("\n  GAMMA GREYSCALE: %d -> %d ",ptr->data[pos],pixelgrey));
       bgColor = gdImageGetPixel(page_imagep, hh + x, vv + y);
       if (bgColor == Color[0]) {
         /* Standard background: use cached value if present */
         pixelcolor=Color[pixelgrey];
         if (pixelcolor==-1) {
           red = cstack[0].red 
             - (cstack[0].red-cstack[csp].red)*pixelgrey/GREYS;
           green = cstack[0].green
             - (cstack[0].green-cstack[csp].green)*pixelgrey/GREYS;
           blue = cstack[0].blue
             - (cstack[0].blue-cstack[csp].blue)*pixelgrey/GREYS;
           Color[pixelgrey] = 
             gdImageColorResolve(page_imagep,red,green,blue);
           pixelcolor=Color[pixelgrey];
         }
       } else {
         /* Overstrike: No cache */
         red=gdImageRed(page_imagep, bgColor);
         green=gdImageGreen(page_imagep, bgColor);
         blue=gdImageBlue(page_imagep, bgColor);
         red = red-(red-cstack[csp].red)*pixelgrey/GREYS;
         green = green-(green-cstack[csp].green)*pixelgrey/GREYS;
         blue = blue-(blue-cstack[csp].blue)*pixelgrey/GREYS;
         pixelcolor = gdImageColorResolve(page_imagep, red, green, blue);
       }
       gdImageSetPixel(page_imagep, hh + x, vv + y, pixelcolor);
      }
      pos++;
    }
  }
  /* This code saved _no_ execution time, strangely.
   * Also, it cannot gamma correct; needs that in loaded glyphs
   *
   * #ifdef HAVE_GDIMAGECREATETRUECOLOR 
   *   if (truecolor) 
   *     for( i=1; i<=ptr->glyph.nchars ; i++) {
   *       Color = gdImageColorResolveAlpha(page_imagep,Red,Green,Blue,
   *                                        128-128*i/ptr->glyph.nchars);
   *       gdImageChar(page_imagep, &(ptr->glyph),
   *                  hh - ptr->xOffset/shrinkfactor,
   *                 vv - ptr->yOffset/shrinkfactor,
   *                 i,Color);
   *       }
   *    else {
   *  #endif */
  return(ptr->tfmw);
}

Here is the caller graph for this function:

int32_t SetRule ( int32_t  ,
int32_t  ,
int32_t  ,
int32_t   
)

Definition at line 252 of file set.c.

{
  /*                               This routine will draw a \rule */
  int Color;
  pixels    width=0, height=0;

  if ( a > 0 && b > 0 ) {
    /* Calculate width and height, round up */
    width = (b+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
    height = (a+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
  }
  if (page_imagep != NULL) {
    if ((height>0) && (width>0)) {
      /* This code produces too dark rules. But what the hell. Grey
       * rules look fuzzy. */
      Color = gdImageColorResolve(page_imagep, 
                              cstack[csp].red,
                              cstack[csp].green,
                              cstack[csp].blue);
      /* +1 and -1 are because the Rectangle coords include last pixels */
      gdImageFilledRectangle(page_imagep,hh,vv-height+1,hh+width-1,vv,Color);
      DEBUG_PRINT(DEBUG_DVI,("\n  RULE \t%dx%d at (%d,%d)",
                 width, height, hh, vv));
    }
  } else {
    /* The +1's are because things are cut _at_that_coordinate_. */
    min(x_min,hh);
    min(y_min,vv-height+1);
    max(x_max,hh+width);
    max(y_max,vv+1);
  }
  return(b);
}
void SetSpecial ( char *  ,
int32_t  ,
int32_t  ,
int32_t   
)

Definition at line 234 of file special.c.

{
  char *buffer, *token;

  DEBUG_PRINT(DEBUG_DVI,(" '%.*s'",length,special));

  buffer = alloca(sizeof(char)*(length+1));
  if (buffer==NULL) 
    Fatal("Cannot allocate space for special string");

  strncpy(buffer,special,length);
  buffer[length]='\0';

  token = strtok(buffer," ");
  /********************** Color specials ***********************/
  if (strcmp(token,"background")==0) {
    token = strtok(NULL,"\0");
    background(token);
    return;
  }
  if (strcmp(token,"color")==0) {
    token = strtok(NULL,"\0");
    if (strncmp(token,"push",4)==0) {
      token = strtok(token," ");
      token = strtok(NULL,"\0");
      pushcolor(token);
    } else {
      if (strncmp(token,"pop",3)==0)
       popcolor();
      else 
       resetcolorstack(token);
    }
    return;
  }

  /******************* Postscript inclusion ********************/
  if (strncmp(token,"PSfile=",7)==0) { /* PSfile */
    char* psname = token+7;
    int llx=0,lly=0,urx=0,ury=0,rwi=0,rhi=0;
    int hresolution,vresolution;

    /* Remove quotation marks around filename */
    if (*psname=='"') {
      char* tmp;
      psname++;
      tmp=strrchr(psname,'"');
      if (tmp!=NULL) *tmp='\0';
    }

    while((token = strtok(NULL," ")) != NULL) {
      if (strncmp(token,"llx=",4)==0) llx = atoi(token+4);
      if (strncmp(token,"lly=",4)==0) lly = atoi(token+4);
      if (strncmp(token,"urx=",4)==0) urx = atoi(token+4);
      if (strncmp(token,"ury=",4)==0) ury = atoi(token+4);
      if (strncmp(token,"rwi=",4)==0) rwi = atoi(token+4);
      if (strncmp(token,"rhi=",4)==0) rhi = atoi(token+4);
    }
    
    /* Calculate resolution, and use our base resolution as a fallback. */
    /* The factor 10 is magic, the dvips graphicx driver needs this.    */
    hresolution = dpi*rwi/(urx - llx)/10;
    vresolution = dpi*rhi/(ury - lly)/10;
    if (vresolution==0) vresolution = hresolution;
    if (hresolution==0) hresolution = vresolution;
    if (hresolution==0) hresolution = vresolution = dpi;
    
    if (page_imagep != NULL) { /* Draw into image */
      char* psfile;
      gdImagePtr psimage=NULL;

      /*---------- Cache ----------*/
      char* cachename = NULL;
      gdImagePtr cacheimage=NULL;

      TEMPSTR(psfile,kpse_find_file(psname,kpse_pict_format,0));
      if (flags & CACHE_IMAGES) { /* Find cached image, if it exists */
       char *cachefile,*separator;

       cachename = alloca(sizeof(char)*(strlen(psname+5)));
       if (cachename==NULL) 
         Fatal("Cannot allocate space for cached image filename");
       strcpy(cachename,psname);
       separator = strrchr(cachename,'.');
       if (separator!=NULL)
         *separator='\0';
       strcat(cachename,".png");
       cachefile = kpse_find_file(cachename,kpse_pict_format,0);
       if (cachefile!=NULL) {
         FILE* cachefilep = fopen(cachefile,"rb");

         if (cachefilep!=NULL) {
           cacheimage = gdImageCreateFromPng(cachefilep);
           fclose(cachefilep);
         }
         free(cachefile);
       }
       psimage = cacheimage;
      }
      /*---------- End Cache ----------*/
      Message(BE_NONQUIET,"<%s",psname);
      if (psimage==NULL) {
       /* No cached image, convert postscript */
       if (psfile == NULL) {
         Warning("PS file %s not found, image will be left blank", psname );
         flags |= PAGE_GAVE_WARN;
       } else if (flags & NO_GHOSTSCRIPT) {
           Warning("GhostScript calls disallowed by --noghostscript", 
                  psfile );
           flags |= PAGE_GAVE_WARN;
       } else {
         psimage = ps2png(psfile, hresolution, vresolution, 
                        urx, ury, llx, lly);
         if ( psimage == NULL ) {
           Warning("Unable to convert %s to PNG, image will be left blank", 
                  psfile );
           flags |= PAGE_GAVE_WARN;
         }
       }
      }
      /*---------- Store Cache ----------*/
      if (flags & CACHE_IMAGES && cachename !=NULL && 
         cacheimage==NULL && psimage != NULL) {
       /* Cache image not found, save converted postscript */
       FILE* cachefilep = fopen(cachename,"wb");
       if (cachefilep!=NULL) {
         gdImagePng(psimage,cachefilep);
         fclose(cachefilep);
       } else
         Warning("Unable to cache %s as PNG", psfile );
      } 
      /*---------- End Store Cache ----------*/
      if (psimage!=NULL) {
       DEBUG_PRINT(DEBUG_DVI,
                  ("\n  PS-PNG INCLUDE \t%s (%d,%d) res %dx%d at (%d,%d)",
                   psfile,
                   gdImageSX(psimage),gdImageSY(psimage),
                   hresolution,vresolution,
                   hh, vv));
       gdImageCopy(page_imagep, psimage, 
                  hh, vv-gdImageSY(psimage),
                  0,0,
                  gdImageSX(psimage),gdImageSY(psimage));
       gdImageDestroy(psimage);
      }
      Message(BE_NONQUIET,">");
    } else { /* Don't draw */
      int pngheight,pngwidth;
      
      /* Convert from postscript 72 dpi resolution to our given resolution */
      pngheight = (vresolution*(ury - lly)+71)/72; /* +71: do 'ceil' */
      pngwidth  = (hresolution*(urx - llx)+71)/72;
      DEBUG_PRINT(DEBUG_DVI,("\n  PS-PNG INCLUDE \t(%d,%d)", 
                 pngwidth,pngheight));
      min(x_min,hh);
      min(y_min,vv-pngheight);
      max(x_max,hh+pngwidth);
      max(y_max,vv);
    }
    return;
  }

  /* preview-latex' tightpage option */
  if (strcmp(buffer,"!userdict")==0 
      && strcmp(buffer+10,"begin/bop-hook{7{currentfile token not{stop}if 65781.76 div DVImag mul}repeat 72 add 72 2 copy gt{exch}if 4 2 roll neg 2 copy lt{exch}if dup 0 gt{pop 0 exch}{exch dup 0 lt{pop 0}if}ifelse 720 add exch 720 add 3 1 roll 4{5 -1 roll add 4 1 roll}repeat <</PageSize[5 -1 roll 6 index sub 5 -1 roll 5 index sub]/PageOffset[7 -2 roll [1 1 dtransform exch]{0 ge{neg}if exch}forall]>>setpagedevice//bop-hook exec}bind def end")==0) {
    if (page_imagep==NULL) 
      Message(BE_NONQUIET,"preview-latex's tightpage option detected, will use its bounding box.\n");
    flags |= PREVIEW_LATEX_TIGHTPAGE;
    return;
  }
  if (strncmp(token,"ps::",4)==0) {
    /* Hokay, decode bounding box */
    dviunits adj_llx,adj_lly,adj_urx,adj_ury,ht,dp,wd;
    adj_llx = atoi(token+4);
    token = strtok(NULL," ");
    adj_lly = atoi(token);
    token = strtok(NULL," ");
    adj_urx = atoi(token);
    token = strtok(NULL," ");
    adj_ury = atoi(token);
    token = strtok(NULL," ");
    ht = atoi(token);
    token = strtok(NULL," ");
    dp = atoi(token);
    token = strtok(NULL," ");
    wd = atoi(token);
    if (wd>0) {
      x_offset_tightpage = 
       (-adj_llx+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
      x_width_tightpage  = x_offset_tightpage
       +(wd+adj_urx+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
    } else {
      x_offset_tightpage = 
       (-wd+adj_urx+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
      x_width_tightpage  = x_offset_tightpage
       +(-adj_llx+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
    }
    /* y-offset = height - 1 */
    y_offset_tightpage = 
      (((ht>0)?ht:0)+adj_ury+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor-1;
    y_width_tightpage  = y_offset_tightpage+1
      +(((dp>0)?dp:0)-adj_lly+dvi->conv*shrinkfactor-1)/dvi->conv/shrinkfactor;
    return;
  }

  if (strncmp(token,"header=",7)==0 || token[0]=='!') { /* header, ignored */
    if ( page_imagep != NULL )
      Warning("at (%ld,%ld) ignored header \\special{%.*s}.",
             hh, vv, length,special);
    return;
  }
  if (strncmp(token,"src:",4)==0) { /* source special */
    if ( page_imagep != NULL )
      Message(BE_NONQUIET," at (%ld,%ld) source \\special{%.*s}",
             hh, vv, length,special);
    return;
  }
  if ( page_imagep != NULL || flags & MODE_PICKY ) {
    Warning("at (%ld,%ld) unimplemented \\special{%.*s}.",
           hh, vv, length,special);
    flags |= PAGE_GAVE_WARN;
  }
}

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:

int32_t SNumRead ( unsigned char *  ,
register  int 
)

Definition at line 629 of file misc.c.

{
  int32_t x = (signed char) *(current)++; /* number being constructed */
  while(--n)
    x = (x << 8) | *(current)++;
  return(x);
}

Here is the caller graph for this function:

void StoreBackgroundColor ( struct page_list tpagep)

Definition at line 242 of file color.c.

{
  /* Background color changes affect the _whole_ page */
  tpagep->cstack[0].red = cstack[0].red;
  tpagep->cstack[0].green = cstack[0].green;
  tpagep->cstack[0].blue = cstack[0].blue;
}

Here is the caller graph for this function:

void StoreColorStack ( struct page_list tpagep)

Definition at line 210 of file color.c.

{
  int i=0;

  DEBUG_PRINT(DEBUG_COLOR,("\n  STORE COLOR STACK:\t %d ", csp));
  tpagep->csp=csp;
  while ( i <= csp ) {
    DEBUG_PRINT(DEBUG_COLOR,("\n  COLOR STACK:\t %d (%d %d %d) ",i,
                          cstack[i].red, cstack[i].green, cstack[i].blue));
    tpagep->cstack[i].red = cstack[i].red;
    tpagep->cstack[i].green = cstack[i].green;
    tpagep->cstack[i].blue = cstack[i].blue;
    i++;
  }
}

Here is the caller graph for this function:

void stringrgb ( char *  colorstring,
int r,
int g,
int b 
)

Definition at line 123 of file color.c.

{
  char* token;

  DEBUG_PRINT(DEBUG_COLOR,("\n  COLOR SPEC:\t'%s' ",p));
  token=strtok(p," ");
  if (strcmp(token,"Black")==0) {
    p+=5;
    *r = *g = *b = 0;
  } else if (strcmp(token,"White")==0) {
    p+=5;
    *r = *g = *b = 255;
  } else if (strcmp(token,"gray")==0) {
    p+=4;
    *r = *g = *b = (int) (255 * toktof(strtok(NULL," ")));
  } else if (strcmp(token,"rgb")==0) {
    p+=3;
    *r = (int) (255 * toktof(strtok(NULL," ")));
    *g = (int) (255 * toktof(strtok(NULL," ")));
    *b = (int) (255 * toktof(strtok(NULL," ")));
  } else if (strncmp(p,"cmyk",4)==0) {
    double c,m,y,k;

    p+=4;
    c = toktof(strtok(NULL," "));
    m = toktof(strtok(NULL," "));
    y = toktof(strtok(NULL," "));
    k = toktof(strtok(NULL," "));
    *r = (int) (255 * ((1-c)*(1-k)));
    *g = (int) (255 * ((1-m)*(1-k)));
    *b = (int) (255 * ((1-y)*(1-k)));
  } else {
    struct colorname *tmp;

    if (colornames==NULL) 
      LoadDvipsNam();
    tmp=colornames;
    while(tmp!=NULL && tmp->name!=NULL && strcmp(tmp->name,token)) 
      tmp++;
    if (tmp!=NULL && tmp->name!=NULL) {
      /* One-level recursion */
      char* colorspec=alloca(sizeof(char)*strlen(tmp->color+1));
      strcpy(colorspec,tmp->color);
      stringrgb(colorspec,r,g,b);
    } else {
      char* t2=strtok(NULL,"");  
      if (t2!=NULL) 
       Warning("Unimplemented color specification '%s %s'\n",p,t2);
      else 
       Warning("Unimplemented color specification '%s'\n",p);
      flags |= PAGE_GAVE_WARN;
    }
  }
  DEBUG_PRINT(DEBUG_COLOR,("(%d %d %d) ",*r,*g,*b))
}

Here is the call graph for this function:

Here is the caller graph for this function:

void UnMmapFile ( struct filemmap fmmap)

Definition at line 760 of file misc.c.

{
  if (fmmap->mmap!=NULL) {
#ifndef MIKTEX
# ifdef HAVE_MMAP
    if (munmap(fmmap->mmap,fmmap->size))
      Warning("cannot munmap file at 0x%X",fmmap->mmap);
    if (close(fmmap->fd))
      Warning("cannot close file descriptor %d",fmmap->fd);
# else /* HAVE_MMAP */
    free(fmmap->mmap);
# endif /* HAVE_MMAP */
#else  /* MIKTEX */
    UnmapViewOfFile (fmmap->mmap);
    CloseHandle (fmmap->hMap);
    CloseHandle (fmmap->hFile);
#endif /* MIKTEX */
  }
  fmmap->mmap=NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t UNumRead ( unsigned char *  ,
register  int 
)

Definition at line 621 of file misc.c.

{
  uint32_t x = (unsigned char) *(current)++; /* number being constructed */
  while(--n) 
    x = (x << 8) | *(current)++;
  return(x);
}

Here is the caller graph for this function:

void Warning ( char *  fmt,
  ... 
)

Definition at line 670 of file misc.c.

{
  va_list args;

  va_start(args, fmt);

  if ( flags & BE_NONQUIET ) {
    fflush(stdout);
    fprintf(stderr, "%s warning: ", programname);
    vfprintf(stderr, fmt, args);
    fprintf(stderr, "\n");
    va_end(args);
  }
}

Here is the call graph for this function:

void WriteImage ( char *  ,
int   
)

Definition at line 73 of file set.c.

{
  char* pos;
  FILE* outfp=NULL;

  /* Transparent border */
  if (borderwidth>0) {
    int Transparent,bgcolor;
    pixels x_width,y_width;

    x_width=gdImageSX(page_imagep);
    y_width=gdImageSY(page_imagep);
    
    bgcolor = gdImageColorResolve(page_imagep,
                              cstack[0].red,cstack[0].green,cstack[0].blue);
    /* Set ANOTHER bg color, transparent this time */
    if (userbordercolor)
      Transparent = gdImageColorAllocate(page_imagep,
                                    bordercolor.red,bordercolor.green,bordercolor.blue); 
    else
      Transparent = gdImageColorAllocate(page_imagep,
                                    cstack[0].red,cstack[0].green,cstack[0].blue); 
    gdImageColorTransparent(page_imagep,Transparent); 
    ChangeColor(page_imagep,0,0,x_width-1,borderwidth-1,bgcolor,Transparent);
    ChangeColor(page_imagep,0,0,borderwidth-1,y_width-1,bgcolor,Transparent);
    ChangeColor(page_imagep,x_width-borderwidth,0,x_width-1,y_width-1,bgcolor,Transparent);
    ChangeColor(page_imagep,0,y_width-borderwidth,x_width-1,y_width-1,bgcolor,Transparent);
  }

  if ((pos=strchr(pngname,'%')) != NULL) {
    if (strchr(++pos,'%'))
      Fatal("too many %%'s in output file name");
    if (*pos == 'd' 
       || (*pos=='0' && pos[1]>='1' && pos[1]<='9' && pos[2]=='d')) {
      /* %d -> pagenumber, so add 9 string positions 
        since pagenumber max +-2^31 or +-2*10^9 */
      char* tempname = alloca(strlen(pngname)+9);
      sprintf(tempname,pngname,pagenum);
      pngname = tempname;
    } else {
      Fatal("unacceptible format spec. in output file name");
    }
  }
#ifdef HAVE_GDIMAGEGIF
  if (flags & GIF_OUTPUT && (pos=strrchr(pngname,'.')) != NULL 
      && strcmp(pos,".png")==0) {
    *(pos+1)='g';
    *(pos+2)='i';
    *(pos+3)='f';
  }
#endif
  if ((outfp = fopen(pngname,"wb")) == NULL)
      Fatal("Cannot open output file %s",pngname);
#ifdef HAVE_GDIMAGEGIF
  if (flags & GIF_OUTPUT) 
    gdImageGif(page_imagep,outfp);
  else
#endif
#ifdef HAVE_GDIMAGEPNGEX
  gdImagePngEx(page_imagep,outfp,compression);
#else
  gdImagePng(page_imagep,outfp);
#endif
  fclose(outfp);
  DEBUG_PRINT(DEBUG_DVI,("\n  WROTE:   \t%s\n",pngname));
  DestroyImage();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 537 of file dvipng.h.

EXTERN struct dvi_color

Definition at line 528 of file dvipng.h.