FT.Internal.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. #region MIT License
  2. /*Copyright (c) 2012 Robert Rouhani <robert.rouhani@gmail.com>
  3. SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
  4. Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. this software and associated documentation files (the "Software"), to deal in
  6. the Software without restriction, including without limitation the rights to
  7. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  8. of the Software, and to permit persons to whom the Software is furnished to do
  9. so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.*/
  19. #endregion
  20. using System;
  21. using System.Runtime.InteropServices;
  22. using SharpFont.Cache;
  23. using SharpFont.PostScript;
  24. using SharpFont.TrueType;
  25. namespace SharpFont
  26. {
  27. /// <content>
  28. /// This file contains all the raw FreeType2 function signatures.
  29. /// </content>
  30. public static partial class FT
  31. {
  32. /// <summary>
  33. /// Defines the location of the FreeType DLL. Update SharpFont.dll.config if you change this!
  34. /// </summary>
  35. private const string FreetypeDll = "freetype.dll";
  36. /// <summary>
  37. /// Defines the calling convention for P/Invoking the native freetype methods.
  38. /// </summary>
  39. private const CallingConvention CallConvention = CallingConvention.Cdecl;
  40. #region Core API
  41. #region FreeType Version
  42. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  43. internal static extern void FT_Library_Version(IntPtr library, out int amajor, out int aminor, out int apatch);
  44. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  45. [return: MarshalAs(UnmanagedType.U1)]
  46. internal static extern bool FT_Face_CheckTrueTypePatents(IntPtr face);
  47. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  48. [return: MarshalAs(UnmanagedType.U1)]
  49. internal static extern bool FT_Face_SetUnpatentedHinting(IntPtr face, [MarshalAs(UnmanagedType.U1)] bool value);
  50. #endregion
  51. #region Base Interface
  52. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  53. internal static extern Error FT_Init_FreeType(out IntPtr alibrary);
  54. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  55. internal static extern Error FT_Done_FreeType(IntPtr library);
  56. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  57. internal static extern Error FT_New_Face(IntPtr library, string filepathname, int face_index, out IntPtr aface);
  58. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  59. internal static extern Error FT_New_Memory_Face(IntPtr library, IntPtr file_base, int file_size, int face_index, out IntPtr aface);
  60. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  61. internal static extern Error FT_Open_Face(IntPtr library, IntPtr args, int face_index, out IntPtr aface);
  62. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  63. internal static extern Error FT_Attach_File(IntPtr face, string filepathname);
  64. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  65. internal static extern Error FT_Attach_Stream(IntPtr face, IntPtr parameters);
  66. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  67. internal static extern Error FT_Reference_Face(IntPtr face);
  68. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  69. internal static extern Error FT_Done_Face(IntPtr face);
  70. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  71. internal static extern Error FT_Select_Size(IntPtr face, int strike_index);
  72. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  73. internal static extern Error FT_Request_Size(IntPtr face, IntPtr req);
  74. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  75. internal static extern Error FT_Set_Char_Size(IntPtr face, int char_width, int char_height, uint horz_resolution, uint vert_resolution);
  76. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  77. internal static extern Error FT_Set_Pixel_Sizes(IntPtr face, uint pixel_width, uint pixel_height);
  78. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  79. internal static extern Error FT_Load_Glyph(IntPtr face, uint glyph_index, int load_flags);
  80. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  81. internal static extern Error FT_Load_Char(IntPtr face, uint char_code, int load_flags);
  82. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  83. internal static extern void FT_Set_Transform(IntPtr face, ref FTMatrix matrix, ref FTVector delta);
  84. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  85. internal static extern Error FT_Render_Glyph(IntPtr slot, RenderMode render_mode);
  86. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  87. internal static extern Error FT_Get_Kerning(IntPtr face, uint left_glyph, uint right_glyph, KerningMode kern_mode, out FTVector akerning);
  88. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  89. internal static extern Error FT_Get_Track_Kerning(IntPtr face, int point_size, int degree, out int akerning);
  90. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  91. internal static extern Error FT_Get_Glyph_Name(IntPtr face, uint glyph_index, IntPtr buffer, uint buffer_max);
  92. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  93. internal static extern IntPtr FT_Get_Postscript_Name(IntPtr face);
  94. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  95. internal static extern Error FT_Select_Charmap(IntPtr face, Encoding encoding);
  96. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  97. internal static extern Error FT_Set_Charmap(IntPtr face, IntPtr charmap);
  98. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  99. internal static extern int FT_Get_Charmap_Index(IntPtr charmap);
  100. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  101. internal static extern uint FT_Get_Char_Index(IntPtr face, uint charcode);
  102. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  103. internal static extern uint FT_Get_First_Char(IntPtr face, out uint agindex);
  104. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  105. internal static extern uint FT_Get_Next_Char(IntPtr face, uint char_code, out uint agindex);
  106. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  107. internal static extern uint FT_Get_Name_Index(IntPtr face, IntPtr glyph_name);
  108. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  109. internal static extern Error FT_Get_SubGlyph_Info(IntPtr glyph, uint sub_index, out int p_index, out SubGlyphFlags p_flags, out int p_arg1, out int p_arg2, out FTMatrix p_transform);
  110. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  111. internal static extern EmbeddingTypes FT_Get_FSType_Flags(IntPtr face);
  112. #endregion
  113. #region Glyph Variants
  114. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  115. internal static extern uint FT_Face_GetCharVariantIndex(IntPtr face, uint charcode, uint variantSelector);
  116. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  117. internal static extern int FT_Face_GetCharVariantIsDefault(IntPtr face, uint charcode, uint variantSelector);
  118. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  119. internal static extern IntPtr FT_Face_GetVariantSelectors(IntPtr face);
  120. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  121. internal static extern IntPtr FT_Face_GetVariantsOfChar(IntPtr face, uint charcode);
  122. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  123. internal static extern IntPtr FT_Face_GetCharsOfVariant(IntPtr face, uint variantSelector);
  124. #endregion
  125. #region Glyph Management
  126. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  127. internal static extern Error FT_Get_Glyph(IntPtr slot, out IntPtr aglyph);
  128. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  129. internal static extern Error FT_Glyph_Copy(IntPtr source, out IntPtr target);
  130. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  131. internal static extern Error FT_Glyph_Transform(IntPtr glyph, ref FTMatrix matrix, ref FTVector delta);
  132. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  133. internal static extern void FT_Glyph_Get_CBox(IntPtr glyph, GlyphBBoxMode bbox_mode, out IntPtr acbox);
  134. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  135. internal static extern Error FT_Glyph_To_Bitmap(ref IntPtr the_glyph, RenderMode render_mode, ref FTVector origin, [MarshalAs(UnmanagedType.U1)] bool destroy);
  136. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  137. internal static extern void FT_Done_Glyph(IntPtr glyph);
  138. #endregion
  139. #region Mac Specific Interface
  140. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  141. internal static extern Error FT_New_Face_From_FOND(IntPtr library, IntPtr fond, int face_index, out IntPtr aface);
  142. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  143. internal static extern Error FT_GetFile_From_Mac_Name(string fontName, out IntPtr pathSpec, out int face_index);
  144. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  145. internal static extern Error FT_GetFile_From_Mac_ATS_Name(string fontName, out IntPtr pathSpec, out int face_index);
  146. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  147. internal static extern Error FT_GetFilePath_From_Mac_ATS_Name(string fontName, IntPtr path, int maxPathSize, out int face_index);
  148. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  149. internal static extern Error FT_New_Face_From_FSSpec(IntPtr library, IntPtr spec, int face_index, out IntPtr aface);
  150. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  151. internal static extern Error FT_New_Face_From_FSRef(IntPtr library, IntPtr @ref, int face_index, out IntPtr aface);
  152. #endregion
  153. #region Size Management
  154. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  155. internal static extern Error FT_New_Size(IntPtr face, out IntPtr size);
  156. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  157. internal static extern Error FT_Done_Size(IntPtr size);
  158. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  159. internal static extern Error FT_Activate_Size(IntPtr size);
  160. #endregion
  161. #endregion
  162. #region Format-Specific API
  163. #region Multiple Masters
  164. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  165. internal static extern Error FT_Get_Multi_Master(IntPtr face, out IntPtr amaster);
  166. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  167. internal static extern Error FT_Get_MM_Var(IntPtr face, out IntPtr amaster);
  168. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  169. internal static extern Error FT_Set_MM_Design_Coordinates(IntPtr face, uint num_coords, IntPtr coords);
  170. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  171. internal static extern Error FT_Set_Var_Design_Coordinates(IntPtr face, uint num_coords, IntPtr coords);
  172. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  173. internal static extern Error FT_Set_MM_Blend_Coordinates(IntPtr face, uint num_coords, IntPtr coords);
  174. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  175. internal static extern Error FT_Set_Var_Blend_Coordinates(IntPtr face, uint num_coords, IntPtr coords);
  176. #endregion
  177. #region TrueType Tables
  178. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  179. internal static extern IntPtr FT_Get_Sfnt_Table(IntPtr face, SfntTag tag);
  180. //TODO find FT_TRUETYPE_TAGS_H and create an enum for "tag"
  181. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  182. internal static extern Error FT_Load_Sfnt_Table(IntPtr face, uint tag, int offset, IntPtr buffer, ref uint length);
  183. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  184. internal static unsafe extern Error FT_Sfnt_Table_Info(IntPtr face, uint table_index, SfntTag* tag, out uint length);
  185. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  186. internal static extern uint FT_Get_CMap_Language_ID(IntPtr charmap);
  187. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  188. internal static extern int FT_Get_CMap_Format(IntPtr charmap);
  189. #endregion
  190. #region Type 1 Tables
  191. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  192. [return: MarshalAs(UnmanagedType.U1)]
  193. internal static extern bool FT_Has_PS_Glyph_Names(IntPtr face);
  194. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  195. internal static extern Error FT_Get_PS_Font_Info(IntPtr face, out IntPtr afont_info);
  196. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  197. internal static extern Error FT_Get_PS_Font_Private(IntPtr face, out IntPtr afont_private);
  198. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  199. internal static extern int FT_Get_PS_Font_Value(IntPtr face, DictionaryKeys key, uint idx, ref IntPtr value, int value_len);
  200. #endregion
  201. #region SFNT Names
  202. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  203. internal static extern uint FT_Get_Sfnt_Name_Count(IntPtr face);
  204. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  205. internal static extern Error FT_Get_Sfnt_Name(IntPtr face, uint idx, out IntPtr aname);
  206. #endregion
  207. #region BDF and PCF Files
  208. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  209. internal static extern Error FT_Get_BDF_Charset_ID(IntPtr face, out string acharset_encoding, out string acharset_registry);
  210. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  211. internal static extern Error FT_Get_BDF_Property(IntPtr face, string prop_name, out IntPtr aproperty);
  212. #endregion
  213. #region CID Fonts
  214. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  215. internal static extern Error FT_Get_CID_Registry_Ordering_Supplement(IntPtr face, out string registry, out string ordering, out int aproperty);
  216. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  217. internal static extern Error FT_Get_CID_Is_Internally_CID_Keyed(IntPtr face, out byte is_cid);
  218. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  219. internal static extern Error FT_Get_CID_From_Glyph_Index(IntPtr face, uint glyph_index, out uint cid);
  220. #endregion
  221. #region PFR Fonts
  222. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  223. internal static extern Error FT_Get_PFR_Metrics(IntPtr face, out uint aoutline_resolution, out uint ametrics_resolution, out int ametrics_x_scale, out int ametrics_y_scale);
  224. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  225. internal static extern Error FT_Get_PFR_Kerning(IntPtr face, uint left, uint right, out FTVector avector);
  226. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  227. internal static extern Error FT_Get_PFR_Advance(IntPtr face, uint gindex, out int aadvance);
  228. #endregion
  229. #region Window FNT Files
  230. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  231. internal static extern Error FT_Get_WinFNT_Header(IntPtr face, out IntPtr aheader);
  232. #endregion
  233. #region Font Formats
  234. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  235. internal static extern IntPtr FT_Get_X11_Font_Format(IntPtr face);
  236. #endregion
  237. #region Gasp Table
  238. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  239. internal static extern Gasp FT_Get_Gasp(IntPtr face, uint ppem);
  240. #endregion
  241. #endregion
  242. #region Support API
  243. #region Computations
  244. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  245. internal static extern int FT_MulDiv(int a, int b, int c);
  246. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  247. internal static extern int FT_MulFix(int a, int b);
  248. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  249. internal static extern int FT_DivFix(int a, int b);
  250. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  251. internal static extern int FT_RoundFix(int a);
  252. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  253. internal static extern int FT_CeilFix(int a);
  254. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  255. internal static extern int FT_FloorFix(int a);
  256. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  257. internal static extern void FT_Vector_Transform(ref FTVector vec, ref FTMatrix matrix);
  258. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  259. internal static extern void FT_Matrix_Multiply(ref FTMatrix a, ref FTMatrix b);
  260. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  261. internal static extern Error FT_Matrix_Invert(ref FTMatrix matrix);
  262. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  263. internal static extern int FT_Sin(int angle);
  264. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  265. internal static extern int FT_Cos(int angle);
  266. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  267. internal static extern int FT_Tan(int angle);
  268. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  269. internal static extern int FT_Atan2(int x, int y);
  270. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  271. internal static extern int FT_Angle_Diff(int angle1, int angle2);
  272. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  273. internal static extern void FT_Vector_Unit(out FTVector vec, int angle);
  274. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  275. internal static extern void FT_Vector_Rotate(ref FTVector vec, int angle);
  276. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  277. internal static extern int FT_Vector_Length(ref FTVector vec);
  278. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  279. internal static extern void FT_Vector_Polarize(ref FTVector vec, out int length, out int angle);
  280. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  281. internal static extern void FT_Vector_From_Polar(out FTVector vec, int length, int angle);
  282. #endregion
  283. #region List Processing
  284. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  285. internal static extern IntPtr FT_List_Find(IntPtr list, IntPtr data);
  286. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  287. internal static extern void FT_List_Add(IntPtr list, IntPtr node);
  288. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  289. internal static extern void FT_List_Insert(IntPtr list, IntPtr node);
  290. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  291. internal static extern void FT_List_Remove(IntPtr list, IntPtr node);
  292. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  293. internal static extern void FT_List_Up(IntPtr list, IntPtr node);
  294. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  295. internal static extern Error FT_List_Iterate(IntPtr list, ListIterator iterator, IntPtr user);
  296. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  297. internal static extern void FT_List_Finalize(IntPtr list, ListDestructor destroy, IntPtr memory, IntPtr user);
  298. #endregion
  299. #region Outline Processing
  300. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  301. internal static extern Error FT_Outline_New(IntPtr library, uint numPoints, int numContours, out IntPtr anoutline);
  302. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  303. internal static extern Error FT_Outline_New_Internal(IntPtr memory, uint numPoints, int numContours, out IntPtr anoutline);
  304. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  305. internal static extern Error FT_Outline_Done(IntPtr library, IntPtr outline);
  306. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  307. internal static extern Error FT_Outline_Done_Internal(IntPtr memory, IntPtr outline);
  308. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  309. internal static extern Error FT_Outline_Copy(IntPtr source, ref IntPtr target);
  310. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  311. internal static extern void FT_Outline_Translate(IntPtr outline, int xOffset, int yOffset);
  312. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  313. internal static extern void FT_Outline_Transform(IntPtr outline, ref FTMatrix matrix);
  314. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  315. internal static extern Error FT_Outline_Embolden(IntPtr outline, int strength);
  316. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  317. internal static extern Error FT_Outline_EmboldenXY(IntPtr outline, int xstrength, int ystrength);
  318. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  319. internal static extern void FT_Outline_Reverse(IntPtr outline);
  320. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  321. internal static extern Error FT_Outline_Check(IntPtr outline);
  322. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  323. internal static extern Error FT_Outline_Get_BBox(IntPtr outline, out IntPtr abbox);
  324. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  325. internal static extern Error FT_Outline_Decompose(IntPtr outline, IntPtr func_interface, IntPtr user);
  326. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  327. internal static extern void FT_Outline_Get_CBox(IntPtr outline, out IntPtr acbox);
  328. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  329. internal static extern Error FT_Outline_Get_Bitmap(IntPtr library, IntPtr outline, IntPtr abitmap);
  330. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  331. internal static extern Error FT_Outline_Render(IntPtr library, IntPtr outline, IntPtr @params);
  332. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  333. internal static extern Orientation FT_Outline_Get_Orientation(IntPtr outline);
  334. #endregion
  335. #region Quick retrieval of advance values
  336. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  337. internal static extern Error FT_Get_Advance(IntPtr face, uint gIndex, LoadFlags load_flags, out int padvance);
  338. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  339. internal static extern Error FT_Get_Advances(IntPtr face, uint start, uint count, LoadFlags load_flags, out IntPtr padvance);
  340. #endregion
  341. #region Bitmap Handling
  342. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  343. internal static extern void FT_Bitmap_New(out IntPtr abitmap);
  344. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  345. internal static extern Error FT_Bitmap_Copy(IntPtr library, IntPtr source, out IntPtr target);
  346. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  347. internal static extern Error FT_Bitmap_Embolden(IntPtr library, IntPtr bitmap, int xStrength, int yStrength);
  348. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  349. internal static extern Error FT_Bitmap_Convert(IntPtr library, IntPtr source, out IntPtr target, int alignment);
  350. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  351. internal static extern Error FT_GlyphSlot_Own_Bitmap(IntPtr slot);
  352. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  353. internal static extern Error FT_Bitmap_Done(IntPtr library, IntPtr bitmap);
  354. #endregion
  355. #region Glyph Stroker
  356. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  357. internal static extern StrokerBorder FT_Outline_GetInsideBorder(IntPtr outline);
  358. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  359. internal static extern StrokerBorder FT_Outline_GetOutsideBorder(IntPtr outline);
  360. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  361. internal static extern Error FT_Stroker_New(IntPtr library, out IntPtr astroker);
  362. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  363. internal static extern void FT_Stroker_Set(IntPtr stroker, int radius, StrokerLineCap line_cap, StrokerLineJoin line_join, int miter_limit);
  364. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  365. internal static extern void FT_Stroker_Rewind(IntPtr stroker);
  366. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  367. internal static extern Error FT_Stroker_ParseOutline(IntPtr stroker, IntPtr outline, [MarshalAs(UnmanagedType.U1)] bool opened);
  368. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  369. internal static extern Error FT_Stroker_BeginSubPath(IntPtr stroker, ref FTVector to, [MarshalAs(UnmanagedType.U1)] bool open);
  370. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  371. internal static extern Error FT_Stroker_EndSubPath(IntPtr stroker);
  372. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  373. internal static extern Error FT_Stroker_LineTo(IntPtr stroker, ref FTVector to);
  374. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  375. internal static extern Error FT_Stroker_ConicTo(IntPtr stroker, ref FTVector control, ref FTVector to);
  376. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  377. internal static extern Error FT_Stroker_CubicTo(IntPtr stroker, ref FTVector control1, ref FTVector control2, ref FTVector to);
  378. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  379. internal static extern Error FT_Stroker_GetBorderCounts(IntPtr stroker, StrokerBorder border, out uint anum_points, out uint anum_contours);
  380. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  381. internal static extern void FT_Stroker_ExportBorder(IntPtr stroker, StrokerBorder border, IntPtr outline);
  382. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  383. internal static extern Error FT_Stroker_GetCounts(IntPtr stroker, out uint anum_points, out uint anum_contours);
  384. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  385. internal static extern void FT_Stroker_Export(IntPtr stroker, IntPtr outline);
  386. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  387. internal static extern void FT_Stroker_Done(IntPtr stroker);
  388. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  389. internal static extern Error FT_Glyph_Stroke(ref IntPtr pglyph, IntPtr stoker, [MarshalAs(UnmanagedType.U1)] bool destroy);
  390. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  391. internal static extern Error FT_Glyph_StrokeBorder(ref IntPtr pglyph, IntPtr stoker, [MarshalAs(UnmanagedType.U1)] bool inside, [MarshalAs(UnmanagedType.U1)] bool destroy);
  392. #endregion
  393. #region Module Management
  394. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  395. internal static extern Error FT_Add_Module(IntPtr library, IntPtr clazz);
  396. [DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
  397. internal static extern IntPtr FT_Get_Module(IntPtr library, string module_name);
  398. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  399. internal static extern Error FT_Remove_Module(IntPtr library, IntPtr module);
  400. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  401. internal static extern Error FT_Reference_Library(IntPtr library);
  402. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  403. internal static extern Error FT_New_Library(IntPtr memory, out IntPtr alibrary);
  404. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  405. internal static extern Error FT_Done_Library(IntPtr library);
  406. //TODO figure out the method signature for debug_hook. (FT_DebugHook_Func)
  407. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  408. internal static extern void FT_Set_Debug_Hook(IntPtr library, uint hook_index, IntPtr debug_hook);
  409. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  410. internal static extern void FT_Add_Default_Modules(IntPtr library);
  411. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  412. internal static extern IntPtr FT_Get_Renderer(IntPtr library, GlyphFormat format);
  413. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  414. internal static extern Error FT_Set_Renderer(IntPtr library, IntPtr renderer, uint num_params, IntPtr parameters);
  415. #endregion
  416. #region GZIP Streams
  417. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  418. internal static extern Error FT_Stream_OpenGzip(IntPtr stream, IntPtr source);
  419. #endregion
  420. #region LZW Streams
  421. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  422. internal static extern Error FT_Stream_OpenLZW(IntPtr stream, IntPtr source);
  423. #endregion
  424. #region BZIP2 Streams
  425. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  426. internal static extern Error FT_Stream_OpenBzip2(IntPtr stream, IntPtr source);
  427. #endregion
  428. #region LCD Filtering
  429. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  430. internal static extern Error FT_Library_SetLcdFilter(IntPtr library, LcdFilter filter);
  431. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  432. internal static extern Error FT_Library_SetLcdFilterWeights(IntPtr library, byte[] weights);
  433. #endregion
  434. #endregion
  435. #region Caching Sub-system
  436. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  437. internal static extern Error FTC_Manager_New(IntPtr library, uint max_faces, uint max_sizes, ulong maxBytes, FaceRequester requester, IntPtr req_data, out IntPtr amanager);
  438. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  439. internal static extern void FTC_Manager_Reset(IntPtr manager);
  440. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  441. internal static extern void FTC_Manager_Done(IntPtr manager);
  442. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  443. internal static extern Error FTC_Manager_LookupFace(IntPtr manager, IntPtr face_id, out IntPtr aface);
  444. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  445. internal static extern Error FTC_Manager_LookupSize(IntPtr manager, IntPtr scaler, out IntPtr asize);
  446. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  447. internal static extern void FTC_Node_Unref(IntPtr node, IntPtr manager);
  448. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  449. internal static extern void FTC_Manager_RemoveFaceID(IntPtr manager, IntPtr face_id);
  450. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  451. internal static extern Error FTC_CMapCache_New(IntPtr manager, out IntPtr acache);
  452. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  453. internal static extern uint FTC_CMapCache_Lookup(IntPtr cache, IntPtr face_id, int cmap_index, uint char_code);
  454. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  455. internal static extern Error FTC_ImageCache_New(IntPtr manager, out IntPtr acache);
  456. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  457. internal static extern Error FTC_ImageCache_Lookup(IntPtr cache, IntPtr type, uint gindex, out IntPtr aglyph, out IntPtr anode);
  458. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  459. internal static extern Error FTC_ImageCache_LookupScaler(IntPtr cache, IntPtr scaler, LoadFlags load_flags, uint gindex, out IntPtr aglyph, out IntPtr anode);
  460. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  461. internal static extern Error FTC_SBitCache_New(IntPtr manager, out IntPtr acache);
  462. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  463. internal static extern Error FTC_SBitCache_Lookup(IntPtr cache, IntPtr type, uint gindex, out IntPtr sbit, out IntPtr anode);
  464. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  465. internal static extern Error FTC_SBitCache_LookupScaler(IntPtr cache, IntPtr scaler, LoadFlags load_flags, uint gindex, out IntPtr sbit, out IntPtr anode);
  466. #endregion
  467. #region Miscellaneous
  468. #region OpenType Validation
  469. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  470. internal static extern Error FT_OpenType_Validate(IntPtr face, OpenTypeValidationFlags validation_flags, out IntPtr BASE_table, out IntPtr GDEF_table, out IntPtr GPOS_table, out IntPtr GSUB_table, out IntPtr JSFT_table);
  471. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  472. internal static extern void FT_OpenType_Free(IntPtr face, IntPtr table);
  473. #endregion
  474. #region The TrueType Engine
  475. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  476. internal static extern EngineType FT_Get_TrueType_Engine_Type(IntPtr library);
  477. #endregion
  478. #region TrueTypeGX/AAT Validation
  479. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  480. internal static extern Error FT_TrueTypeGX_Validate(IntPtr face, TrueTypeValidationFlags validation_flags, byte[][] tables, uint tableLength);
  481. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  482. internal static extern Error FT_TrueTypeGX_Free(IntPtr face, IntPtr table);
  483. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  484. internal static extern Error FT_ClassicKern_Validate(IntPtr face, ClassicKernValidationFlags validation_flags, out IntPtr ckern_table);
  485. [DllImport(FreetypeDll, CallingConvention = CallConvention)]
  486. internal static extern Error FT_ClassicKern_Free(IntPtr face, IntPtr table);
  487. #endregion
  488. #endregion
  489. }
  490. }