Hardcoded application name
[aaf.git] / aaf.h
1 #ifndef __AAF_H
2 #define __AAF_H
3
4 #include <stdio.h>
5 #include <stdint.h>
6
7 #define AAF_GLYPH_MAX 256
8
9 struct aaf_glyph {
10         uint16_t w;
11         uint16_t h;
12         uint32_t off;
13 };
14
15 struct aaf {
16         char signature[4];
17         uint16_t max_h;
18         uint16_t gap_h;
19         uint16_t space_width;
20         uint16_t gap_v;
21         
22         struct aaf_glyph glyphs[AAF_GLYPH_MAX];
23 };
24
25 struct aaf_glyph_data {
26         /* variable size array of values 0-9 */
27         uint8_t * pixels;
28 };
29
30 /**
31  * Reads AAF informations about font
32  *
33  * @param in opened stream for reading
34  * @param _aaf reference to structure where read informations will be stored
35  *
36  * @return when succesful function returns 0, otherwise non-zero value
37  */
38 int read_aaf(FILE * in, struct aaf * _aaf);
39
40 /**
41  * Reads AAF glyph data from input stream
42  * Returned structure is an array with number of elements equal to AAF_GLYPH_MAX.
43  * Every X element of array relates to _aaf->glyphs[X].
44  * Structure should be freed using free_aaf_glyph_data function.
45  *
46  * @param in opened input stream
47  * @param _aaf pointer to AAF header information
48  *
49  * @return when succesful returns pointer to newly allocated array of struct
50  * aaf_glyph_data. On error NULL is returned.
51  */
52 struct aaf_glyph_data ** read_aaf_glyph_data(FILE * in, struct aaf * _aaf);
53
54 /**
55  * Function used to free data allocated using read_aaf_glyph_data.
56  *
57  * @param data pointer to array of glyph data
58  */
59 void free_aaf_glyph_data(struct aaf_glyph_data ** data);
60
61 /**
62  * Writes AAF glyph as PGM image
63  *
64  * @param out opened output stream for writting
65  * @param glyph glyph description
66  * @param data glyph data
67  * @return 0 if data was written succesfully, negative value when error occured
68  */
69 int write_aaf_glyph_as_pgm(FILE * out, const struct aaf_glyph * glyph, const struct aaf_glyph_data * data);
70
71 #endif /* __AAF_H */