]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - ft2_defs.h
... forgot to add the files, I'm too used to git now :P
[xonotic/darkplaces.git] / ft2_defs.h
1 /* FreeType 2 definitions from the freetype header mostly.
2  */
3
4 #ifndef FT2_DEFS_H_H__
5 #define FT2_DEFS_H_H__
6
7 #ifdef _MSC_VER
8 typedef __int32 FT_Int32;
9 typedef __uint32 FT_UInt32;
10 #else
11 typedef int32_t FT_Int32;
12 typedef u_int32_t FT_UInt32;
13 #endif
14
15 typedef int FT_Error;
16
17 typedef signed char FT_Char;
18 typedef unsigned char FT_Byte;
19 typedef const FT_Byte *FT_Bytes;
20 typedef char FT_String;
21 typedef signed short FT_Short;
22 typedef unsigned short FT_UShort;
23 typedef signed int FT_Int;
24 typedef unsigned int FT_UInt;
25 typedef signed long FT_Long;
26 typedef signed long FT_Fixed;
27 typedef unsigned long FT_ULong;
28 typedef void *FT_Pointer;
29 typedef size_t FT_Offset;
30 typedef signed long FT_F26Dot6;
31
32 typedef void *FT_Stream;
33 typedef void *FT_Module;
34 typedef void *FT_Library;
35 typedef struct FT_FaceRec_ *FT_Face;
36 typedef struct FT_CharMapRec_*  FT_CharMap;
37 typedef struct FT_SizeRec_*  FT_Size;
38 typedef struct FT_Size_InternalRec_*  FT_Size_Internal;
39 typedef struct FT_GlyphSlotRec_*  FT_GlyphSlot;
40 typedef struct FT_SubGlyphRec_*  FT_SubGlyph;
41 typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
42
43 // Taken from the freetype headers:
44 typedef signed long FT_Pos;
45 typedef struct FT_Vector_
46 {
47         FT_Pos x;
48         FT_Pos y;
49 } FT_Vector;
50
51 typedef struct  FT_BBox_
52 {
53         FT_Pos  xMin, yMin;
54         FT_Pos  xMax, yMax;
55 } FT_BBox;
56
57 typedef enum  FT_Pixel_Mode_
58 {
59         FT_PIXEL_MODE_NONE = 0,
60         FT_PIXEL_MODE_MONO,
61         FT_PIXEL_MODE_GRAY,
62         FT_PIXEL_MODE_GRAY2,
63         FT_PIXEL_MODE_GRAY4,
64         FT_PIXEL_MODE_LCD,
65         FT_PIXEL_MODE_LCD_V,
66         FT_PIXEL_MODE_MAX      /* do not remove */
67 } FT_Pixel_Mode;
68 typedef enum  FT_Render_Mode_
69 {
70         FT_RENDER_MODE_NORMAL = 0,
71         FT_RENDER_MODE_LIGHT,
72         FT_RENDER_MODE_MONO,
73         FT_RENDER_MODE_LCD,
74         FT_RENDER_MODE_LCD_V,
75
76         FT_RENDER_MODE_MAX
77 } FT_Render_Mode;
78
79 #define ft_pixel_mode_none   FT_PIXEL_MODE_NONE
80 #define ft_pixel_mode_mono   FT_PIXEL_MODE_MONO
81 #define ft_pixel_mode_grays  FT_PIXEL_MODE_GRAY
82 #define ft_pixel_mode_pal2   FT_PIXEL_MODE_GRAY2
83 #define ft_pixel_mode_pal4   FT_PIXEL_MODE_GRAY4
84
85 typedef struct  FT_Bitmap_
86 {
87         int             rows;
88         int             width;
89         int             pitch;
90         unsigned char*  buffer;
91         short           num_grays;
92         char            pixel_mode;
93         char            palette_mode;
94         void*           palette;
95 } FT_Bitmap;
96
97 typedef struct  FT_Outline_
98 {
99         short       n_contours;      /* number of contours in glyph        */
100         short       n_points;        /* number of points in the glyph      */
101
102         FT_Vector*  points;          /* the outline's points               */
103         char*       tags;            /* the points flags                   */
104         short*      contours;        /* the contour end points             */
105
106         int         flags;           /* outline masks                      */
107 } FT_Outline;
108
109 #define FT_OUTLINE_NONE             0x0
110 #define FT_OUTLINE_OWNER            0x1
111 #define FT_OUTLINE_EVEN_ODD_FILL    0x2
112 #define FT_OUTLINE_REVERSE_FILL     0x4
113 #define FT_OUTLINE_IGNORE_DROPOUTS  0x8
114 #define FT_OUTLINE_SMART_DROPOUTS   0x10
115 #define FT_OUTLINE_INCLUDE_STUBS    0x20
116
117 #define FT_OUTLINE_HIGH_PRECISION   0x100
118 #define FT_OUTLINE_SINGLE_PASS      0x200
119
120 #define ft_outline_none             FT_OUTLINE_NONE
121 #define ft_outline_owner            FT_OUTLINE_OWNER
122 #define ft_outline_even_odd_fill    FT_OUTLINE_EVEN_ODD_FILL
123 #define ft_outline_reverse_fill     FT_OUTLINE_REVERSE_FILL
124 #define ft_outline_ignore_dropouts  FT_OUTLINE_IGNORE_DROPOUTS
125 #define ft_outline_high_precision   FT_OUTLINE_HIGH_PRECISION
126 #define ft_outline_single_pass      FT_OUTLINE_SINGLE_PASS
127
128 #define FT_CURVE_TAG( flag )  ( flag & 3 )
129
130 #define FT_CURVE_TAG_ON           1
131 #define FT_CURVE_TAG_CONIC        0
132 #define FT_CURVE_TAG_CUBIC        2
133
134 #define FT_CURVE_TAG_TOUCH_X      8  /* reserved for the TrueType hinter */
135 #define FT_CURVE_TAG_TOUCH_Y     16  /* reserved for the TrueType hinter */
136
137 #define FT_CURVE_TAG_TOUCH_BOTH  ( FT_CURVE_TAG_TOUCH_X | \
138                                    FT_CURVE_TAG_TOUCH_Y )
139
140 #define FT_Curve_Tag_On       FT_CURVE_TAG_ON
141 #define FT_Curve_Tag_Conic    FT_CURVE_TAG_CONIC
142 #define FT_Curve_Tag_Cubic    FT_CURVE_TAG_CUBIC
143 #define FT_Curve_Tag_Touch_X  FT_CURVE_TAG_TOUCH_X
144 #define FT_Curve_Tag_Touch_Y  FT_CURVE_TAG_TOUCH_Y
145
146 typedef int
147 (*FT_Outline_MoveToFunc)( const FT_Vector*  to,
148                           void*             user );
149 #define FT_Outline_MoveTo_Func  FT_Outline_MoveToFunc
150
151 typedef int
152 (*FT_Outline_LineToFunc)( const FT_Vector*  to,
153                           void*             user );
154 #define FT_Outline_LineTo_Func  FT_Outline_LineToFunc
155
156 typedef int
157 (*FT_Outline_ConicToFunc)( const FT_Vector*  control,
158                            const FT_Vector*  to,
159                            void*             user );
160 #define FT_Outline_ConicTo_Func  FT_Outline_ConicToFunc
161
162 typedef int
163 (*FT_Outline_CubicToFunc)( const FT_Vector*  control1,
164                            const FT_Vector*  control2,
165                            const FT_Vector*  to,
166                            void*             user );
167 #define FT_Outline_CubicTo_Func  FT_Outline_CubicToFunc
168
169 typedef struct  FT_Outline_Funcs_
170 {
171         FT_Outline_MoveToFunc   move_to;
172         FT_Outline_LineToFunc   line_to;
173         FT_Outline_ConicToFunc  conic_to;
174         FT_Outline_CubicToFunc  cubic_to;
175
176         int                     shift;
177         FT_Pos                  delta;
178 } FT_Outline_Funcs;
179
180 #ifndef FT_IMAGE_TAG
181 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 )  \
182           value = ( ( (unsigned long)_x1 << 24 ) | \
183                     ( (unsigned long)_x2 << 16 ) | \
184                     ( (unsigned long)_x3 << 8  ) | \
185                       (unsigned long)_x4         )
186 #endif /* FT_IMAGE_TAG */
187
188 typedef enum  FT_Glyph_Format_
189 {
190         FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
191
192         FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
193         FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP,    'b', 'i', 't', 's' ),
194         FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE,   'o', 'u', 't', 'l' ),
195         FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER,   'p', 'l', 'o', 't' )
196 } FT_Glyph_Format;
197 #define ft_glyph_format_none       FT_GLYPH_FORMAT_NONE
198 #define ft_glyph_format_composite  FT_GLYPH_FORMAT_COMPOSITE
199 #define ft_glyph_format_bitmap     FT_GLYPH_FORMAT_BITMAP
200 #define ft_glyph_format_outline    FT_GLYPH_FORMAT_OUTLINE
201 #define ft_glyph_format_plotter    FT_GLYPH_FORMAT_PLOTTER
202
203 typedef struct  FT_Glyph_Metrics_
204 {
205         FT_Pos  width;
206         FT_Pos  height;
207
208         FT_Pos  horiBearingX;
209         FT_Pos  horiBearingY;
210         FT_Pos  horiAdvance;
211
212         FT_Pos  vertBearingX;
213         FT_Pos  vertBearingY;
214         FT_Pos  vertAdvance;
215 } FT_Glyph_Metrics;
216
217 #define FT_EXPORT( x )  x
218
219 #define FT_OPEN_MEMORY    0x1
220 #define FT_OPEN_STREAM    0x2
221 #define FT_OPEN_PATHNAME  0x4
222 #define FT_OPEN_DRIVER    0x8
223 #define FT_OPEN_PARAMS    0x10
224
225 typedef struct  FT_Parameter_
226 {
227         FT_ULong    tag;
228         FT_Pointer  data;
229 } FT_Parameter;
230
231 typedef struct  FT_Open_Args_
232 {
233         FT_UInt         flags;
234         const FT_Byte*  memory_base;
235         FT_Long         memory_size;
236         FT_String*      pathname;
237         FT_Stream       stream;
238         FT_Module       driver;
239         FT_Int          num_params;
240         FT_Parameter*   params;
241 } FT_Open_Args;
242 typedef enum  FT_Size_Request_Type_
243 {
244         FT_SIZE_REQUEST_TYPE_NOMINAL,
245         FT_SIZE_REQUEST_TYPE_REAL_DIM,
246         FT_SIZE_REQUEST_TYPE_BBOX,
247         FT_SIZE_REQUEST_TYPE_CELL,
248         FT_SIZE_REQUEST_TYPE_SCALES,
249
250         FT_SIZE_REQUEST_TYPE_MAX
251
252 } FT_Size_Request_Type;
253 typedef struct  FT_Size_RequestRec_
254 {
255         FT_Size_Request_Type  type;
256         FT_Long               width;
257         FT_Long               height;
258         FT_UInt               horiResolution;
259         FT_UInt               vertResolution;
260 } FT_Size_RequestRec;
261 typedef struct FT_Size_RequestRec_  *FT_Size_Request;
262
263 #define FT_LOAD_DEFAULT                      0x0
264 #define FT_LOAD_NO_SCALE                     0x1
265 #define FT_LOAD_NO_HINTING                   0x2
266 #define FT_LOAD_RENDER                       0x4
267 #define FT_LOAD_NO_BITMAP                    0x8
268 #define FT_LOAD_VERTICAL_LAYOUT              0x10
269 #define FT_LOAD_FORCE_AUTOHINT               0x20
270 #define FT_LOAD_CROP_BITMAP                  0x40
271 #define FT_LOAD_PEDANTIC                     0x80
272 #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH  0x200
273 #define FT_LOAD_NO_RECURSE                   0x400
274 #define FT_LOAD_IGNORE_TRANSFORM             0x800
275 #define FT_LOAD_MONOCHROME                   0x1000
276 #define FT_LOAD_LINEAR_DESIGN                0x2000
277 #define FT_LOAD_NO_AUTOHINT                  0x8000U
278
279 #define FT_LOAD_TARGET_( x )   ( (FT_Int32)( (x) & 15 ) << 16 )
280
281 #define FT_LOAD_TARGET_NORMAL  FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
282 #define FT_LOAD_TARGET_LIGHT   FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT  )
283 #define FT_LOAD_TARGET_MONO    FT_LOAD_TARGET_( FT_RENDER_MODE_MONO   )
284 #define FT_LOAD_TARGET_LCD     FT_LOAD_TARGET_( FT_RENDER_MODE_LCD    )
285 #define FT_LOAD_TARGET_LCD_V   FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V  )
286
287 #define FT_ENC_TAG( value, a, b, c, d )       \
288         value = ( ( (FT_UInt32)(a) << 24 ) |                      \
289                   ( (FT_UInt32)(b) << 16 ) |                            \
290                   ( (FT_UInt32)(c) <<  8 ) |                            \
291                   (FT_UInt32)(d)         )
292
293 typedef enum  FT_Encoding_
294 {
295         FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
296
297         FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
298         FT_ENC_TAG( FT_ENCODING_UNICODE,   'u', 'n', 'i', 'c' ),
299
300         FT_ENC_TAG( FT_ENCODING_SJIS,    's', 'j', 'i', 's' ),
301         FT_ENC_TAG( FT_ENCODING_GB2312,  'g', 'b', ' ', ' ' ),
302         FT_ENC_TAG( FT_ENCODING_BIG5,    'b', 'i', 'g', '5' ),
303         FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
304         FT_ENC_TAG( FT_ENCODING_JOHAB,   'j', 'o', 'h', 'a' ),
305
306         /* for backwards compatibility */
307         FT_ENCODING_MS_SJIS    = FT_ENCODING_SJIS,
308         FT_ENCODING_MS_GB2312  = FT_ENCODING_GB2312,
309         FT_ENCODING_MS_BIG5    = FT_ENCODING_BIG5,
310         FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
311         FT_ENCODING_MS_JOHAB   = FT_ENCODING_JOHAB,
312
313         FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
314         FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT,   'A', 'D', 'B', 'E' ),
315         FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM,   'A', 'D', 'B', 'C' ),
316         FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1,  'l', 'a', 't', '1' ),
317
318         FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
319
320         FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
321 } FT_Encoding;
322
323 #define ft_encoding_none            FT_ENCODING_NONE
324 #define ft_encoding_unicode         FT_ENCODING_UNICODE
325 #define ft_encoding_symbol          FT_ENCODING_MS_SYMBOL
326 #define ft_encoding_latin_1         FT_ENCODING_ADOBE_LATIN_1
327 #define ft_encoding_latin_2         FT_ENCODING_OLD_LATIN_2
328 #define ft_encoding_sjis            FT_ENCODING_SJIS
329 #define ft_encoding_gb2312          FT_ENCODING_GB2312
330 #define ft_encoding_big5            FT_ENCODING_BIG5
331 #define ft_encoding_wansung         FT_ENCODING_WANSUNG
332 #define ft_encoding_johab           FT_ENCODING_JOHAB
333
334 #define ft_encoding_adobe_standard  FT_ENCODING_ADOBE_STANDARD
335 #define ft_encoding_adobe_expert    FT_ENCODING_ADOBE_EXPERT
336 #define ft_encoding_adobe_custom    FT_ENCODING_ADOBE_CUSTOM
337 #define ft_encoding_apple_roman     FT_ENCODING_APPLE_ROMAN
338
339 typedef struct  FT_Bitmap_Size_
340 {
341         FT_Short  height;
342         FT_Short  width;
343
344         FT_Pos    size;
345
346         FT_Pos    x_ppem;
347         FT_Pos    y_ppem;
348 } FT_Bitmap_Size;
349
350 typedef struct  FT_CharMapRec_
351 {
352         FT_Face      face;
353         FT_Encoding  encoding;
354         FT_UShort    platform_id;
355         FT_UShort    encoding_id;
356 } FT_CharMapRec;
357
358 typedef void  (*FT_Generic_Finalizer)(void*  object);
359 typedef struct  FT_Generic_
360 {
361         void*                 data;
362         FT_Generic_Finalizer  finalizer;
363 } FT_Generic;
364
365 typedef struct  FT_Size_Metrics_
366 {
367         FT_UShort  x_ppem;      /* horizontal pixels per EM               */
368         FT_UShort  y_ppem;      /* vertical pixels per EM                 */
369
370         FT_Fixed   x_scale;     /* scaling values used to convert font    */
371         FT_Fixed   y_scale;     /* units to 26.6 fractional pixels        */
372
373         FT_Pos     ascender;    /* ascender in 26.6 frac. pixels          */
374         FT_Pos     descender;   /* descender in 26.6 frac. pixels         */
375         FT_Pos     height;      /* text height in 26.6 frac. pixels       */
376         FT_Pos     max_advance; /* max horizontal advance, in 26.6 pixels */
377 } FT_Size_Metrics;
378
379 typedef struct  FT_SizeRec_
380 {
381         FT_Face           face;      /* parent face object              */
382         FT_Generic        generic;   /* generic pointer for client uses */
383         FT_Size_Metrics   metrics;   /* size metrics                    */
384         FT_Size_Internal  internal;
385 } FT_SizeRec;
386
387 typedef struct  FT_FaceRec_
388 {
389         FT_Long           num_faces;
390         FT_Long           face_index;
391
392         FT_Long           face_flags;
393         FT_Long           style_flags;
394
395         FT_Long           num_glyphs;
396
397         FT_String*        family_name;
398         FT_String*        style_name;
399
400         FT_Int            num_fixed_sizes;
401         FT_Bitmap_Size*   available_sizes;
402
403         FT_Int            num_charmaps;
404         FT_CharMap*       charmaps;
405
406         FT_Generic        generic;
407
408         /*# The following member variables (down to `underline_thickness') */
409         /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size    */
410         /*# for bitmap fonts.                                              */
411         FT_BBox           bbox;
412
413         FT_UShort         units_per_EM;
414         FT_Short          ascender;
415         FT_Short          descender;
416         FT_Short          height;
417
418         FT_Short          max_advance_width;
419         FT_Short          max_advance_height;
420
421         FT_Short          underline_position;
422         FT_Short          underline_thickness;
423
424         FT_GlyphSlot      glyph;
425         FT_Size           size;
426         FT_CharMap        charmap;
427
428         /* ft2 private
429         FT_Driver         driver;
430         FT_Memory         memory;
431         FT_Stream         stream;
432
433         FT_ListRec        sizes_list;
434
435         FT_Generic        autohint;
436         void*             extensions;
437
438         FT_Face_Internal  internal;
439         */
440 } FT_FaceRec;
441
442 typedef struct  FT_GlyphSlotRec_
443 {
444         FT_Library        library;
445         FT_Face           face;
446         FT_GlyphSlot      next;
447         FT_UInt           reserved;       /* retained for binary compatibility */
448         FT_Generic        generic;
449
450         FT_Glyph_Metrics  metrics;
451         FT_Fixed          linearHoriAdvance;
452         FT_Fixed          linearVertAdvance;
453         FT_Vector         advance;
454
455         FT_Glyph_Format   format;
456
457         FT_Bitmap         bitmap;
458         FT_Int            bitmap_left;
459         FT_Int            bitmap_top;
460
461         FT_Outline        outline;
462
463         FT_UInt           num_subglyphs;
464         FT_SubGlyph       subglyphs;
465
466         void*             control_data;
467         long              control_len;
468
469         FT_Pos            lsb_delta;
470         FT_Pos            rsb_delta;
471
472         void*             other;
473
474         FT_Slot_Internal  internal;
475 } FT_GlyphSlotRec;
476
477 #define FT_FACE_FLAG_SCALABLE          ( 1L <<  0 )
478 #define FT_FACE_FLAG_FIXED_SIZES       ( 1L <<  1 )
479 #define FT_FACE_FLAG_FIXED_WIDTH       ( 1L <<  2 )
480 #define FT_FACE_FLAG_SFNT              ( 1L <<  3 )
481 #define FT_FACE_FLAG_HORIZONTAL        ( 1L <<  4 )
482 #define FT_FACE_FLAG_VERTICAL          ( 1L <<  5 )
483 #define FT_FACE_FLAG_KERNING           ( 1L <<  6 )
484 #define FT_FACE_FLAG_FAST_GLYPHS       ( 1L <<  7 )
485 #define FT_FACE_FLAG_MULTIPLE_MASTERS  ( 1L <<  8 )
486 #define FT_FACE_FLAG_GLYPH_NAMES       ( 1L <<  9 )
487 #define FT_FACE_FLAG_EXTERNAL_STREAM   ( 1L << 10 )
488 #define FT_FACE_FLAG_HINTER            ( 1L << 11 )
489 #define FT_FACE_FLAG_CID_KEYED         ( 1L << 12 )
490 #define FT_FACE_FLAG_TRICKY            ( 1L << 13 )
491
492 typedef enum  FT_Kerning_Mode_
493 {
494         FT_KERNING_DEFAULT  = 0,
495         FT_KERNING_UNFITTED,
496         FT_KERNING_UNSCALED
497 } FT_Kerning_Mode;
498
499 #endif // FT2_DEFS_H_H__