]> git.karo-electronics.de Git - gbdfed.git/blob - bdfP.h
Initial import of upstream V1.6 from
[gbdfed.git] / bdfP.h
1 /*
2  * Copyright 2008 Department of Mathematical Sciences, New Mexico State University
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is 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  * DEPARTMENT OF MATHEMATICAL SCIENCES OR NEW MEXICO STATE UNIVERSITY BE
18  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #ifndef _h_bdfP
23 #define _h_bdfP
24
25 #include "bdf.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #ifndef MYABS
32 #define MYABS(xx) ((xx) < 0 ? -(xx) : (xx))
33 #endif
34
35 /*
36  * Macros and structures used for undo operations in the font.
37  */
38 #define _UNDO_REPLACE_GLYPHS 1
39 #define _UNDO_INSERT_GLYPHS  2
40 #define _UNDO_MERGE_GLYPHS   3
41
42 /*
43  * This structure is for undo operations of replacing and merging glyphs
44  * in the font.
45  */
46 typedef struct {
47     bdf_bbx_t b;
48     bdf_glyphlist_t g;
49 } _bdf_undo1_t;
50
51 /*
52  * This structure is for undo operations of inserting glyphs.
53  */
54 typedef struct {
55     bdf_bbx_t b;
56     int start;
57     int end;
58 } _bdf_undo2_t;
59
60 /*
61  * This is the final undo structure used to store undo information with the
62  * font.
63  */
64 typedef struct {
65     int type;
66     union {
67         _bdf_undo1_t one;
68         _bdf_undo2_t two;
69     } field;
70 } _bdf_undo_t;
71
72 /*
73  * Tables for rotation and shearing.
74  */
75 extern double _bdf_cos_tbl[];
76 extern double _bdf_sin_tbl[];
77 extern double _bdf_tan_tbl[];
78
79 /*
80  * PSF magic numbers.
81  */
82 extern unsigned char _bdf_psf1magic[];
83 extern unsigned char _bdf_psf2magic[];
84 extern char _bdf_psfcombined[];
85
86 /*
87  * Arrays of masks for test with different bits per pixel.
88  */
89 extern unsigned char bdf_onebpp[];
90 extern unsigned char bdf_twobpp[];
91 extern unsigned char bdf_fourbpp[];
92 extern unsigned char bdf_eightbpp[];
93
94 /*
95  * Simple routine for determining the ceiling.
96  */
97 extern short _bdf_ceiling(double v);
98
99 extern unsigned char *_bdf_strdup(unsigned char *s, unsigned int len);
100 extern void _bdf_memmove(char *dest, char *src, unsigned int bytes);
101
102 extern short _bdf_atos(char *s, char **end, int base);
103 extern int _bdf_atol(char *s, char **end, int base);
104 extern unsigned int _bdf_atoul(char *s, char **end, int base);
105
106 /*
107  * Function to locate the nearest glyph to a specified encoding.
108  */
109 extern bdf_glyph_t *_bdf_locate_glyph(bdf_font_t *font, int encoding,
110                                       int unencoded);
111
112 /*
113  * Macros to test/set the modified status of a glyph.
114  */
115 #define _bdf_glyph_modified(map, e) ((map)[(e) >> 5] & (1 << ((e) & 31)))
116 #define _bdf_set_glyph_modified(map, e) (map)[(e) >> 5] |= (1 << ((e) & 31))
117 #define _bdf_clear_glyph_modified(map, e) (map)[(e) >> 5] &= ~(1 << ((e) & 31))
118
119 /*
120  * Function to add a message to the font.
121  */
122 extern void _bdf_add_acmsg(bdf_font_t *font, char *msg, unsigned int len);
123
124 /*
125  * Function to add a comment to the font.
126  */
127 extern void _bdf_add_comment(bdf_font_t *font, char *comment,
128                              unsigned int len);
129
130 /*
131  * Function to do glyph name table cleanup when exiting.
132  */
133 extern void _bdf_glyph_name_cleanup(void);
134
135 /*
136  * Function to pad cells when saving glyphs.
137  */
138 extern void _bdf_pad_cell(bdf_font_t *font, bdf_glyph_t *glyph,
139                           bdf_glyph_t *cell);
140
141 /*
142  * Function to crop glyphs down to their minimum bitmap.
143  */
144 extern void _bdf_crop_glyph(bdf_font_t *font, bdf_glyph_t *glyph);
145
146 /*
147  * Routine to generate a string list from the PSF2 Unicode mapping format.
148  */
149 extern char **_bdf_psf_unpack_mapping(bdf_psf_unimap_t *unimap, int *num_seq);
150
151 /*
152  * Routine to convert a string list of mappings back to PSF2 format.
153  */
154 extern int _bdf_psf_pack_mapping(char **list, int len, int encoding,
155                                  bdf_psf_unimap_t *map);
156
157 #ifdef __cplusplus
158 }
159 #endif
160
161 #endif /* _h_bdfP */