1 
2 //          Copyright Michael D. Parker 2018.
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.freetype.bind.ftglyph;
8 
9 alias FT_Glyph = FT_GlyphRec*;
10 
11 import bindbc.freetype.bind.freetype,
12        bindbc.freetype.bind.ftimage,
13        bindbc.freetype.bind.ftrender,
14        bindbc.freetype.bind.fttypes;
15 
16 struct FT_GlyphRec {
17     FT_Library library;
18     FT_Glyph_Class* clazz;
19     FT_Glyph_Format format;
20     FT_Vector advance;
21 }
22 
23 alias FT_BitmapGlyph = FT_BitmapGlyphRec*;
24 
25 struct FT_BitmapGlyphRec {
26     FT_GlyphRec root;
27     FT_Int left;
28     FT_Int top;
29     FT_Bitmap bitmap;
30 }
31 
32 alias FT_OutlineGlyph = FT_OutlineGlyphRec*;
33 
34 struct FT_OutlineGlyphRec {
35     FT_GlyphRec root;
36     FT_Outline outline;
37 }
38 
39 alias FT_Glyph_BBox_Mode = int;
40 enum {
41     FT_GLYPH_BBOX_UNSCALED = 0,
42     FT_GLYPH_BBOX_SUBPIXELS = 0,
43     FT_GLYPH_BBOX_GRIDFIT = 1,
44     FT_GLYPH_BBOX_TRUNCATE = 2,
45     FT_GLYPH_BBOX_PIXELS = 3
46 }
47 
48 version(BindFT_Static) {
49 	extern(C) @nogc nothrow {
50         FT_Error FT_Get_Glyph(FT_GlyphSlot,FT_Glyph*);
51         FT_Error FT_Glyph_Copy(FT_Glyph,FT_Glyph*);
52         FT_Error FT_Glyph_Transform(FT_Glyph,FT_Matrix*,FT_Vector*);
53         void FT_Glyph_Get_CBox(FT_Glyph,FT_UInt,FT_BBox*);
54         FT_Error FT_Glyph_To_Bitmap(FT_Glyph*,FT_Render_Mode,FT_Vector*,FT_Bool);
55         void FT_Done_Glyph(FT_Glyph);
56         void FT_Matrix_Multiply(const(FT_Matrix)*,FT_Matrix*);
57         FT_Error FT_Matrix_Invert(FT_Matrix*);
58     }
59 }
60 else {
61     extern(C) @nogc nothrow {
62         alias pFT_Get_Glyph = FT_Error function(FT_GlyphSlot,FT_Glyph*);
63         alias pFT_Glyph_Copy = FT_Error function(FT_Glyph,FT_Glyph*);
64         alias pFT_Glyph_Transform = FT_Error function(FT_Glyph,FT_Matrix*,FT_Vector*);
65         alias pFT_Glyph_Get_CBox = void function(FT_Glyph,FT_UInt,FT_BBox*);
66         alias pFT_Glyph_To_Bitmap = FT_Error function(FT_Glyph*,FT_Render_Mode,FT_Vector*,FT_Bool);
67         alias pFT_Done_Glyph = void function(FT_Glyph);
68         alias pFT_Matrix_Multiply = void function(const(FT_Matrix)*,FT_Matrix*);
69         alias pFT_Matrix_Invert = FT_Error function(FT_Matrix*);
70     }
71 
72     __gshared {
73         pFT_Get_Glyph FT_Get_Glyph;
74         pFT_Glyph_Copy FT_Glyph_Copy;
75         pFT_Glyph_Transform FT_Glyph_Transform;
76         pFT_Glyph_Get_CBox FT_Glyph_Get_CBox;
77         pFT_Glyph_To_Bitmap FT_Glyph_To_Bitmap;
78         pFT_Done_Glyph FT_Done_Glyph;
79         pFT_Matrix_Multiply FT_Matrix_Multiply;
80         pFT_Matrix_Invert FT_Matrix_Invert;
81     }
82 }