1 
2 //          Copyright 2019 - 2021 Michael D. Parker
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 import bindbc.freetype.config,
10        bindbc.freetype.bind.freetype,
11        bindbc.freetype.bind.ftimage,
12        bindbc.freetype.bind.ftrender,
13        bindbc.freetype.bind.fttypes;
14 
15 alias FT_Glyph = FT_GlyphRec*;
16 
17 struct FT_GlyphRec {
18     FT_Library library;
19     FT_Glyph_Class* clazz;
20     FT_Glyph_Format format;
21     FT_Vector advance;
22 }
23 
24 alias FT_BitmapGlyph = FT_BitmapGlyphRec*;
25 
26 struct FT_BitmapGlyphRec {
27     FT_GlyphRec root;
28     FT_Int left;
29     FT_Int top;
30     FT_Bitmap bitmap;
31 }
32 
33 alias FT_OutlineGlyph = FT_OutlineGlyphRec*;
34 
35 struct FT_OutlineGlyphRec {
36     FT_GlyphRec root;
37     FT_Outline outline;
38 }
39 
40 alias FT_Glyph_BBox_Mode = int;
41 enum {
42     FT_GLYPH_BBOX_UNSCALED = 0,
43     FT_GLYPH_BBOX_SUBPIXELS = 0,
44     FT_GLYPH_BBOX_GRIDFIT = 1,
45     FT_GLYPH_BBOX_TRUNCATE = 2,
46     FT_GLYPH_BBOX_PIXELS = 3
47 }
48 
49 static if(staticBinding) {
50 	extern(C) @nogc nothrow {
51         FT_Error FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph* aglyph);
52         FT_Error FT_Glyph_Copy(FT_Glyph source, FT_Glyph* target);
53         FT_Error FT_Glyph_Transform(FT_Glyph glyph, FT_Matrix* matrix, FT_Vector* delta);
54         void FT_Glyph_Get_CBox(FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox* acbox);
55         FT_Error FT_Glyph_To_Bitmap(FT_Glyph* the_glyph, FT_Render_Mode render_mode, FT_Vector* origin, FT_Bool destroy);
56         void FT_Done_Glyph(FT_Glyph glyph);
57         void FT_Matrix_Multiply(const(FT_Matrix)* a, FT_Matrix* b);
58         FT_Error FT_Matrix_Invert(FT_Matrix* matrix);
59     }
60     static if(ftSupport >= FTSupport.ft210) {
61         FT_Error FT_New_Glyph(FT_Library library, FT_Glyph_Format format, FT_Glyph* aglyph);
62     }
63 }
64 else {
65     extern(C) @nogc nothrow {
66         alias pFT_Get_Glyph = FT_Error function(FT_GlyphSlot slot, FT_Glyph* aglyph);
67         alias pFT_Glyph_Copy = FT_Error function(FT_Glyph source, FT_Glyph* target);
68         alias pFT_Glyph_Transform = FT_Error function(FT_Glyph glyph, FT_Matrix* matrix, FT_Vector* delta);
69         alias pFT_Glyph_Get_CBox = void function(FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox* acbox);
70         alias pFT_Glyph_To_Bitmap = FT_Error function(FT_Glyph* the_glyph, FT_Render_Mode render_mode, FT_Vector* origin, FT_Bool destroy);
71         alias pFT_Done_Glyph = void function(FT_Glyph glyph);
72         alias pFT_Matrix_Multiply = void function(const(FT_Matrix)* a, FT_Matrix* b);
73         alias pFT_Matrix_Invert = FT_Error function(FT_Matrix* matrix);
74 
75         static if(ftSupport >= FTSupport.ft210) {
76             alias pFT_New_Glyph = FT_Error function(FT_Library library, FT_Glyph_Format format, FT_Glyph* aglyph);
77         }
78     }
79 
80     __gshared {
81         pFT_Get_Glyph FT_Get_Glyph;
82         pFT_Glyph_Copy FT_Glyph_Copy;
83         pFT_Glyph_Transform FT_Glyph_Transform;
84         pFT_Glyph_Get_CBox FT_Glyph_Get_CBox;
85         pFT_Glyph_To_Bitmap FT_Glyph_To_Bitmap;
86         pFT_Done_Glyph FT_Done_Glyph;
87         pFT_Matrix_Multiply FT_Matrix_Multiply;
88         pFT_Matrix_Invert FT_Matrix_Invert;
89 
90         static if(ftSupport >= FTSupport.ft210) {
91             pFT_New_Glyph FT_New_Glyph;
92         }
93     }
94 }