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