freetypeh.pp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. Basic canvas definitions.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. unit freetypeh;
  13. { These are not all the availlable calls from the dll, but only those
  14. I needed for the TStringBimaps }
  15. interface
  16. const
  17. {$ifdef win32}
  18. freetypedll = 'freetype-6.dll'; // version 2.1.4
  19. {$packrecords c}
  20. {$else}
  21. // I don't know what it will be ??
  22. freetypedll = 'freetype';
  23. {$endif}
  24. type
  25. FT_Encoding = array[0..3] of char;
  26. const
  27. FT_FACE_FLAG_SCALABLE = 1 shl 0;
  28. FT_FACE_FLAG_FIXED_SIZES = 1 shl 1;
  29. FT_FACE_FLAG_FIXED_WIDTH = 1 shl 2;
  30. FT_FACE_FLAG_SFNT = 1 shl 3;
  31. FT_FACE_FLAG_HORIZONTAL = 1 shl 4;
  32. FT_FACE_FLAG_VERTICAL = 1 shl 5;
  33. FT_FACE_FLAG_KERNING = 1 shl 6;
  34. FT_FACE_FLAG_FAST_GLYPHS = 1 shl 7;
  35. FT_FACE_FLAG_MULTIPLE_MASTERS = 1 shl 8;
  36. FT_FACE_FLAG_GLYPH_NAMES = 1 shl 9;
  37. FT_FACE_FLAG_EXTERNAL_STREAM = 1 shl 10;
  38. FT_STYLE_FLAG_ITALIC = 1 shl 0;
  39. FT_STYLE_FLAG_BOLD = 1 shl 1;
  40. FT_LOAD_DEFAULT = $0000;
  41. FT_LOAD_NO_SCALE = $0001;
  42. FT_LOAD_NO_HINTING = $0002;
  43. FT_LOAD_RENDER = $0004;
  44. FT_LOAD_NO_BITMAP = $0008;
  45. FT_LOAD_VERTICAL_LAYOUT = $0010;
  46. FT_LOAD_FORCE_AUTOHINT = $0020;
  47. FT_LOAD_CROP_BITMAP = $0040;
  48. FT_LOAD_PEDANTIC = $0080;
  49. FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = $0200;
  50. FT_LOAD_NO_RECURSE = $0400;
  51. FT_LOAD_IGNORE_TRANSFORM = $0800;
  52. FT_LOAD_MONOCHROME = $1000;
  53. FT_LOAD_LINEAR_DESIGN = $2000;
  54. ft_glyph_format_none = $00000000;
  55. ft_glyph_format_composite = $636F6D70; //comp 099 111 109 112
  56. ft_glyph_format_bitmap = $62697473; //bits 098 105 116 115
  57. ft_glyph_format_outline = $6F75746C; //outl 111 117 116 108
  58. ft_glyph_format_plotter = $706C6F74; //plot 112 108 111 116
  59. FT_ENCODING_MS_SYMBOL : FT_Encoding = 'symb';
  60. FT_ENCODING_UNICODE : FT_Encoding = 'unic';
  61. FT_ENCODING_MS_SJIS : FT_Encoding = 'sjis';
  62. FT_ENCODING_MS_GB2312 : FT_Encoding = 'gb ';
  63. FT_ENCODING_MS_BIG5 : FT_Encoding = 'big5';
  64. FT_ENCODING_MS_WANSUNG : FT_Encoding = 'wans';
  65. FT_ENCODING_MS_JOHAB : FT_Encoding = 'joha';
  66. FT_ENCODING_ADOBE_STANDARD : FT_Encoding = 'ADOB';
  67. FT_ENCODING_ADOBE_EXPERT : FT_Encoding = 'ADBE';
  68. FT_ENCODING_ADOBE_CUSTOM : FT_Encoding = 'ADBC';
  69. FT_ENCODING_ADOBE_LATIN_1 : FT_Encoding = 'lat1';
  70. FT_ENCODING_OLD_LATIN_2 : FT_Encoding = 'lat2';
  71. FT_ENCODING_APPLE_ROMAN : FT_Encoding = 'armn';
  72. ft_glyph_bbox_unscaled = 0; //* return unscaled font units */
  73. ft_glyph_bbox_subpixels = 0; //* return unfitted 26.6 coordinates */
  74. ft_glyph_bbox_gridfit = 1; //* return grid-fitted 26.6 coordinates */
  75. ft_glyph_bbox_truncate = 2; //* return coordinates in integer pixels */
  76. ft_glyph_bbox_pixels = 3; //* return grid-fitted pixel coordinates */
  77. FT_KERNING_DEFAULT = 0;
  78. FT_KERNING_UNFITTED = 1;
  79. FT_KERNING_UNSCALED = 2;
  80. type
  81. FT_Bool = boolean;
  82. FT_FWord = smallint;
  83. FT_UFWord = word;
  84. FT_Char = char;
  85. FT_Byte = byte;
  86. FT_String = char;
  87. FT_Short = smallint;
  88. FT_UShort = word;
  89. FT_Int = longint;
  90. FT_UInt = longword;
  91. FT_Long = longint;
  92. FT_ULong = longword;
  93. FT_F2Dot14 = smallint;
  94. FT_F26Dot6 = longint;
  95. FT_Fixed = longint;
  96. FT_Error = longint;
  97. FT_Pointer = pointer;
  98. FT_Pos = longint;
  99. //FT_Offset = size_t;
  100. //FT_PtrDist = size_t;
  101. FT_Render_Mode = (FT_RENDER_MODE_NORMAL, FT_RENDER_MODE_LIGHT,
  102. FT_RENDER_MODE_MONO, FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V,
  103. FT_RENDER_MODE_MAX);
  104. FT_UnitVector_ = record
  105. x : FT_F2Dot14;
  106. y : FT_F2Dot14;
  107. end;
  108. FT_UnitVector = FT_UnitVector_;
  109. FT_Matrix = record
  110. xx : FT_Fixed;
  111. xy : FT_Fixed;
  112. yx : FT_Fixed;
  113. yy : FT_Fixed;
  114. end;
  115. PFT_Matrix = ^FT_Matrix;
  116. FT_Data = record
  117. pointer : ^FT_Byte;
  118. length : FT_Int;
  119. end;
  120. FT_Generic_Finalizer = procedure (AnObject:pointer);cdecl;
  121. FT_Generic = record
  122. data : pointer;
  123. finalizer : FT_Generic_Finalizer;
  124. end;
  125. FT_Glyph_Metrics = record
  126. width : FT_Pos;
  127. height : FT_Pos;
  128. horiBearingX : FT_Pos;
  129. horiBearingY : FT_Pos;
  130. horiAdvance : FT_Pos;
  131. vertBearingX : FT_Pos;
  132. vertBearingY : FT_Pos;
  133. vertAdvance : FT_Pos;
  134. end;
  135. FT_Bitmap_Size = record
  136. height : FT_Short;
  137. width : FT_Short;
  138. end;
  139. AFT_Bitmap_Size = array [0..1023] of FT_Bitmap_Size;
  140. PFT_Bitmap_Size = ^AFT_Bitmap_Size;
  141. FT_Vector = record
  142. x : FT_Pos;
  143. y : FT_Pos;
  144. end;
  145. PFT_Vector = ^FT_Vector;
  146. FT_BBox = record
  147. xMin, yMin : FT_Pos;
  148. xMax, yMax : FT_Pos;
  149. end;
  150. PFT_BBox = ^FT_BBox;
  151. FT_Bitmap = record
  152. rows : integer;
  153. width : integer;
  154. pitch : integer;
  155. buffer : pointer;
  156. num_grays : shortint;
  157. pixel_mode : char;
  158. palette_mode : char;
  159. palette : pointer;
  160. end;
  161. FT_Outline = record
  162. n_contours,
  163. n_points : smallint;
  164. points : PFT_Vector;
  165. tags : pchar;
  166. contours : ^smallint;
  167. flags : integer;
  168. end;
  169. FT_Size_Metrics = record
  170. x_ppem : FT_UShort;
  171. y_ppem : FT_UShort;
  172. x_scale : FT_Fixed;
  173. y_scale : FT_Fixed;
  174. ascender : FT_Pos;
  175. descender : FT_Pos;
  176. height : FT_Pos;
  177. max_advance : FT_Pos;
  178. end;
  179. PFT_Library = ^TFT_Library;
  180. //PPFT_Library = ^PFT_Library;
  181. PFT_Face = ^TFT_Face;
  182. //PPFT_Face = ^PFT_Face;
  183. PFT_Charmap = ^TFT_Charmap;
  184. PPFT_Charmap = ^PFT_Charmap;
  185. PFT_GlyphSlot = ^TFT_GlyphSlot;
  186. PFT_Subglyph = ^TFT_Subglyph;
  187. PFT_Size = ^TFT_Size;
  188. PFT_Glyph = ^TFT_Glyph;
  189. //PPFT_Glyph = ^PFT_Glyph;
  190. PFT_BitmapGlyph = ^TFT_BitmapGlyph;
  191. PFT_OutlineGlyph = ^TFT_OutlineGlyph;
  192. TFT_Library = record
  193. end;
  194. TFT_Charmap = record
  195. face : PFT_Face;
  196. encoding : FT_Encoding;
  197. platform_id, encoding_id : FT_UShort;
  198. end;
  199. TFT_Size = record
  200. face : PFT_Face;
  201. generic : FT_Generic;
  202. metrics : FT_Size_Metrics;
  203. //internal : FT_Size_Internal;
  204. end;
  205. TFT_Subglyph = record // TODO
  206. end;
  207. TFT_GlyphSlot = record
  208. alibrary : PFT_Library;
  209. face : PFT_Face;
  210. next : PFT_GlyphSlot;
  211. flags : FT_UInt;
  212. generic : FT_Generic;
  213. metrics : FT_Glyph_Metrics;
  214. linearHoriAdvance : FT_Fixed;
  215. linearVertAdvance : FT_Fixed;
  216. advance : FT_Vector;
  217. format : longword;
  218. bitmap : FT_Bitmap;
  219. bitmap_left : FT_Int;
  220. bitmap_top : FT_Int;
  221. outline : FT_Outline;
  222. num_subglyphs : FT_UInt;
  223. subglyphs : PFT_SubGlyph;
  224. control_data : pointer;
  225. control_len : longint;
  226. other : pointer;
  227. end;
  228. TFT_Face = record
  229. num_faces : FT_Long;
  230. face_index : FT_Long;
  231. face_flags : FT_Long;
  232. style_flags : FT_Long;
  233. num_glyphs : FT_Long;
  234. family_name : pchar;
  235. style_name : pchar;
  236. num_fixed_sizes : FT_Int;
  237. available_sizes : PFT_Bitmap_Size; // is array
  238. num_charmaps : FT_Int;
  239. charmaps : PPFT_CharMap; // is array
  240. generic : FT_Generic;
  241. bbox : FT_BBox;
  242. units_per_EM : FT_UShort;
  243. ascender : FT_Short;
  244. descender : FT_Short;
  245. height : FT_Short;
  246. max_advance_width : FT_Short;
  247. max_advance_height : FT_Short;
  248. underline_position : FT_Short;
  249. underline_thickness : FT_Short;
  250. glyph : PFT_GlyphSlot;
  251. size : PFT_Size;
  252. charmap : PFT_CharMap;
  253. end;
  254. TFT_Glyph = record
  255. FTlibrary : PFT_Library;
  256. clazz : pointer;
  257. aFormat : longword;
  258. advance : FT_Vector;
  259. end;
  260. TFT_BitmapGlyph = record
  261. root : TFT_Glyph;
  262. left, top : FT_Int;
  263. bitmap : FT_Bitmap;
  264. end;
  265. TFT_OutlineGlyph = record
  266. root : TFT_Glyph;
  267. outline : FT_Outline;
  268. end;
  269. function FT_Init_FreeType(var alibrary:PFT_Library) : integer; cdecl; external freetypedll name 'FT_Init_FreeType';
  270. function FT_Done_FreeType(alibrary:PFT_Library) : integer; cdecl; external freetypedll name 'FT_Done_FreeType';
  271. procedure FT_Library_Version(alibrary:PFT_Library; var amajor,aminor,apatch:integer); cdecl; external freetypedll name 'FT_Library_Version';
  272. function FT_New_Face(alibrary:PFT_Library; filepathname:pchar; face_index:integer; var aface:PFT_Face):integer; cdecl; external freetypedll name 'FT_New_Face';
  273. function FT_Set_Pixel_Sizes(face:PFT_Face; pixel_width,pixel_height:FT_UInt) : integer; cdecl; external freetypedll name 'FT_Set_Pixel_Sizes';
  274. function FT_Set_Char_Size(face:PFT_Face; char_width,char_height:FT_F26dot6;horz_res, vert_res:FT_UInt) : integer; cdecl; external freetypedll name 'FT_Set_Char_Size';
  275. function FT_Get_Char_Index(face:PFT_Face; charcode:FT_ULong):FT_UInt; cdecl; external freetypedll name 'FT_Get_Char_Index';
  276. function FT_Load_Glyph(face:PFT_Face; glyph_index:FT_UInt ;load_flags:longint):integer; cdecl; external freetypedll name 'FT_Load_Glyph';
  277. function FT_Get_Kerning(face:PFT_Face; left_glyph, right_glyph, kern_mode:FT_UInt; var akerning:FT_Vector) : integer; cdecl; external freetypedll name 'FT_Get_Kerning';
  278. function FT_Get_Glyph(slot:PFT_GlyphSlot; var aglyph:PFT_Glyph) : integer; cdecl; external freetypedll name 'FT_Get_Glyph';
  279. function FT_Glyph_Transform(glyph:PFT_Glyph; matrix:PFT_Matrix; delta:PFT_Vector) : integer; cdecl; external freetypedll name 'FT_Glyph_Transform';
  280. function FT_Glyph_Copy(source:PFT_Glyph; var target:PFT_Glyph): integer; cdecl; external freetypedll name 'FT_Glyph_Copy';
  281. procedure FT_Glyph_Get_CBox(glyph:PFT_Glyph;bbox_mode:FT_UInt;var acbox:FT_BBox); cdecl; external freetypedll name 'FT_Glyph_Get_CBox';
  282. function FT_Glyph_To_Bitmap(var the_glyph:PFT_Glyph;render_mode:FT_Render_Mode;origin:PFT_Vector; destroy:FT_Bool):integer; cdecl; external freetypedll name 'FT_Glyph_To_Bitmap';
  283. procedure FT_Done_Glyph (glyph:PFT_Glyph); cdecl; external freetypedll name 'FT_Done_Glyph';
  284. implementation
  285. end.