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