Debian Codegraph @

texk/xdvik/dvi-init.h

raw
1 /*
2 * Copyright (c) 1990-2013 Paul Vojta and the xdvik development team
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
23
24 #ifndef DVI_INIT_H_
25 #define DVI_INIT_H_
26
27 #include "xdvi.h"
28
29 #if FREETYPE
30 # include <ft2build.h>
31 # include FT_FREETYPE_H
32 #endif
33
34 typedef enum {
35 NO_ERROR = 0,
36 WRONG_DVI_VERSION,
37 DVI_CORRUPTED,
38 NOT_A_DVI_FILE,
39 POSTAMBLE_NO_POST,
40 POSTAMBLE_NO_MATCH,
41 POSTAMBLE_NON_FNTDEF,
42 NOT_ALL_PIXEL_FILES_FOUND,
43 NO_BOP_AT_PAGEDESC,
44 FILE_HAS_ZERO_SIZE,
45 FILE_DOESNT_EXIST,
46 FILE_IS_DIRECTORY,
47 PS_CONVERSION_FAILED,
48 PDF_CONVERSION_FAILED,
49 UNKNOWN_ERROR
50 } dviErrFlagT;
51
52 extern const char *get_dvi_error(dviErrFlagT flag);
53
54 extern Boolean internal_open_dvi(const char *path, dviErrFlagT *errmsg,
55 #if DELAYED_MKTEXPK
56 Boolean read_fonts, Boolean initialize_fonts
57 #else
58 Boolean load_fonts
59 #endif
60 );
61 extern char *open_dvi_file_wrapper(const char *filename,
62 Boolean from_command_line,
63 Boolean open_new_instance,
64 Boolean *tried_dvi_ext,
65 Boolean from_file_history);
66 extern char *get_tmp_dvi_name(void);
67
68 /* font stuff */
69
70 /*
71 * Bitmap structure for raster ops.
72 */
73 struct bitmap {
74 unsigned short w, h; /* width and height in pixels */
75 short bytes_wide; /* scan line width in bytes */
76 char *bits; /* pointer to the bits */
77 };
78
79 /*
80 * Per-character information.
81 * There is one of these for each character in a font (non-virtual fonts only).
82 * All fields are filled in at font definition time,
83 * except for the bitmap, which is "faulted in"
84 * when the character is first referenced.
85 */
86 struct glyph {
87 long addr; /* address of bitmap in font file */
88 long dvi_adv; /* DVI units to move reference point */
89 short x, y; /* x and y offset in pixels */
90 struct bitmap bitmap; /* bitmap for character */
91 short x2, y2; /* x and y offset in pixels for shrunken bitmap */
92 #if GREY
93 # if COLOR
94 struct fgrec *fg; /* fgrec for which these pixmaps are valid */
95 # endif
96 /* `2' means `shrunken' here */
97 XImage *image2; /* shrunken pixmap for antialiased character */
98 char *pixmap2; /* image data pointer for image2 */
99 char *pixmap2_gc2; /* separate image data for drawing image to globals.gc.fore2 */
100 #endif /* GREY */
101 struct bitmap bitmap2; /* shrunken bitmap for character */
102 };
103
104 /*
105 * Per-character information for virtual fonts
106 */
107 struct macro {
108 ubyte *pos; /* address of first byte of macro */
109 ubyte *end; /* address of last+1 byte */
110 long dvi_adv; /* DVI units to move reference point */
111 Boolean free_me; /* if free(pos) should be called when */
112 /* freeing space */
113 };
114
115 /*
116 * The layout of a font information block.
117 * There is one of these for every loaded font or magnification thereof.
118 * Duplicates are eliminated: this is necessary because of possible recursion
119 * in virtual fonts.
120 *
121 * Also note the strange units. The design size is in 1/2^20 point
122 * units (also called micro-points), and the individual character widths
123 * are in the TFM file in 1/2^20 ems units, i.e., relative to the design size.
124 *
125 * We then change the sizes to SPELL units (unshrunk pixel / 2^16).
126 */
127
128 #define NOMAGSTP (-29999)
129
130 #define FONT_IN_USE 1 /* used for housekeeping */
131 #define FONT_LOADED 2 /* if font file has been read */
132 #define FONT_VIRTUAL 4 /* if font is virtual */
133
134 /* forward declarations */
135 struct font;
136 struct tn;
137
138 typedef void (*read_char_proc) (struct font *, wide_ubyte);
139
140 struct font {
141 struct font *next; /* link to next font info block */
142 char *fontname; /* name of font */
143 float fsize; /* size information (dots per inch) */
144 int magstepval; /* magstep number * two, or NOMAGSTP */
145 FILE *file; /* open font file or NULL */
146 const char *filename; /* name of font file */
147 long checksum; /* checksum */
148 unsigned short timestamp; /* for LRU management of fonts */
149 ubyte flags; /* flags byte (see values below) */
150 wide_ubyte maxchar; /* largest character code */
151 double dimconv; /* size conversion factor */
152 set_char_proc set_char_p; /* proc used to set char */
153 /* these fields are used by (loaded) non-virtual fonts */
154 read_char_proc read_char; /* function to read bitmap */
155 struct glyph *glyph;
156 /* these fields are used by (loaded) virtual fonts */
157 struct font **vf_table; /* list of fonts used by this vf */
158 struct tn *vf_chain; /* ditto, if TeXnumber >= VFTABLELEN */
159 struct font *first_font; /* first font defined */
160 struct macro *macro;
161 #if FREETYPE
162 /* these fields are used by (loaded) FreeType fonts */
163 struct ftfont *ft; /* master record for font (all sizes) */
164 double pixsize; /* scaled size of the font in pixels */
165 FT_Size size;
166 struct font *next_size; /* next font from same face */
167 #endif
168 };
169
170 struct tn {
171 struct tn *next; /* link to next TeXnumber info block */
172 unsigned long TeXnumber; /* font number (in DVI file) */
173 struct font *fontp; /* pointer to the rest of the info */
174 };
175
176
177 extern void reset_fonts(void);
178 #if COLOR
179 extern void reset_colors(void);
180 extern void full_reset_colors(void);
181 #endif
182 extern void realloc_font(struct font *, wide_ubyte);
183 extern void realloc_virtual_font(struct font *, wide_ubyte);
184 extern Boolean load_font(struct font *
185 #if DELAYED_MKTEXPK
186 , Boolean load_font_now
187 #endif
188 );
189
190 extern struct font *define_font(
191 #if DELAYED_MKTEXPK
192 Boolean read_fonts,
193 Boolean initialize_fonts,
194 #else
195 Boolean load_font_now,
196 #endif
197 FILE *,
198 wide_ubyte,
199 struct font *,
200 struct font **,
201 unsigned int,
202 struct tn **,
203 Boolean *not_found_flag);
204 extern void init_page(void);
205 extern void form_dvi_property(void);
206 extern Boolean dvi_file_changed(void);
207 extern Boolean load_dvi_file(
208 #if !DELAYED_MKTEXPK
209 Boolean load_fonts,
210 #endif
211 dviErrFlagT *errflag);
212 extern void read_PK_index(struct font *, wide_bool);
213 extern void read_GF_index(struct font *, wide_bool);
214 extern unsigned long read_VF_index(struct font *, wide_bool);
215
216 #if FREETYPE
217 extern Boolean load_ft_font(struct font *fontp);
218 #endif
219
220 extern Boolean set_paper_type(const char *arg);
221
222 extern Boolean find_postamble(FILE *fp, dviErrFlagT *errflag);
223 extern Boolean read_postamble(FILE *fp, dviErrFlagT *errflag,
224 #if DELAYED_MKTEXPK
225 Boolean read_fonts, Boolean initialize_fonts
226 #else
227 Boolean load_fonts
228 #endif
229 );
230 extern void close_old_filep(void);
231 extern Boolean process_preamble(FILE *fp, dviErrFlagT *errflag);
232
233 extern FILE *file_exists(const char *path, dviErrFlagT *errflag);
234 extern char *find_dvi_file(const char *filename, Boolean *tried_dvi_ext, Boolean from_file_history);
235 #endif /* DVI_INIT_H_ */