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.ftrender;
8 
9 import bindbc.freetype.config;
10 import bindbc.freetype.bind.freetype,
11        bindbc.freetype.bind.ftglyph,
12        bindbc.freetype.bind.ftimage,
13        bindbc.freetype.bind.ftmodapi,
14        bindbc.freetype.bind.fttypes;
15 
16 extern(C) nothrow {
17     alias FT_Glyph_InitFunc = FT_Error function(FT_Glyph, FT_GlyphSlot);
18     alias FT_Glyph_DoneFunc = void function(FT_Glyph);
19     alias FT_Glyph_TransformFunc = void function(FT_Glyph, const(FT_Matrix)*, const(FT_Vector)*);
20     alias FT_Glyph_GetBBoxFunc = void function(FT_Glyph, FT_BBox*);
21     alias FT_Glyph_CopyFunc = FT_Error function(FT_Glyph, FT_Glyph);
22     alias FT_Glyph_PrepareFunc = FT_Error function(FT_Glyph, FT_GlyphSlot);
23 }
24 
25 struct FT_Glyph_Class {  // typedef'd in ftglyph.h
26     FT_Long glyph_size;
27     FT_Glyph_Format glyph_format;
28     FT_Glyph_InitFunc glyph_init;
29     FT_Glyph_DoneFunc glyph_done;
30     FT_Glyph_CopyFunc glyph_copy;
31     FT_Glyph_TransformFunc glyph_transform;
32     FT_Glyph_GetBBoxFunc glyph_bbox;
33     FT_Glyph_PrepareFunc glyph_prepare;
34 }
35 
36 extern(C) nothrow {
37     alias FT_Renderer_RenderFunc = FT_Error function(FT_Renderer, FT_GlyphSlot, FT_Render_Mode, const(FT_Vector)*);
38     alias FT_Renderer_TransformFunc = FT_Error function(FT_Renderer, FT_GlyphSlot, const(FT_Matrix)*, const(FT_Vector)*);
39     alias FT_Renderer_GetCBoxFunc = void function(FT_Renderer, FT_GlyphSlot, FT_BBox*);
40     alias FT_Renderer_SetModeFunc = FT_Error function(FT_Renderer, FT_ULong, FT_Pointer);
41 }
42 
43 struct FT_Renderer_Class {
44     FT_Module_Class root;
45     FT_Glyph_Format glyph_format;
46     FT_Renderer_RenderFunc render_glyph;
47     FT_Renderer_TransformFunc transform_glyph;
48     FT_Renderer_GetCBoxFunc get_glyph_cbox;
49     FT_Renderer_SetModeFunc set_mode;
50     FT_Raster_Funcs* raster_class;
51 }
52 
53 static if(staticBinding) {
54 	extern(C) @nogc nothrow {
55         FT_Renderer FT_Get_Renderer(FT_Library library, FT_Glyph_Format format);
56         FT_Error FT_Set_Renderer(FT_Library library, FT_Renderer renderer, FT_UInt num_params, FT_Parameter* parameters);
57     }
58 }
59 else {
60     extern(C) @nogc nothrow {
61         alias da_FT_Get_Renderer = FT_Renderer function(FT_Library library, FT_Glyph_Format format);
62         alias da_FT_Set_Renderer = FT_Error function(FT_Library library, FT_Renderer renderer, FT_UInt num_params, FT_Parameter* parameters);
63     }
64 
65     __gshared {
66         da_FT_Get_Renderer FT_Get_Renderer;
67         da_FT_Set_Renderer FT_Set_Renderer;
68     }
69 }