]> www.fi.muni.cz Git - evince.git/blob - backend/dvi/mdvi-lib/mdvi.h
[windows] Guess texmf.cnf location from mktexpk executable
[evince.git] / backend / dvi / mdvi-lib / mdvi.h
1 /*
2  * Copyright (C) 2000, Matias Atria
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18 #ifndef _MDVI_DVI_H
19 #define _MDVI_DVI_H 1
20
21 #include <stdio.h>
22 #include <sys/types.h>
23 #include <math.h>
24
25 #include "sysdeps.h"
26 #include "bitmap.h"
27 #include "common.h"
28 #include "defaults.h"
29 #include "dviopcodes.h"
30
31 typedef struct _DviGlyph DviGlyph;
32 typedef struct _DviDevice DviDevice;
33 typedef struct _DviFontChar DviFontChar;
34 typedef struct _DviFontRef DviFontRef;
35 typedef struct _DviFontInfo DviFontInfo;
36 typedef struct _DviFont DviFont;
37 typedef struct _DviState DviState;
38 typedef struct _DviPageSpec *DviPageSpec;
39 typedef struct _DviParams DviParams;
40 typedef struct _DviBuffer DviBuffer;
41 typedef struct _DviContext DviContext;
42 typedef struct _DviRange DviRange;
43 typedef struct _DviColorPair DviColorPair;
44 typedef struct _DviSection DviSection;
45 typedef struct _TFMChar TFMChar;
46 typedef struct _TFMInfo TFMInfo;
47 typedef struct _DviFontSearch DviFontSearch;
48 /* this is an opaque type */
49 typedef struct _DviFontClass DviFontClass;
50
51 typedef void (*DviFreeFunc) __PROTO((void *));
52 typedef void (*DviFree2Func) __PROTO((void *, void *));
53
54 typedef Ulong   DviColor;
55
56 #ifdef TRUE
57 #undef TRUE
58 #endif
59 #ifdef FALSE
60 #undef FALSE
61 #endif
62
63 typedef enum {
64         FALSE   = 0,
65         TRUE    = 1     
66 } DviBool;
67
68 #include "hash.h"
69 #include "paper.h"
70
71 /* 
72  * information about a page:
73  *   pagenum[0] = offset to BOP
74  *   pagenum[1], ..., pagenum[10] = TeX \counters
75  */
76 typedef long    PageNum[11];
77
78 /* this structure contains the platform-specific information 
79  * required to interpret a DVI file */
80
81 typedef void (*DviGlyphDraw)    __PROTO((DviContext *context, 
82                                           DviFontChar *glyph,
83                                           int x, int y));
84
85 typedef void (*DviRuleDraw)     __PROTO((DviContext *context,
86                                           int x, int y, 
87                                           Uint width, Uint height, int fill));
88
89 typedef int (*DviColorScale)    __PROTO((void *device_data,
90                                          Ulong *pixels, 
91                                          int npixels,
92                                          Ulong foreground, 
93                                          Ulong background,
94                                          double gamma,
95                                          int density));
96 typedef void *(*DviCreateImage) __PROTO((void *device_data,
97                                          Uint width,
98                                          Uint height,
99                                          Uint bpp));
100 typedef void (*DviFreeImage)    __PROTO((void *image));
101 typedef void (*DviPutPixel)     __PROTO((void *image, int x, int y, Ulong color));
102 typedef void (*DviDevDestroy)   __PROTO((void *data));
103 typedef void (*DviRefresh)      __PROTO((DviContext *dvi, void *device_data));
104 typedef void (*DviSetColor)     __PROTO((void *device_data, Ulong, Ulong));
105 typedef void (*DviPSDraw)       __PROTO((DviContext *context,
106                                          const char *filename, 
107                                          int x, int y,
108                                          Uint width, Uint height));
109
110 struct _DviDevice {
111         DviGlyphDraw    draw_glyph;
112         DviRuleDraw     draw_rule;
113         DviColorScale   alloc_colors;
114         DviCreateImage  create_image;
115         DviFreeImage    free_image;
116         DviPutPixel     put_pixel;
117         DviDevDestroy   dev_destroy;
118         DviRefresh      refresh;
119         DviSetColor     set_color;
120         DviPSDraw       draw_ps;
121         void *          device_data;
122 };
123
124 /*
125  * Fonts
126  */
127
128 #include "fontmap.h"
129
130 struct _TFMChar {
131         Int32   present;
132         Int32   advance;        /* advance */
133         Int32   height;         /* ascent */
134         Int32   depth;          /* descent */
135         Int32   left;           /* leftSideBearing */
136         Int32   right;          /* rightSideBearing */
137 };
138
139 struct _TFMInfo {
140         int     type; /* DviFontAFM, DviFontTFM, DviFontOFM */
141         Uint32  checksum;
142         Uint32  design;
143         int     loc;
144         int     hic;
145         char    coding[64];
146         char    family[64];
147         TFMChar *chars;
148 };
149
150 struct _DviGlyph {
151         short   x, y;   /* origin */
152         Uint    w, h;   /* dimensions */
153         void    *data;  /* bitmap or XImage */
154 };
155
156 typedef void (*DviFontShrinkFunc) 
157         __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *));
158 typedef int (*DviFontLoadFunc) __PROTO((DviParams *, DviFont *));
159 typedef int (*DviFontGetGlyphFunc) __PROTO((DviParams *, DviFont *, int));
160 typedef void (*DviFontFreeFunc) __PROTO((DviFont *));
161 typedef void (*DviFontResetFunc) __PROTO((DviFont *));
162 typedef char *(*DviFontLookupFunc) __PROTO((const char *, Ushort *, Ushort *));
163 typedef int (*DviFontEncodeFunc) __PROTO((DviParams *, DviFont *, DviEncoding *));
164
165 struct _DviFontInfo {
166         char    *name;  /* human-readable format identifying string */
167         int     scalable; /* does it support scaling natively? */
168         DviFontLoadFunc         load;
169         DviFontGetGlyphFunc     getglyph;
170         DviFontShrinkFunc       shrink0;
171         DviFontShrinkFunc       shrink1;
172         DviFontFreeFunc         freedata;
173         DviFontResetFunc        reset;
174         DviFontLookupFunc       lookup;
175         int                     kpse_type;
176         void *                  private;
177 };
178
179 struct _DviFontChar {
180         Uint32  offset;
181         Int16   code;           /* format-dependent, not used by MDVI */
182         Int16   width;
183         Int16   height;
184         Int16   x;
185         Int16   y;
186         Int32   tfmwidth;
187         Ushort  flags;
188 #ifdef __STRICT_ANSI__
189         Ushort  loaded;
190         Ushort  missing;
191 #else
192         Ushort  loaded : 1,
193                 missing : 1;
194 #endif
195         Ulong   fg;
196         Ulong   bg;
197         BITMAP  *glyph_data;
198         /* data for shrunk bitimaps */
199         DviGlyph glyph;
200         DviGlyph shrunk;
201         DviGlyph grey;
202 };
203
204 struct _DviFontRef {
205         DviFontRef *next;
206         DviFont *ref;
207         Int32   fontid;
208 };
209
210 typedef enum {
211         DviFontAny  = -1,
212         DviFontPK   = 0,
213         DviFontGF   = 1,
214         DviFontVF   = 2,
215         DviFontTFM  = 3,
216         DviFontT1   = 4,
217         DviFontTT   = 5,
218         DviFontAFM  = 6,
219         DviFontOFM  = 7
220 } DviFontType;
221
222 struct _DviFontSearch {
223         int     id;
224         Ushort  hdpi;
225         Ushort  vdpi;
226         Ushort  actual_hdpi;
227         Ushort  actual_vdpi;
228         const char *wanted_name;
229         const char *actual_name;
230         DviFontClass *curr;
231         DviFontInfo  *info;
232 };
233
234 /* this is a kludge, I know */
235 #define ISVIRTUAL(font) ((font)->search.info->getglyph == NULL)
236 #define SEARCH_DONE(s)  ((s).id < 0)
237 #define SEARCH_INIT(s, name, h, v) do { \
238         (s).id = 0; \
239         (s).curr = NULL; \
240         (s).hdpi = (h); \
241         (s).vdpi = (v); \
242         (s).wanted_name = (name); \
243         (s).actual_name = NULL; \
244         } while(0)
245
246 struct _DviFont {
247         DviFont *next;
248         DviFont *prev;
249         int     type;
250         Int32   checksum;
251         int     hdpi;
252         int     vdpi;
253         Int32   scale;
254         Int32   design;
255         FILE    *in;
256         char    *fontname;
257         char    *filename;
258         int     links;
259         int     loc;
260         int     hic;
261         Uint    flags;
262         DviFontSearch   search;
263         DviFontChar     *chars;
264         DviFontRef      *subfonts;
265         void    *private;
266 };
267
268 /*
269  * Dvi context
270  */
271
272 typedef enum {
273         MDVI_ORIENT_TBLR  = 0,  /* top to bottom, left to right */
274         MDVI_ORIENT_TBRL  = 1,  /* top to bottom, right to left */
275         MDVI_ORIENT_BTLR  = 2,  /* bottom to top, left to right */
276         MDVI_ORIENT_BTRL  = 3,  /* bottom to top, right to left */
277         MDVI_ORIENT_RP90  = 4,  /* rotated +90 degrees (counter-clockwise) */
278         MDVI_ORIENT_RM90  = 5,  /* rotated -90 degrees (clockwise) */
279         MDVI_ORIENT_IRP90 = 6,  /* flip horizontally, then rotate by +90 */
280         MDVI_ORIENT_IRM90 = 7   /* rotate by -90, then flip horizontally */
281 } DviOrientation;
282
283 typedef enum {
284         MDVI_PAGE_SORT_UP,      /* up, using \counter0 */
285         MDVI_PAGE_SORT_DOWN,    /* down, using \counter0 */
286         MDVI_PAGE_SORT_RANDOM,  /* randomly */
287         MDVI_PAGE_SORT_DVI_UP,  /* up, by location in DVI file */
288         MDVI_PAGE_SORT_DVI_DOWN,        /* down, by location in DVI file */
289         MDVI_PAGE_SORT_NONE     /* don't sort */
290 } DviPageSort;
291
292 struct _DviParams {
293         double  mag;            /* magnification */
294         double  conv;           /* horizontal DVI -> pixel */
295         double  vconv;          /* vertical DVI -> pixel */
296         double  tfm_conv;       /* TFM -> DVI */
297         double  gamma;          /* gamma correction factor */
298         Uint    dpi;            /* horizontal resolution */
299         Uint    vdpi;           /* vertical resolution */
300         int     hshrink;        /* horizontal shrinking factor */
301         int     vshrink;        /* vertical shrinking factor */
302         Uint    density;        /* pixel density */
303         Uint    flags;          /* flags (see MDVI_PARAM macros) */
304         int     hdrift;         /* max. horizontal drift */
305         int     vdrift;         /* max. vertical drift */
306         int     vsmallsp;       /* small vertical space */
307         int     thinsp;         /* small horizontal space */
308         int     layer;          /* visible layer (for layered DVI files) */
309         Ulong   fg;             /* foreground color */
310         Ulong   bg;             /* background color */
311         DviOrientation  orientation;    /* page orientation */
312         int     base_x;
313         int     base_y;
314 };
315
316 typedef enum {
317         MDVI_PARAM_LAST         = 0,
318         MDVI_SET_DPI            = 1,
319         MDVI_SET_XDPI           = 2,
320         MDVI_SET_YDPI           = 3,
321         MDVI_SET_SHRINK         = 4,
322         MDVI_SET_XSHRINK        = 5,
323         MDVI_SET_YSHRINK        = 6,
324         MDVI_SET_GAMMA          = 7,
325         MDVI_SET_DENSITY        = 8,
326         MDVI_SET_MAGNIFICATION  = 9,
327         MDVI_SET_DRIFT          = 10,
328         MDVI_SET_HDRIFT         = 11,
329         MDVI_SET_VDRIFT         = 12,
330         MDVI_SET_ORIENTATION    = 13,
331         MDVI_SET_FOREGROUND     = 14,
332         MDVI_SET_BACKGROUND     = 15
333 } DviParamCode;
334
335 struct _DviBuffer {
336         Uchar   *data;
337         size_t  size;           /* allocated size */
338         size_t  length;         /* amount of data buffered */
339         size_t  pos;            /* current position in buffer */
340         int     frozen;         /* can we free this data? */
341 };
342
343 /* DVI registers */
344 struct _DviState {
345         int     h;
346         int     v;
347         int     hh;
348         int     vv;
349         int     w;
350         int     x;
351         int     y;
352         int     z;      
353 };
354
355 struct _DviColorPair {
356         Ulong   fg;
357         Ulong   bg;
358 };
359
360 struct _DviContext {
361         char    *filename;      /* name of the DVI file */
362         FILE    *in;            /* from here we read */
363         char    *fileid;        /* from preamble */
364         int     npages;         /* number of pages */
365         int     currpage;       /* currrent page (0 based) */
366         int     depth;          /* recursion depth */
367         DviBuffer buffer;       /* input buffer */
368         DviParams params;       /* parameters */
369         DviPaper  paper;        /* paper type */
370         Int32   num;            /* numerator */
371         Int32   den;            /* denominator */
372         DviFontRef *fonts;      /* fonts used in this file */
373         DviFontRef **fontmap;   /* for faster id lookups */
374         DviFontRef *currfont;   /* current font */
375         int     nfonts;         /* # of fonts used in this job */
376         Int32   dvimag;         /* original magnification */
377         double  dviconv;        /* unshrunk scaling factor */
378         double  dvivconv;       /* unshrunk scaling factor (vertical) */
379         int     dvi_page_w;     /* unscaled page width */
380         int     dvi_page_h;     /* unscaled page height */
381         Ulong   modtime;        /* file modification time */
382         PageNum *pagemap;       /* page table */
383         DviState pos;           /* registers */
384         DviPageSpec *pagesel;   /* page selection data */
385         int     curr_layer;     /* current layer */
386         DviState *stack;        /* DVI stack */
387         int     stacksize;      /* stack depth */
388         int     stacktop;       /* stack pointer */
389         DviDevice device;       /* device-specific routines */
390         Ulong   curr_fg;        /* rendering color */
391         Ulong   curr_bg;
392
393         DviColorPair *color_stack;
394         int     color_top;
395         int     color_size;
396
397         DviFontRef *(*findref) __PROTO((DviContext *, Int32));
398         void    *user_data;     /* client data attached to this context */
399 };
400
401 typedef enum {
402         MDVI_RANGE_BOUNDED,     /* range is finite */
403         MDVI_RANGE_LOWER,       /* range has a lower bound */
404         MDVI_RANGE_UPPER,       /* range has an upper bound */
405         MDVI_RANGE_UNBOUNDED    /* range has no bounds at all */
406 } DviRangeType;
407
408 struct _DviRange {
409         DviRangeType type;      /* one of the above */
410         int     from;           /* lower bound */
411         int     to;             /* upper bound */
412         int     step;           /* step */
413 };
414
415
416 typedef void (*DviSpecialHandler) 
417         __PROTO((DviContext *dvi, const char *prefix, const char *arg));
418
419 #define RANGE_HAS_LOWER(x) \
420         ((x) == MDVI_RANGE_BOUNDED || (x) == MDVI_RANGE_LOWER)
421 #define RANGE_HAS_UPPER(x) \
422         ((x) == MDVI_RANGE_BOUNDED || (x) == MDVI_RANGE_UPPER)
423
424 /*
425  * Macros and prototypes
426  */
427
428 #define MDVI_PARAM_ANTIALIASED  1
429 #define MDVI_PARAM_MONO         2
430 #define MDVI_PARAM_CHARBOXES    4
431 #define MDVI_PARAM_SHOWUNDEF    8
432 #define MDVI_PARAM_DELAYFONTS   16
433
434 /* 
435  * The FALLBACK priority class is reserved for font formats that
436  * contain no glyph information and are to be used as a last
437  * resort (e.g. TFM, AFM)
438  */
439 #define MDVI_FONTPRIO_FALLBACK  -3
440 #define MDVI_FONTPRIO_LOWEST    -2
441 #define MDVI_FONTPRIO_LOW       -1
442 #define MDVI_FONTPRIO_NORMAL    0
443 #define MDVI_FONTPRIO_HIGH      1
444 #define MDVI_FONTPRIO_HIGHEST   2
445
446 #define MDVI_FONT_ENCODED       (1 << 0)
447
448 #define MDVI_GLYPH_EMPTY        ((void *)1)
449 /* does the glyph have a non-empty bitmap/image? */
450 #define MDVI_GLYPH_NONEMPTY(x)  ((x) && (x) != MDVI_GLYPH_EMPTY)
451 /* has the glyph been loaded from disk? */
452 #define MDVI_GLYPH_UNSET(x)     ((x) == NULL)
453 /* do we have only a bounding box for this glyph? */
454 #define MDVI_GLYPH_ISEMPTY(x)   ((x) == MDVI_GLYPH_EMPTY)
455
456 #define MDVI_ENABLED(d,x)       ((d)->params.flags & (x))
457 #define MDVI_DISABLED(d,x)      !MDVI_ENABLED((d), (x))
458
459 #define MDVI_LASTPAGE(d)        ((d)->npages - 1)
460 #define MDVI_NPAGES(d)          (d)->npages
461 #define MDVI_VALIDPAGE(d,p)     ((p) >= 0 && (p) <= MDVI_LASTPAGE(d))
462 #define MDVI_FLAGS(d)           (d)->params.flags
463 #define MDVI_SHRINK_FROM_DPI(d) Max(1, (d) / 75)
464 #define MDVI_CURRFG(d)          (d)->curr_fg
465 #define MDVI_CURRBG(d)          (d)->curr_bg
466
467 #define pixel_round(d,v)        (int)((d)->params.conv * (v) + 0.5)
468 #define vpixel_round(d,v)       (int)((d)->params.vconv * (v) + 0.5)
469 #define rule_round(d,v)         (int)((d)->params.conv * (v) + 0.99999) /*9999999)*/
470 #define vrule_round(d,v)        (int)((d)->params.vconv * (v) + 0.99999)
471
472 extern int      mdvi_reload __PROTO((DviContext *, DviParams *));
473 extern void     mdvi_setpage __PROTO((DviContext *, int));
474 extern int      mdvi_dopage __PROTO((DviContext *, int));
475 extern void     mdvi_shrink_glyph __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *));
476 extern void     mdvi_shrink_box __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *));
477 extern void     mdvi_shrink_glyph_grey __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *));
478 extern int      mdvi_find_tex_page __PROTO((DviContext *, int));
479 extern int      mdvi_configure __PROTO((DviContext *, DviParamCode, ...));
480
481 extern int      get_tfm_chars __PROTO((DviParams *, DviFont *, TFMInfo *, int));
482 extern int      tfm_load_file __PROTO((const char *, TFMInfo *));
483 extern int      afm_load_file __PROTO((const char *, TFMInfo *));
484 extern TFMInfo *get_font_metrics __PROTO((const char *, int, const char *));
485 extern char    *lookup_font_metrics __PROTO((const char *, int *));
486 extern void     free_font_metrics __PROTO((TFMInfo *));
487 extern void     flush_font_metrics __PROTO((void));
488
489 #define get_metrics(name)       get_font_metrics((name), DviFontAny, NULL)
490
491 extern void     mdvi_sort_pages __PROTO((DviContext *, DviPageSort));
492
493 extern void mdvi_init_kpathsea __PROTO((const char *, const char *, const char *, int, const char *));
494
495 extern DviContext* mdvi_init_context __PROTO((DviParams *, DviPageSpec *, const char *));
496 extern void     mdvi_destroy_context __PROTO((DviContext *));
497
498 /* helper macros that call mdvi_configure() */
499 #define mdvi_config_one(d,x,y)  mdvi_configure((d), (x), (y), MDVI_PARAM_LAST)
500 #define mdvi_set_dpi(d,x)       mdvi_config_one((d), MDVI_SET_DPI, (x))
501 #define mdvi_set_xdpi(d,x)      mdvi_config_one((d), MDVI_SET_XDPI, (x))
502 #define mdvi_set_ydpi(d,x)      mdvi_config_one((d), MDVI_SET_YDPI, (x))
503 #define mdvi_set_hshrink(d,h)   mdvi_config_one((d), MDVI_SET_XSHRINK, (h))
504 #define mdvi_set_vshrink(d,h)   mdvi_config_one((d), MDVI_SET_YSHRINK, (h))
505 #define mdvi_set_gamma(d,g)     mdvi_config_one((d), MDVI_SET_GAMMA, (g))
506 #define mdvi_set_density(d,x)   mdvi_config_one((d), MDVI_SET_DENSITY, (x))
507 #define mdvi_set_drift(d,x)     mdvi_config_one((d), MDVI_SET_DRIFT, (x))
508 #define mdvi_set_hdrift(d,h)    mdvi_config_one((d), MDVI_SET_HDRIFT, (h))
509 #define mdvi_set_vdrift(d,v)    mdvi_config_one((d), MDVI_SET_VDRIFT, (v))
510 #define mdvi_set_mag(d,m) \
511         mdvi_config_one((d), MDVI_SET_MAGNIFICATION, (m))
512 #define mdvi_set_foreground(d,x) \
513         mdvi_config_one((d), MDVI_SET_FOREGROUND, (x))
514 #define mdvi_set_background(d,x) \
515         mdvi_config_one((d), MDVI_SET_BACKGROUND, (x))
516 #define mdvi_set_orientation(d,x) \
517         mdvi_config_one((d), MDVI_SET_ORIENTATION, (x))
518 #define mdvi_set_shrink(d,h,v)  \
519         mdvi_configure((d), MDVI_SET_XSHRINK, (h), \
520         MDVI_SET_YSHRINK, (v), MDVI_PARAM_LAST)
521
522 extern DviRange* mdvi_parse_range __PROTO((const char *, DviRange *, int *, char **));
523 extern DviPageSpec* mdvi_parse_page_spec __PROTO((const char *));
524 extern void mdvi_free_page_spec __PROTO((DviPageSpec *));
525 extern int mdvi_in_range __PROTO((DviRange *, int, int));
526 extern int mdvi_range_length __PROTO((DviRange *, int));
527 extern int mdvi_page_selected __PROTO((DviPageSpec *, PageNum, int));
528
529 /* Specials */
530 extern int mdvi_register_special __PROTO((
531         const char *label,
532         const char *prefix,
533         const char *regex,
534         DviSpecialHandler handler,
535         int replace));
536 extern int mdvi_unregister_special __PROTO((const char *prefix));
537 extern int mdvi_do_special __PROTO((DviContext *dvi, char *dvi_special));
538 extern void mdvi_flush_specials __PROTO((void));
539
540 /* Fonts */
541
542 #define MDVI_FONTSEL_BITMAP     (1 << 0)
543 #define MDVI_FONTSEL_GREY       (1 << 1)
544 #define MDVI_FONTSEL_GLYPH      (1 << 2)
545
546 #define FONTCHAR(font, code)    \
547         (((code) < font->loc || (code) > font->hic || !(font)->chars) ? \
548                 NULL : &font->chars[(code) - (font)->loc])
549 #define FONT_GLYPH_COUNT(font) ((font)->hic - (font)->loc + 1)
550
551 #define glyph_present(x) ((x) && (x)->offset)
552
553 /* create a reference to a font */
554 extern DviFontRef *font_reference __PROTO((DviParams *params, 
555                                            Int32 dvi_id, 
556                                            const char *font_name, 
557                                            Int32 checksum, 
558                                            int xdpi,
559                                            int ydpi,
560                                            Int32 scale_factor));
561
562 /* drop a reference to a font */
563 extern void font_drop_one __PROTO((DviFontRef *));
564
565 /* drop a chain of references */
566 extern void font_drop_chain __PROTO((DviFontRef *));
567
568 /* destroy selected information for a glyph */
569 extern void font_reset_one_glyph __PROTO((DviDevice *, DviFontChar *, int));
570
571 /* destroy selected information for all glyphs in a font */
572 extern void font_reset_font_glyphs __PROTO((DviDevice *, DviFont *, int));
573
574 /* same for a chain of font references */
575 extern void font_reset_chain_glyphs __PROTO((DviDevice *, DviFontRef *, int));
576
577 extern void font_finish_definitions __PROTO((DviContext *));
578
579 /* lookup an id # in a reference chain */
580 extern DviFontRef* font_find_flat __PROTO((DviContext *, Int32));
581 extern DviFontRef* font_find_mapped __PROTO((DviContext *, Int32));
582
583 /* called to reopen (or rewind) a font file */
584 extern int font_reopen __PROTO((DviFont *));
585
586 /* reads a glyph from a font, and makes all necessary transformations */
587 extern DviFontChar* font_get_glyph __PROTO((DviContext *, DviFont *, int));
588
589 /* transform a glyph according to the given orientation */
590 extern void font_transform_glyph __PROTO((DviOrientation, DviGlyph *));
591
592 /* destroy all fonts that are not being used, returns number of fonts freed */
593 extern int font_free_unused __PROTO((DviDevice *));
594
595 #define font_free_glyph(dev, font, code) \
596         font_reset_one_glyph((dev), \
597         FONTCHAR((font), (code)), MDVI_FONTSEL_GLYPH)
598
599 extern int mdvi_encode_font __PROTO((DviParams *, DviFont *));
600
601
602 /* font lookup functions */
603 extern int mdvi_register_font_type __PROTO((DviFontInfo *, int));
604 extern char **mdvi_list_font_class __PROTO((int));
605 extern int mdvi_get_font_classes __PROTO((void));
606 extern int mdvi_unregister_font_type __PROTO((const char *, int));
607 extern char *mdvi_lookup_font __PROTO((DviFontSearch *));
608 extern DviFont *mdvi_add_font __PROTO((const char *, Int32, int, int, Int32));
609 extern int mdvi_font_retry __PROTO((DviParams *, DviFont *));
610
611 /* Miscellaneous */
612
613 extern int mdvi_set_logfile __PROTO((const char *));
614 extern int mdvi_set_logstream __PROTO((FILE *));
615 extern int mdvi_set_loglevel __PROTO((int));
616
617 #define mdvi_stop_logging(x) mdvi_set_logstream(NULL)
618
619 /* this will check the environment and then `texmf.cnf' for
620  * the given name changed to lowercase, and `_' changed to `-' */
621 extern char* mdvi_getenv __PROTO((const char *));
622
623 #endif /* _MDVI_DVI_H */