3 * Copyright (c) 1995-1998 Markku Rossi.
5 * Author: Markku Rossi <mtr@iki.fi>
9 * This program 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 2, or (at your option)
14 * This program 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 this program; see the file COPYING. If not, write to
21 * the Free Software Foundation, 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
30 #define ___P(protos) protos
31 #else /* no PROTOTYPES */
32 #define ___P(protos) ()
33 #endif /* no PROTOTYPES */
36 /**********************************************************************
40 **********************************************************************/
44 #define AFM_TYPE_STRING 1
45 #define AFM_TYPE_NAME 2
46 #define AFM_TYPE_NUMBER 3
47 #define AFM_TYPE_INTEGER 4
48 #define AFM_TYPE_ARRAY 5
49 #define AFM_TYPE_BOOLEAN 6
51 typedef char *AFMString;
52 typedef char *AFMName;
53 typedef double AFMNumber;
54 typedef long AFMInteger;
62 typedef struct afm_array_st *AFMArray;
79 typedef struct afm_node_st AFMNode;
88 /* AFM file data structures. */
91 * Sorry! I know that those mixed case variable names are ugly,
92 * but this is the way how they are written in Adobe's document
93 * so I think that this is the best way for documentary reasons.
96 /* Global Font Information*/
97 struct global_font_information_st
101 AFMString FamilyName;
103 AFMNumber FontBBox_llx;
104 AFMNumber FontBBox_lly;
105 AFMNumber FontBBox_urx;
106 AFMNumber FontBBox_ury;
109 AFMString EncodingScheme;
110 AFMInteger MappingScheme;
112 AFMString CharacterSet;
113 AFMInteger Characters;
114 AFMBoolean IsBaseFont;
122 AFMArray BlendAxisTypes;
123 AFMArray BlendDesignPositions;
124 AFMArray BlendDesignMap;
125 AFMArray WeightVector;
128 typedef struct global_font_information_st AFMGlobalFontInformation;
131 /* Writing Direction Metrics. */
132 struct writing_direction_metrics_st
135 AFMNumber UnderlinePosition;
136 AFMNumber UnderlineThickness;
137 AFMNumber ItalicAngle;
138 AFMNumber CharWidth_x;
139 AFMNumber CharWidth_y;
140 AFMBoolean IsFixedPitch;
143 typedef struct writing_direction_metrics_st AFMWritingDirectionMetrics;
146 /* Multiple Master Axis Information. */
147 struct multiple_master_axis_info_st
153 typedef struct multiple_master_axis_info_st AFMMultipleMasterAxisInformation;
156 /* Individual Character Metrics. */
164 typedef struct ligature_st AFMLigature;
166 /* Single individual character. */
167 struct individual_character_metrics_st
169 AFMInteger character_code; /* default charcode (-1 if not encoded) */
170 AFMNumber w0x; /* character width x in writing direction 0 */
171 AFMNumber w0y; /* character width y in writing direction 0 */
172 AFMNumber w1x; /* character width x in writing direction 1 */
173 AFMNumber w1y; /* character width y in writing direction 1 */
174 AFMName name; /* character name */
175 AFMNumber vv_x; /* local VVector x */
176 AFMNumber vv_y; /* local VVector y */
178 /* character bounding box. */
184 AFMNumber num_ligatures;
185 AFMLigature *ligatures;
188 typedef struct individual_character_metrics_st AFMIndividualCharacterMetrics;
193 /* Track Kerning Data. */
197 AFMNumber min_ptsize;
199 AFMNumber max_ptsize;
203 typedef struct track_kern_st AFMTrackKern;
206 /* Pair-Wise Kerning. */
207 struct pair_wise_kerning_st
215 typedef struct pair_wise_kerning_st AFMPairWiseKerning;
218 /* Composite fonts. */
220 /* Single composite component. */
221 struct composite_component_st
228 typedef struct composite_component_st AFMCompositeComponent;
233 AFMInteger num_components;
234 AFMCompositeComponent *components;
237 typedef struct composite_st AFMComposite;
240 /**********************************************************************
244 **********************************************************************/
248 #define UNITS_PER_POINT 1000
250 /* Successful operation. */
251 #define AFM_SUCCESS 0
254 * AFM information levels. The AFM libarary returns always Global
255 * Font information, Writing Direction Metrics and Individual
256 * Character Metrics. Other fields can be retrieved by defining some
257 * of the following flags to afm_open_{font, file}() functions.
259 #define AFM_I_MINIMUM 0x00
260 #define AFM_I_COMPOSITES 0x01
261 #define AFM_I_KERN_PAIRS 0x02
262 #define AFM_I_TRACK_KERNS 0x04
263 #define AFM_I_ALL 0xffffffff
266 * Flags for the encoding functions.
268 #define AFM_ENCODE_ACCEPT_COMPOSITES 0x01
270 typedef unsigned int AFMError;
272 typedef struct afm_handle_st *AFMHandle;
274 /* Supported encoding types. */
277 AFM_ENCODING_DEFAULT, /* Font's default encoding. */
278 AFM_ENCODING_ISO_8859_1, /* ISO-8859-1 */
279 AFM_ENCODING_ISO_8859_2, /* ISO-8859-2 */
280 AFM_ENCODING_ISO_8859_3, /* ISO-8859-3 */
281 AFM_ENCODING_ISO_8859_4, /* ISO-8859-4 */
282 AFM_ENCODING_ISO_8859_5, /* ISO-8859-5 */
283 AFM_ENCODING_ISO_8859_7, /* ISO-8859-7 */
284 AFM_ENCODING_ISO_8859_9, /* ISO-8859-9 */
285 AFM_ENCODING_ISO_8859_10, /* ISO-8859-10 */
286 AFM_ENCODING_IBMPC, /* IBM PC */
287 AFM_ENCODING_ASCII, /* 7 bit ASCII */
288 AFM_ENCODING_MAC, /* Mac */
289 AFM_ENCODING_VMS, /* VMS multinational */
290 AFM_ENCODING_HP8, /* HP Roman-8 */
291 AFM_ENCODING_KOI8 /* Adobe Standard Cyrillic Font KOI8 */
294 /* Special encoding types for individual characters. */
295 #define AFM_ENC_NONE ((void *) 0)
296 #define AFM_ENC_NON_EXISTENT ((void *) 1)
299 /* AFM information for a single PostScript font. */
303 /* AFM Library's private data. */
304 struct afm_font_private_data_st *private;
306 AFMNumber version; /* AFM format specification version number. */
307 unsigned int info_level;
310 * Current font encoding. Following values are valid:
312 * AFM_ENC_NONE character is not encoded
313 * AFM_ENC_NON_EXISTENT character is encoded, but font does not
314 * have the specified character
315 * <pointer to character's metrics>
316 * character is encoded and it exists in font
318 AFMIndividualCharacterMetrics *encoding[256];
320 AFMGlobalFontInformation global_info;
321 AFMWritingDirectionMetrics writing_direction_metrics[2];
323 AFMInteger num_character_metrics;
324 AFMIndividualCharacterMetrics *character_metrics;
326 AFMInteger num_composites;
327 AFMComposite *composites;
329 AFMInteger num_kern_pairs;
330 AFMPairWiseKerning *kern_pairs;
332 AFMInteger num_track_kerns;
333 AFMTrackKern *track_kerns;
336 typedef struct afm_font_st *AFMFont;
341 * Prototypes for public functions.
345 * Format error <error> to human readable format to buffer <buf>.
346 * Buffer must be long enough for error messages (256 bytes is good).
348 void afm_error_to_string ___P ((AFMError error, char *buf));
351 * Open AFM library. <path> specifies the search path for the AFM
352 * files. A handle to the library is returned in <handle_return>.
354 AFMError afm_create ___P ((const char *path, unsigned int verbose_level,
355 AFMHandle *handle_return));
358 * Close AFM library handle <handle>.
360 AFMError afm_destroy ___P ((AFMHandle handle));
363 * Set AFM library's verbose level to <level>. Value 0 means "no output".
365 AFMError afm_set_verbose ___P ((AFMHandle handle, unsigned int level));
368 * Return a prefix to the font <fontname>'s data. Various font
369 * resource file names can be constructed from the returned prefix:
373 * Returned prefix belongs to AFM library, user should not modify it.
375 AFMError afm_font_prefix ___P ((AFMHandle handle, const char *fontname,
376 const char **prefix_return));
379 * Open font <name> and return font handle in <font_return>.
381 AFMError afm_open_font ___P ((AFMHandle handle, unsigned int info_level,
382 const char *name, AFMFont *font_return));
385 * Open AFM file <filename> and return font handle in <font_return>.
387 AFMError afm_open_file ___P ((AFMHandle handle, unsigned int info_level,
388 const char *filename, AFMFont *font_return));
391 * Open built-in default font (Courier).
393 AFMError afm_open_default_font ___P ((AFMHandle handle, AFMFont *font_return));
398 AFMError afm_close_font ___P ((AFMFont font));
401 * Dump font information to file <fp>.
403 void afm_font_dump ___P ((FILE *fp, AFMFont font));
406 * Return the width of the string <string, stringlen>.
408 AFMError afm_font_stringwidth ___P ((AFMFont font, AFMNumber ptsize,
409 char *string, unsigned int stringlen,
410 AFMNumber *w0x_return,
411 AFMNumber *w0y_return));
414 * Return the width of the character <ch>.
416 AFMError afm_font_charwidth ___P ((AFMFont font, AFMNumber ptsize,
417 char ch, AFMNumber *w0x_return,
418 AFMNumber *w0y_return));
421 * Encode character code <code> to print as character <name>.
422 * If <name> is NULL, encoding is removed. <flags> can contain
423 * any combination of the AFM_ENCODE_* values.
425 AFMError afm_font_encode ___P ((AFMFont font, unsigned char code, char *name,
426 unsigned int flags));
429 * Apply encoding <enc> to font <font>. <flags> can contain any
430 * combination of the AFM_ENCODE_* values.
432 AFMError afm_font_encoding ___P ((AFMFont font, AFMEncoding enc,
433 unsigned int flags));
435 #endif /* not AFM_H */