1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.freetype.ft;
29 
30 public {
31     import derelict.freetype.types;
32     import derelict.freetype.functions;
33 }
34 
35 private {
36     import derelict.util.loader;
37     import derelict.util.system;
38 
39     static if(Derelict_OS_Windows)
40         enum libNames = "freetype.dll,libfreetype.dll,libfreetype-6.dll";
41     else static if(Derelict_OS_Mac)
42         enum libNames = "libfreetype.dylib,libfreetype.6.dylib,libfreetype.6.3.16.dylib,/usr/X11/lib/libfreetype.dylib,/usr/X11/lib/libfreetype.6.dylib,/usr/X11/lib/libfreetype.6.3.16.dylib,/opt/X11/lib/libfreetype.dylib";
43     else static if(Derelict_OS_Android)
44         enum libNames = "libft2.so,libfreetype.so.6,libfreetype.so";
45     else static if(Derelict_OS_Posix)
46         enum libNames = "libfreetype.so.6,libfreetype.so";
47     else
48         static assert(0, "Need to implement FreeType libNames for this operating system.");
49 }
50 
51 class DerelictFTLoader : SharedLibLoader {
52     public this() {
53         super(libNames);
54     }
55 
56     protected override void loadSymbols() {
57         bindFunc(cast(void**)&FT_Init_FreeType, "FT_Init_FreeType");
58         bindFunc(cast(void**)&FT_Done_FreeType, "FT_Done_FreeType");
59         bindFunc(cast(void**)&FT_New_Face, "FT_New_Face");
60         bindFunc(cast(void**)&FT_New_Memory_Face, "FT_New_Memory_Face");
61         bindFunc(cast(void**)&FT_Open_Face, "FT_Open_Face");
62         bindFunc(cast(void**)&FT_Attach_File, "FT_Attach_File");
63         bindFunc(cast(void**)&FT_Attach_Stream, "FT_Attach_Stream");
64         bindFunc(cast(void**)&FT_Reference_Face, "FT_Reference_Face");
65         bindFunc(cast(void**)&FT_Done_Face, "FT_Done_Face");
66         bindFunc(cast(void**)&FT_Select_Size, "FT_Select_Size");
67         bindFunc(cast(void**)&FT_Request_Size, "FT_Request_Size");
68         bindFunc(cast(void**)&FT_Set_Char_Size, "FT_Set_Char_Size");
69         bindFunc(cast(void**)&FT_Set_Pixel_Sizes, "FT_Set_Pixel_Sizes");
70         bindFunc(cast(void**)&FT_Load_Glyph, "FT_Load_Glyph");
71         bindFunc(cast(void**)&FT_Load_Char, "FT_Load_Char");
72         bindFunc(cast(void**)&FT_Set_Transform, "FT_Set_Transform");
73         bindFunc(cast(void**)&FT_Render_Glyph, "FT_Render_Glyph");
74         bindFunc(cast(void**)&FT_Get_Kerning, "FT_Get_Kerning");
75         bindFunc(cast(void**)&FT_Get_Track_Kerning, "FT_Get_Track_Kerning");
76         bindFunc(cast(void**)&FT_Get_Glyph_Name, "FT_Get_Glyph_Name");
77         bindFunc(cast(void**)&FT_Get_Postscript_Name, "FT_Get_Postscript_Name");
78         bindFunc(cast(void**)&FT_Select_Charmap, "FT_Select_Charmap");
79         bindFunc(cast(void**)&FT_Set_Charmap, "FT_Set_Charmap");
80         bindFunc(cast(void**)&FT_Get_Charmap_Index, "FT_Get_Charmap_Index");
81         bindFunc(cast(void**)&FT_Get_Char_Index, "FT_Get_Char_Index");
82         bindFunc(cast(void**)&FT_Get_First_Char, "FT_Get_First_Char");
83         bindFunc(cast(void**)&FT_Get_Next_Char, "FT_Get_Next_Char");
84         bindFunc(cast(void**)&FT_Get_Name_Index, "FT_Get_Name_Index");
85         bindFunc(cast(void**)&FT_Get_SubGlyph_Info, "FT_Get_SubGlyph_Info");
86         bindFunc(cast(void**)&FT_Get_FSType_Flags, "FT_Get_FSType_Flags");
87         bindFunc(cast(void**)&FT_Face_GetCharVariantIndex, "FT_Face_GetCharVariantIndex");
88         bindFunc(cast(void**)&FT_Face_GetCharVariantIsDefault, "FT_Face_GetCharVariantIsDefault");
89         bindFunc(cast(void**)&FT_Face_GetVariantSelectors, "FT_Face_GetVariantSelectors");
90         bindFunc(cast(void**)&FT_Face_GetVariantsOfChar, "FT_Face_GetVariantsOfChar");
91         bindFunc(cast(void**)&FT_Face_GetCharsOfVariant, "FT_Face_GetCharsOfVariant");
92         bindFunc(cast(void**)&FT_MulDiv, "FT_MulDiv");
93         bindFunc(cast(void**)&FT_MulFix, "FT_MulFix");
94         bindFunc(cast(void**)&FT_DivFix, "FT_DivFix");
95         bindFunc(cast(void**)&FT_RoundFix, "FT_RoundFix");
96         bindFunc(cast(void**)&FT_CeilFix, "FT_CeilFix");
97         bindFunc(cast(void**)&FT_FloorFix, "FT_FloorFix");
98         bindFunc(cast(void**)&FT_Vector_Transform, "FT_Vector_Transform");
99         bindFunc(cast(void**)&FT_Library_Version, "FT_Library_Version");
100         bindFunc(cast(void**)&FT_Face_CheckTrueTypePatents, "FT_Face_CheckTrueTypePatents");
101         bindFunc(cast(void**)&FT_Face_SetUnpatentedHinting, "FT_Face_SetUnpatentedHinting");
102 
103         bindFunc(cast(void**)&FT_Get_Advance, "FT_Get_Advance");
104         bindFunc(cast(void**)&FT_Get_Advances, "FT_Get_Advances");
105 
106         bindFunc(cast(void**)&FT_Outline_Get_BBox, "FT_Outline_Get_BBox");
107 
108         version(linux) {
109             bindFunc(cast(void**)&FT_Get_BDF_Charset_ID, "FT_Get_BDF_Charset_ID");
110             bindFunc(cast(void**)&FT_Get_BDF_Property, "FT_Get_BDF_Property");
111         }
112 
113         bindFunc(cast(void**)&FT_Bitmap_Init, "FT_Bitmap_Init");
114         bindFunc(cast(void**)&FT_Bitmap_Copy, "FT_Bitmap_Copy");
115         bindFunc(cast(void**)&FT_Bitmap_Embolden, "FT_Bitmap_Embolden");
116         bindFunc(cast(void**)&FT_Bitmap_Convert, "FT_Bitmap_Convert");
117         bindFunc(cast(void**)&FT_Bitmap_Done, "FT_Bitmap_Done");
118         bindFunc(cast(void**)&FT_GlyphSlot_Own_Bitmap, "FT_GlyphSlot_Own_Bitmap");
119 
120 //        bindFunc(cast(void**)&FT_Stream_OpenBzip2, "FT_Stream_OpenBzip2");
121 
122         bindFunc(cast(void**)&FTC_Manager_New, "FTC_Manager_New");
123         bindFunc(cast(void**)&FTC_Manager_Reset, "FTC_Manager_Reset");
124         bindFunc(cast(void**)&FTC_Manager_Done, "FTC_Manager_Done");
125         bindFunc(cast(void**)&FTC_Manager_LookupFace, "FTC_Manager_LookupFace");
126         bindFunc(cast(void**)&FTC_Manager_LookupSize, "FTC_Manager_LookupSize");
127         bindFunc(cast(void**)&FTC_Node_Unref, "FTC_Node_Unref");
128         bindFunc(cast(void**)&FTC_Manager_RemoveFaceID, "FTC_Manager_RemoveFaceID");
129         bindFunc(cast(void**)&FTC_CMapCache_New, "FTC_CMapCache_New");
130         bindFunc(cast(void**)&FTC_CMapCache_Lookup, "FTC_CMapCache_Lookup");
131         bindFunc(cast(void**)&FTC_ImageCache_New, "FTC_ImageCache_New");
132         bindFunc(cast(void**)&FTC_ImageCache_Lookup, "FTC_ImageCache_Lookup");
133         bindFunc(cast(void**)&FTC_ImageCache_LookupScaler, "FTC_ImageCache_LookupScaler");
134         bindFunc(cast(void**)&FTC_SBitCache_New, "FTC_SBitCache_New");
135         bindFunc(cast(void**)&FTC_SBitCache_Lookup, "FTC_SBitCache_Lookup");
136         bindFunc(cast(void**)&FTC_SBitCache_LookupScaler, "FTC_SBitCache_LookupScaler");
137 
138         bindFunc(cast(void**)&FT_Get_CID_Registry_Ordering_Supplement, "FT_Get_CID_Registry_Ordering_Supplement");
139         bindFunc(cast(void**)&FT_Get_CID_Is_Internally_CID_Keyed, "FT_Get_CID_Is_Internally_CID_Keyed");
140         bindFunc(cast(void**)&FT_Get_CID_From_Glyph_Index, "FT_Get_CID_From_Glyph_Index");
141 
142         bindFunc(cast(void**)&FT_Get_Gasp, "FT_Get_Gasp");
143 
144         bindFunc(cast(void**)&FT_Get_Glyph, "FT_Get_Glyph");
145         bindFunc(cast(void**)&FT_Glyph_Copy, "FT_Glyph_Copy");
146         bindFunc(cast(void**)&FT_Glyph_Transform, "FT_Glyph_Transform");
147         bindFunc(cast(void**)&FT_Glyph_Get_CBox, "FT_Glyph_Get_CBox");
148         bindFunc(cast(void**)&FT_Glyph_To_Bitmap, "FT_Glyph_To_Bitmap");
149         bindFunc(cast(void**)&FT_Done_Glyph, "FT_Done_Glyph");
150         bindFunc(cast(void**)&FT_Matrix_Multiply, "FT_Matrix_Multiply");
151         bindFunc(cast(void**)&FT_Matrix_Invert, "FT_Matrix_Invert");
152 
153         bindFunc(cast(void**)&FT_TrueTypeGX_Validate, "FT_TrueTypeGX_Validate");
154         bindFunc(cast(void**)&FT_TrueTypeGX_Free, "FT_TrueTypeGX_Free");
155         bindFunc(cast(void**)&FT_ClassicKern_Validate, "FT_ClassicKern_Validate");
156         bindFunc(cast(void**)&FT_ClassicKern_Free, "FT_ClassicKern_Free");
157 
158         bindFunc(cast(void**)&FT_Stream_OpenGzip, "FT_Stream_OpenGzip");
159         bindFunc(cast(void**)&FT_Gzip_Uncompress, "FT_Gzip_Uncompress");
160 
161         bindFunc(cast(void**)&FT_Library_SetLcdFilter, "FT_Library_SetLcdFilter");
162         bindFunc(cast(void**)&FT_Library_SetLcdFilterWeights, "FT_Library_SetLcdFilterWeights");
163 
164         bindFunc(cast(void**)&FT_List_Find, "FT_List_Find");
165         bindFunc(cast(void**)&FT_List_Add, "FT_List_Add");
166         bindFunc(cast(void**)&FT_List_Insert, "FT_List_Insert");
167         bindFunc(cast(void**)&FT_List_Remove, "FT_List_Remove");
168         bindFunc(cast(void**)&FT_List_Up, "FT_List_Up");
169         bindFunc(cast(void**)&FT_List_Iterate, "FT_List_Iterate");
170         bindFunc(cast(void**)&FT_List_Finalize, "FT_List_Finalize");
171 
172         bindFunc(cast(void**)&FT_Stream_OpenLZW, "FT_Stream_OpenLZW");
173 
174         bindFunc(cast(void**)&FT_Get_Multi_Master, "FT_Get_Multi_Master");
175         bindFunc(cast(void**)&FT_Get_MM_Var, "FT_Get_MM_Var");
176         bindFunc(cast(void**)&FT_Set_MM_Design_Coordinates, "FT_Set_MM_Design_Coordinates");
177         bindFunc(cast(void**)&FT_Set_Var_Design_Coordinates, "FT_Set_Var_Design_Coordinates");
178         bindFunc(cast(void**)&FT_Set_MM_Blend_Coordinates, "FT_Set_MM_Blend_Coordinates");
179         bindFunc(cast(void**)&FT_Set_Var_Blend_Coordinates, "FT_Set_Var_Blend_Coordinates");
180 
181         bindFunc(cast(void**)&FT_Add_Module, "FT_Add_Module");
182         bindFunc(cast(void**)&FT_Get_Module, "FT_Get_Module");
183         bindFunc(cast(void**)&FT_Remove_Module, "FT_Remove_Module");
184         bindFunc(cast(void**)&FT_Property_Set, "FT_Property_Set");
185         bindFunc(cast(void**)&FT_Property_Get, "FT_Property_Get");
186         bindFunc(cast(void**)&FT_Reference_Library, "FT_Reference_Library");
187         bindFunc(cast(void**)&FT_New_Library, "FT_New_Library");
188         bindFunc(cast(void**)&FT_Done_Library, "FT_Done_Library");
189         bindFunc(cast(void**)&FT_Set_Debug_Hook, "FT_Set_Debug_Hook");
190         bindFunc(cast(void**)&FT_Add_Default_Modules, "FT_Add_Default_Modules");
191         bindFunc(cast(void**)&FT_Get_TrueType_Engine_Type, "FT_Get_TrueType_Engine_Type");
192 
193         bindFunc(cast(void**)&FT_OpenType_Validate, "FT_OpenType_Validate");
194         bindFunc(cast(void**)&FT_OpenType_Free, "FT_OpenType_Free");
195 
196         bindFunc(cast(void**)&FT_Outline_Decompose, "FT_Outline_Decompose");
197         bindFunc(cast(void**)&FT_Outline_New, "FT_Outline_New");
198         bindFunc(cast(void**)&FT_Outline_New_Internal, "FT_Outline_New_Internal");
199         bindFunc(cast(void**)&FT_Outline_Done, "FT_Outline_Done");
200         bindFunc(cast(void**)&FT_Outline_Done_Internal, "FT_Outline_Done_Internal");
201         bindFunc(cast(void**)&FT_Outline_Check, "FT_Outline_Check");
202         bindFunc(cast(void**)&FT_Outline_Get_CBox, "FT_Outline_Get_CBox");
203         bindFunc(cast(void**)&FT_Outline_Translate, "FT_Outline_Translate");
204         bindFunc(cast(void**)&FT_Outline_Copy, "FT_Outline_Copy");
205         bindFunc(cast(void**)&FT_Outline_Transform, "FT_Outline_Transform");
206         bindFunc(cast(void**)&FT_Outline_Embolden, "FT_Outline_Embolden");
207         bindFunc(cast(void**)&FT_Outline_EmboldenXY, "FT_Outline_EmboldenXY");
208         bindFunc(cast(void**)&FT_Outline_Reverse, "FT_Outline_Reverse");
209         bindFunc(cast(void**)&FT_Outline_Get_Bitmap, "FT_Outline_Get_Bitmap");
210         bindFunc(cast(void**)&FT_Outline_Render, "FT_Outline_Render");
211         bindFunc(cast(void**)&FT_Outline_Get_Orientation, "FT_Outline_Get_Orientation");
212 
213         bindFunc(cast(void**)&FT_Get_PFR_Metrics, "FT_Get_PFR_Metrics");
214         bindFunc(cast(void**)&FT_Get_PFR_Kerning, "FT_Get_PFR_Kerning");
215         bindFunc(cast(void**)&FT_Get_PFR_Advance, "FT_Get_PFR_Advance");
216 
217         bindFunc(cast(void**)&FT_Get_Renderer, "FT_Get_Renderer");
218         bindFunc(cast(void**)&FT_Set_Renderer, "FT_Set_Renderer");
219 
220         bindFunc(cast(void**)&FT_New_Size, "FT_New_Size");
221         bindFunc(cast(void**)&FT_Done_Size, "FT_Done_Size");
222         bindFunc(cast(void**)&FT_Activate_Size, "FT_Activate_Size");
223 
224         bindFunc(cast(void**)&FT_Get_Sfnt_Name_Count, "FT_Get_Sfnt_Name_Count");
225         bindFunc(cast(void**)&FT_Get_Sfnt_Name, "FT_Get_Sfnt_Name");
226 
227         bindFunc(cast(void**)&FT_Outline_GetInsideBorder, "FT_Outline_GetInsideBorder");
228         bindFunc(cast(void**)&FT_Outline_GetOutsideBorder, "FT_Outline_GetOutsideBorder");
229         bindFunc(cast(void**)&FT_Stroker_New, "FT_Stroker_New");
230         bindFunc(cast(void**)&FT_Stroker_Set, "FT_Stroker_Set");
231         bindFunc(cast(void**)&FT_Stroker_Rewind, "FT_Stroker_Rewind");
232         bindFunc(cast(void**)&FT_Stroker_ParseOutline, "FT_Stroker_ParseOutline");
233         bindFunc(cast(void**)&FT_Stroker_BeginSubPath, "FT_Stroker_BeginSubPath");
234         bindFunc(cast(void**)&FT_Stroker_EndSubPath, "FT_Stroker_EndSubPath");
235         bindFunc(cast(void**)&FT_Stroker_LineTo, "FT_Stroker_LineTo");
236         bindFunc(cast(void**)&FT_Stroker_ConicTo, "FT_Stroker_ConicTo");
237         bindFunc(cast(void**)&FT_Stroker_CubicTo, "FT_Stroker_CubicTo");
238         bindFunc(cast(void**)&FT_Stroker_GetBorderCounts, "FT_Stroker_GetBorderCounts");
239         bindFunc(cast(void**)&FT_Stroker_ExportBorder, "FT_Stroker_ExportBorder");
240         bindFunc(cast(void**)&FT_Stroker_GetCounts, "FT_Stroker_GetCounts");
241         bindFunc(cast(void**)&FT_Stroker_Export, "FT_Stroker_Export");
242         bindFunc(cast(void**)&FT_Stroker_Done, "FT_Stroker_Done");
243         bindFunc(cast(void**)&FT_Glyph_Stroke, "FT_Glyph_Stroke");
244         bindFunc(cast(void**)&FT_Glyph_StrokeBorder, "FT_Glyph_StrokeBorder");
245 
246         bindFunc(cast(void**)&FT_GlyphSlot_Embolden, "FT_GlyphSlot_Embolden");
247         bindFunc(cast(void**)&FT_GlyphSlot_Oblique, "FT_GlyphSlot_Oblique");
248 
249         bindFunc(cast(void**)&FT_Sin, "FT_Sin");
250         bindFunc(cast(void**)&FT_Cos, "FT_Cos");
251         bindFunc(cast(void**)&FT_Tan, "FT_Tan");
252         bindFunc(cast(void**)&FT_Atan2, "FT_Atan2");
253         bindFunc(cast(void**)&FT_Angle_Diff, "FT_Angle_Diff");
254         bindFunc(cast(void**)&FT_Vector_Unit, "FT_Vector_Unit");
255         bindFunc(cast(void**)&FT_Vector_Rotate, "FT_Vector_Rotate");
256         bindFunc(cast(void**)&FT_Vector_Length, "FT_Vector_Length");
257         bindFunc(cast(void**)&FT_Vector_Polarize, "FT_Vector_Polarize");
258         bindFunc(cast(void**)&FT_Vector_From_Polar, "FT_Vector_From_Polar");
259 
260         bindFunc(cast(void**)&FT_Get_WinFNT_Header, "FT_Get_WinFNT_Header");
261 
262         bindFunc(cast(void**)&FT_Get_X11_Font_Format, "FT_Get_X11_Font_Format");
263 
264         bindFunc(cast(void**)&FT_Has_PS_Glyph_Names, "FT_Has_PS_Glyph_Names");
265         bindFunc(cast(void**)&FT_Get_PS_Font_Info, "FT_Get_PS_Font_Info");
266         bindFunc(cast(void**)&FT_Get_PS_Font_Private, "FT_Get_PS_Font_Private");
267         bindFunc(cast(void**)&FT_Get_PS_Font_Value, "FT_Get_PS_Font_Value");
268 
269         bindFunc(cast(void**)&FT_Get_Sfnt_Table, "FT_Get_Sfnt_Table");
270         bindFunc(cast(void**)&FT_Load_Sfnt_Table, "FT_Load_Sfnt_Table");
271         bindFunc(cast(void**)&FT_Sfnt_Table_Info, "FT_Sfnt_Table_Info");
272         bindFunc(cast(void**)&FT_Get_CMap_Language_ID, "FT_Get_CMap_Language_ID");
273         bindFunc(cast(void**)&FT_Get_CMap_Format, "FT_Get_CMap_Format");
274     }
275 }
276 
277 __gshared DerelictFTLoader DerelictFT;
278 
279 shared static this() {
280     DerelictFT = new DerelictFTLoader();
281 }