Back to index

tetex-bin  3.0
dvi-init.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1990-2004  Paul Vojta and the xdvik development team
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00017  * PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM,
00018  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  */
00023 
00024 #ifndef DVI_INIT_H_
00025 #define DVI_INIT_H_
00026 
00027 #include "xdvi-config.h"
00028 #include "xdvi.h"
00029 
00030 typedef enum {
00031     NO_ERROR = 0,
00032     WRONG_DVI_VERSION,
00033     DVI_CORRUPTED,
00034     NOT_A_DVI_FILE,
00035     POSTAMBLE_NO_POST,
00036     POSTAMBLE_NO_MATCH,
00037     POSTAMBLE_NON_FNTDEF,
00038     NOT_ALL_PIXEL_FILES_FOUND,
00039     NO_BOP_AT_PAGEDESC,
00040     FILE_HAS_ZERO_SIZE,
00041     FILE_DOESNT_EXIST,
00042     FILE_IS_DIRECTORY,
00043     PS_CONVERSION_FAILED,
00044     PDF_CONVERSION_FAILED,
00045     UNKNOWN_ERROR
00046 } dviErrFlagT;
00047 
00048 extern const char *get_dvi_error(dviErrFlagT flag);
00049 
00050 extern Boolean internal_open_dvi(const char *path, dviErrFlagT *errmsg, Boolean load_fonts);
00051 extern char *open_dvi_file_wrapper(const char *filename,
00052                                Boolean from_command_line,
00053                                Boolean open_new_instance,
00054                                Boolean *tried_dvi_ext,
00055                                Boolean from_file_history);
00056 extern char *get_tmp_dvi_name(void);
00057 
00058 /* font stuff */
00059 
00060 /*
00061  * Bitmap structure for raster ops.
00062  */
00063 struct bitmap {
00064     unsigned short  w, h;   /* width and height in pixels */
00065     short     bytes_wide;   /* scan line width in bytes */
00066     char     *bits;         /* pointer to the bits */
00067 };
00068 
00069 /*
00070  * Per-character information.
00071  * There is one of these for each character in a font (raster fonts only).
00072  * All fields are filled in at font definition time,
00073  * except for the bitmap, which is "faulted in"
00074  * when the character is first referenced.
00075  */
00076 struct glyph {
00077     long addr;                  /* address of bitmap in font file */
00078     long dvi_adv;        /* DVI units to move reference point */
00079     short x, y;                 /* x and y offset in pixels */
00080     struct bitmap bitmap;   /* bitmap for character */
00081     short x2, y2;        /* x and y offset in pixels for shrunken bitmap */
00082 #if GREY
00083 # if COLOR
00084     struct fgrec *fg;       /* fgrec for which these pixmaps are valid */
00085 # endif
00086     /* `2' means `shrunken' here */
00087     XImage *image2;         /* shrunken pixmap for antialiased character */
00088     char *pixmap2;       /* image data pointer for image2 */
00089     char *pixmap2_gc2;          /* separate image data for drawing image to globals.gc.fore2 */
00090 #endif /* GREY */
00091     struct bitmap bitmap2;  /* shrunken bitmap for character */
00092 };
00093 
00094 /*
00095  * Per character information for virtual fonts
00096  */
00097 struct macro {
00098        ubyte  *pos;         /* address of first byte of macro */
00099        ubyte  *end;         /* address of last+1 byte */
00100        long   dvi_adv;      /* DVI units to move reference point */
00101        Boolean       free_me;      /* if free(pos) should be called when */
00102                             /* freeing space */
00103 };
00104 
00105 /*
00106  * The layout of a font information block.
00107  * There is one of these for every loaded font or magnification thereof.
00108  * Duplicates are eliminated:  this is necessary because of possible recursion
00109  * in virtual fonts.
00110  *
00111  * Also note the strange units.  The design size is in 1/2^20 point
00112  * units (also called micro-points), and the individual character widths
00113  * are in the TFM file in 1/2^20 ems units, i.e., relative to the design size.
00114  *
00115  * We then change the sizes to SPELL units (unshrunk pixel / 2^16).
00116  */
00117 
00118 #define       NOMAGSTP (-29999)
00119 
00120 #define       FONT_IN_USE   1      /* used for housekeeping */
00121 #define       FONT_LOADED   2      /* if font file has been read */
00122 #define       FONT_VIRTUAL  4      /* if font is virtual */
00123 
00124 /* forward declarations */
00125 struct font;
00126 struct tn;
00127 
00128 typedef       void (*read_char_proc) (struct font *, wide_ubyte);
00129 
00130 struct font {
00131     struct font *next;             /* link to next font info block */
00132     char *fontname;         /* name of font */
00133     float fsize;            /* size information (dots per inch) */
00134     int magstepval;         /* magstep number * two, or NOMAGSTP */
00135     FILE *file;                    /* open font file or NULL */
00136     char *filename;         /* name of font file */
00137     long checksum;          /* checksum */
00138     unsigned short timestamp;      /* for LRU management of fonts */
00139     ubyte flags;            /* flags byte (see values below) */
00140     wide_ubyte maxchar;            /* largest character code */
00141     double dimconv;         /* size conversion factor */
00142     set_char_proc set_char_p;      /* proc used to set char */
00143     /* these fields are used by (loaded) raster fonts */
00144     read_char_proc read_char;      /* function to read bitmap */
00145     struct glyph *glyph;
00146     /* these fields are used by (loaded) virtual fonts */
00147     struct font **vf_table; /* list of fonts used by this vf */
00148     struct tn *vf_chain;    /* ditto, if TeXnumber >= VFTABLELEN */
00149     struct font *first_font;       /* first font defined */
00150     struct macro *macro;
00151     /* These were added for t1 use */
00152     int t1id;
00153     long scale;
00154 };
00155 
00156 struct tn {
00157     struct tn *next;        /* link to next TeXnumber info block */
00158     unsigned long TeXnumber;       /* font number (in DVI file) */
00159     struct font *fontp;            /* pointer to the rest of the info */
00160 };
00161 
00162 
00163 extern void reset_fonts(void);
00164 #if COLOR
00165 extern void reset_colors(void);
00166 extern void full_reset_colors(void);
00167 #endif
00168 extern void realloc_font(struct font *, wide_ubyte);
00169 extern void realloc_virtual_font(struct font *, wide_ubyte);
00170 extern Boolean load_font(struct font *, Boolean use_t1lib);
00171 extern struct font *define_font(Boolean load_font_now,
00172                             FILE *, wide_ubyte,
00173                             struct font *, struct font **, unsigned int,
00174                             struct tn **, Boolean *not_found_flag);
00175 extern void init_page(void);
00176 extern void form_dvi_property(void);
00177 extern Boolean dvi_file_changed(void);
00178 extern void remove_tmp_dvi_file(void);
00179 extern Boolean load_dvi_file(Boolean load_fonts, dviErrFlagT *errflag);
00180 extern void read_PK_index(struct font *, wide_bool);
00181 extern void read_GF_index(struct font *, wide_bool);
00182 extern unsigned long read_VF_index(struct font *, wide_bool);
00183 
00184 extern Boolean set_paper_type(const char *arg);
00185 
00186 extern Boolean find_postamble(FILE *fp, dviErrFlagT *errflag);
00187 extern Boolean read_postamble(FILE *fp, dviErrFlagT *errflag, Boolean load_fonts);
00188 extern void close_old_filep(void);
00189 extern Boolean process_preamble(FILE *fp, dviErrFlagT *errflag);
00190 
00191 extern FILE *file_exists(const char *path, dviErrFlagT *errflag);
00192 extern char *find_dvi_file(const char *filename, Boolean *tried_dvi_ext, Boolean from_file_history);
00193 #endif /* DVI_INIT_H_ */