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