3 * Copyright (c) 1995-1998 Markku Rossi.
5 * Author: Markku Rossi <mtr@iki.fi>
9 * Enscript is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * Enscript is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Enscript. If not, see <http://www.gnu.org/licenses/>.
28 #define ___P(protos) protos
29 #else /* no PROTOTYPES */
30 #define ___P(protos) ()
31 #endif /* no PROTOTYPES */
34 /**********************************************************************
38 **********************************************************************/
42 #define AFM_TYPE_STRING 1
43 #define AFM_TYPE_NAME 2
44 #define AFM_TYPE_NUMBER 3
45 #define AFM_TYPE_INTEGER 4
46 #define AFM_TYPE_ARRAY 5
47 #define AFM_TYPE_BOOLEAN 6
49 typedef char *AFMString;
50 typedef char *AFMName;
51 typedef double AFMNumber;
52 typedef long AFMInteger;
60 typedef struct afm_array_st *AFMArray;
77 typedef struct afm_node_st AFMNode;
86 /* AFM file data structures. */
89 * Sorry! I know that those mixed case variable names are ugly,
90 * but this is the way how they are written in Adobe's document
91 * so I think that this is the best way for documentary reasons.
94 /* Global Font Information*/
95 struct global_font_information_st
101 AFMNumber FontBBox_llx;
102 AFMNumber FontBBox_lly;
103 AFMNumber FontBBox_urx;
104 AFMNumber FontBBox_ury;
107 AFMString EncodingScheme;
108 AFMInteger MappingScheme;
110 AFMString CharacterSet;
111 AFMInteger Characters;
112 AFMBoolean IsBaseFont;
120 AFMArray BlendAxisTypes;
121 AFMArray BlendDesignPositions;
122 AFMArray BlendDesignMap;
123 AFMArray WeightVector;
126 typedef struct global_font_information_st AFMGlobalFontInformation;
129 /* Writing Direction Metrics. */
130 struct writing_direction_metrics_st
133 AFMNumber UnderlinePosition;
134 AFMNumber UnderlineThickness;
135 AFMNumber ItalicAngle;
136 AFMNumber CharWidth_x;
137 AFMNumber CharWidth_y;
138 AFMBoolean IsFixedPitch;
141 typedef struct writing_direction_metrics_st AFMWritingDirectionMetrics;
144 /* Multiple Master Axis Information. */
145 struct multiple_master_axis_info_st
151 typedef struct multiple_master_axis_info_st AFMMultipleMasterAxisInformation;
154 /* Individual Character Metrics. */
162 typedef struct ligature_st AFMLigature;
164 /* Single individual character. */
165 struct individual_character_metrics_st
167 AFMInteger character_code; /* default charcode (-1 if not encoded) */
168 AFMNumber w0x; /* character width x in writing direction 0 */
169 AFMNumber w0y; /* character width y in writing direction 0 */
170 AFMNumber w1x; /* character width x in writing direction 1 */
171 AFMNumber w1y; /* character width y in writing direction 1 */
172 AFMName name; /* character name */
173 AFMNumber vv_x; /* local VVector x */
174 AFMNumber vv_y; /* local VVector y */
176 /* character bounding box. */
182 AFMNumber num_ligatures;
183 AFMLigature *ligatures;
186 typedef struct individual_character_metrics_st AFMIndividualCharacterMetrics;
191 /* Track Kerning Data. */
195 AFMNumber min_ptsize;
197 AFMNumber max_ptsize;
201 typedef struct track_kern_st AFMTrackKern;
204 /* Pair-Wise Kerning. */
205 struct pair_wise_kerning_st
213 typedef struct pair_wise_kerning_st AFMPairWiseKerning;
216 /* Composite fonts. */
218 /* Single composite component. */
219 struct composite_component_st
226 typedef struct composite_component_st AFMCompositeComponent;
231 AFMInteger num_components;
232 AFMCompositeComponent *components;
235 typedef struct composite_st AFMComposite;
238 /**********************************************************************
242 **********************************************************************/
246 #define UNITS_PER_POINT 1000
248 /* Successful operation. */
249 #define AFM_SUCCESS 0
252 * AFM information levels. The AFM libarary returns always Global
253 * Font information, Writing Direction Metrics and Individual
254 * Character Metrics. Other fields can be retrieved by defining some
255 * of the following flags to afm_open_{font, file}() functions.
257 #define AFM_I_MINIMUM 0x00
258 #define AFM_I_COMPOSITES 0x01
259 #define AFM_I_KERN_PAIRS 0x02
260 #define AFM_I_TRACK_KERNS 0x04
261 #define AFM_I_ALL 0xffffffff
264 * Flags for the encoding functions.
266 #define AFM_ENCODE_ACCEPT_COMPOSITES 0x01
268 typedef unsigned int AFMError;
270 typedef struct afm_handle_st *AFMHandle;
272 /* Supported encoding types. */
275 AFM_ENCODING_DEFAULT, /* Font's default encoding. */
276 AFM_ENCODING_ISO_8859_1, /* ISO-8859-1 */
277 AFM_ENCODING_ISO_8859_2, /* ISO-8859-2 */
278 AFM_ENCODING_ISO_8859_3, /* ISO-8859-3 */
279 AFM_ENCODING_ISO_8859_4, /* ISO-8859-4 */
280 AFM_ENCODING_ISO_8859_5, /* ISO-8859-5 */
281 AFM_ENCODING_ISO_8859_7, /* ISO-8859-7 */
282 AFM_ENCODING_ISO_8859_9, /* ISO-8859-9 */
283 AFM_ENCODING_ISO_8859_10, /* ISO-8859-10 */
284 AFM_ENCODING_IBMPC, /* IBM PC */
285 AFM_ENCODING_ASCII, /* 7 bit ASCII */
286 AFM_ENCODING_MAC, /* Mac */
287 AFM_ENCODING_VMS, /* VMS multinational */
288 AFM_ENCODING_HP8, /* HP Roman-8 */
289 AFM_ENCODING_KOI8 /* Adobe Standard Cyrillic Font KOI8 */
292 /* Special encoding types for individual characters. */
293 #define AFM_ENC_NONE ((void *) 0)
294 #define AFM_ENC_NON_EXISTENT ((void *) 1)
297 /* AFM information for a single PostScript font. */
301 /* AFM Library's private data. */
302 struct afm_font_private_data_st *private;
304 AFMNumber version; /* AFM format specification version number. */
305 unsigned int info_level;
308 * Current font encoding. Following values are valid:
310 * AFM_ENC_NONE character is not encoded
311 * AFM_ENC_NON_EXISTENT character is encoded, but font does not
312 * have the specified character
313 * <pointer to character's metrics>
314 * character is encoded and it exists in font
316 AFMIndividualCharacterMetrics *encoding[256];
318 AFMGlobalFontInformation global_info;
319 AFMWritingDirectionMetrics writing_direction_metrics[2];
321 AFMInteger num_character_metrics;
322 AFMIndividualCharacterMetrics *character_metrics;
324 AFMInteger num_composites;
325 AFMComposite *composites;
327 AFMInteger num_kern_pairs;
328 AFMPairWiseKerning *kern_pairs;
330 AFMInteger num_track_kerns;
331 AFMTrackKern *track_kerns;
334 typedef struct afm_font_st *AFMFont;
339 * Prototypes for public functions.
343 * Format error <error> to human readable format to buffer <buf>.
344 * Buffer must be long enough for error messages (256 bytes is good).
346 void afm_error_to_string ___P ((AFMError error, char *buf));
349 * Open AFM library. <path> specifies the search path for the AFM
350 * files. A handle to the library is returned in <handle_return>.
352 AFMError afm_create ___P ((const char *path, unsigned int verbose_level,
353 AFMHandle *handle_return));
356 * Close AFM library handle <handle>.
358 AFMError afm_destroy ___P ((AFMHandle handle));
361 * Set AFM library's verbose level to <level>. Value 0 means "no output".
363 AFMError afm_set_verbose ___P ((AFMHandle handle, unsigned int level));
366 * Return a prefix to the font <fontname>'s data. Various font
367 * resource file names can be constructed from the returned prefix:
371 * Returned prefix belongs to AFM library, user should not modify it.
373 AFMError afm_font_prefix ___P ((AFMHandle handle, const char *fontname,
374 const char **prefix_return));
377 * Open font <name> and return font handle in <font_return>.
379 AFMError afm_open_font ___P ((AFMHandle handle, unsigned int info_level,
380 const char *name, AFMFont *font_return));
383 * Open AFM file <filename> and return font handle in <font_return>.
385 AFMError afm_open_file ___P ((AFMHandle handle, unsigned int info_level,
386 const char *filename, AFMFont *font_return));
389 * Open built-in default font (Courier).
391 AFMError afm_open_default_font ___P ((AFMHandle handle, AFMFont *font_return));
396 AFMError afm_close_font ___P ((AFMFont font));
399 * Dump font information to file <fp>.
401 void afm_font_dump ___P ((FILE *fp, AFMFont font));
404 * Return the width of the string <string, stringlen>.
406 AFMError afm_font_stringwidth ___P ((AFMFont font, AFMNumber ptsize,
407 char *string, unsigned int stringlen,
408 AFMNumber *w0x_return,
409 AFMNumber *w0y_return));
412 * Return the width of the character <ch>.
414 AFMError afm_font_charwidth ___P ((AFMFont font, AFMNumber ptsize,
415 char ch, AFMNumber *w0x_return,
416 AFMNumber *w0y_return));
419 * Encode character code <code> to print as character <name>.
420 * If <name> is NULL, encoding is removed. <flags> can contain
421 * any combination of the AFM_ENCODE_* values.
423 AFMError afm_font_encode ___P ((AFMFont font, unsigned char code, char *name,
424 unsigned int flags));
427 * Apply encoding <enc> to font <font>. <flags> can contain any
428 * combination of the AFM_ENCODE_* values.
430 AFMError afm_font_encoding ___P ((AFMFont font, AFMEncoding enc,
431 unsigned int flags));
433 #endif /* not AFM_H */