Debian Codegraph @

src/fonts/castleinternalfreetypeh.pas

raw
1 {
2 This file is based on the Free Pascal run time library,
3 with various adjustments for Castle Game Engine.
4
5 Copyright by the Free Pascal development team and Michalis Kamburelis.
6
7 License:
8 This file is adapted from the FPC RTL source code, as such
9 the license and copyright information of FPC RTL applies here.
10 That said, the license of FPC RTL happens to be *exactly*
11 the same as used by the "Castle Game Engine": LGPL (version 2.1)
12 with "static linking exception" (with exactly the same wording
13 of the "static linking exception").
14 See the file COPYING.txt, included in this distribution, for details about
15 the copyright of "Castle Game Engine".
16 See http://www.freepascal.org/faq.var#general-license about the copyright
17 of FPC RTL.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22
23 ----------------------------------------------------------------------------
24 }
25
26 { FreeType library routines.
27
28 Based on FPC RTL, with some modifications:
29
30 - Load dynamic library using TDynLib, and merely expose
31 FreeTypeLibraryInitialized = false when library not found.
32 TFontManager.Create will raise an exception if freetype library is not
33 installed, and it can be handled gracefully.
34
35 - Honor ALLOW_DLOPEN_FROM_UNIT_INITIALIZATION symbol.
36
37 - Optionally load staticaly, if CASTLE_FREETYPE_STATIC is defined.
38 It is automatically defined on iOS now
39 (matching Castle Game Engine "freetype" service on iOS,
40 that links freetype statically into the main library).
41
42 - Define some things we need (or needed in the past) in CGE:
43 FT_New_Memory_Face, FT_Open_Face and friends. }
44 unit CastleInternalFreeTypeH;
45
46 {$i castleconf.inc}
47
48 {$ifdef CASTLE_IOS}
49 {$define CASTLE_FREETYPE_STATIC}
50 {$endif}
51
52 interface
53
54 uses CTypes;
55
56 {$ifdef FPC}{$packrecords c}{$endif}
57
58 type
59 FT_Encoding = array[0..3] of Ansichar;
60
61 const
62 FT_FACE_FLAG_SCALABLE = 1 shl 0;
63 FT_FACE_FLAG_FIXED_SIZES = 1 shl 1;
64 FT_FACE_FLAG_FIXED_WIDTH = 1 shl 2;
65 FT_FACE_FLAG_SFNT = 1 shl 3;
66 FT_FACE_FLAG_HORIZONTAL = 1 shl 4;
67 FT_FACE_FLAG_VERTICAL = 1 shl 5;
68 FT_FACE_FLAG_KERNING = 1 shl 6;
69 FT_FACE_FLAG_FAST_GLYPHS = 1 shl 7;
70 FT_FACE_FLAG_MULTIPLE_MASTERS = 1 shl 8;
71 FT_FACE_FLAG_GLYPH_NAMES = 1 shl 9;
72 FT_FACE_FLAG_EXTERNAL_STREAM = 1 shl 10;
73
74 FT_STYLE_FLAG_ITALIC = 1 shl 0;
75 FT_STYLE_FLAG_BOLD = 1 shl 1;
76
77 FT_LOAD_DEFAULT = $0000;
78 FT_LOAD_NO_SCALE = $0001;
79 FT_LOAD_NO_HINTING = $0002;
80 FT_LOAD_RENDER = $0004;
81 FT_LOAD_NO_BITMAP = $0008;
82 FT_LOAD_VERTICAL_LAYOUT = $0010;
83 FT_LOAD_FORCE_AUTOHINT = $0020;
84 FT_LOAD_CROP_BITMAP = $0040;
85 FT_LOAD_PEDANTIC = $0080;
86 FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = $0200;
87 FT_LOAD_NO_RECURSE = $0400;
88 FT_LOAD_IGNORE_TRANSFORM = $0800;
89 FT_LOAD_MONOCHROME = $1000;
90 FT_LOAD_LINEAR_DESIGN = $2000;
91
92 ft_glyph_format_none = $00000000;
93 ft_glyph_format_composite = $636F6D70; //comp 099 111 109 112
94 ft_glyph_format_bitmap = $62697473; //bits 098 105 116 115
95 ft_glyph_format_outline = $6F75746C; //outl 111 117 116 108
96 ft_glyph_format_plotter = $706C6F74; //plot 112 108 111 116
97
98 FT_ENCODING_MS_SYMBOL : FT_Encoding = 'symb';
99 FT_ENCODING_UNICODE : FT_Encoding = 'unic';
100 FT_ENCODING_MS_SJIS : FT_Encoding = 'sjis';
101 FT_ENCODING_MS_GB2312 : FT_Encoding = 'gb ';
102 FT_ENCODING_MS_BIG5 : FT_Encoding = 'big5';
103 FT_ENCODING_MS_WANSUNG : FT_Encoding = 'wans';
104 FT_ENCODING_MS_JOHAB : FT_Encoding = 'joha';
105 FT_ENCODING_ADOBE_STANDARD : FT_Encoding = 'ADOB';
106 FT_ENCODING_ADOBE_EXPERT : FT_Encoding = 'ADBE';
107 FT_ENCODING_ADOBE_CUSTOM : FT_Encoding = 'ADBC';
108 FT_ENCODING_ADOBE_LATIN_1 : FT_Encoding = 'lat1';
109 FT_ENCODING_OLD_LATIN_2 : FT_Encoding = 'lat2';
110 FT_ENCODING_APPLE_ROMAN : FT_Encoding = 'armn';
111
112 ft_glyph_bbox_unscaled = 0; //* return unscaled font units */
113 ft_glyph_bbox_subpixels = 0; //* return unfitted 26.6 coordinates */
114 ft_glyph_bbox_gridfit = 1; //* return grid-fitted 26.6 coordinates */
115 ft_glyph_bbox_truncate = 2; //* return coordinates in integer pixels */
116 ft_glyph_bbox_pixels = 3; //* return grid-fitted pixel coordinates */
117
118 FT_KERNING_DEFAULT = 0;
119 FT_KERNING_UNFITTED = 1;
120 FT_KERNING_UNSCALED = 2;
121
122 {**************************************************************************
123 *
124 * @enum:
125 * FT_OPEN_XXX
126 *
127 * @description:
128 * A list of bit field constants used within the `flags` field of the
129 * @FT_Open_Args structure.
130 *
131 * @values:
132 * FT_OPEN_MEMORY ::
133 * This is a memory-based stream.
134 *
135 * FT_OPEN_STREAM ::
136 * Copy the stream from the `stream` field.
137 *
138 * FT_OPEN_PATHNAME ::
139 * Create a new input stream from a C~path name.
140 *
141 * FT_OPEN_DRIVER ::
142 * Use the `driver` field.
143 *
144 * FT_OPEN_PARAMS ::
145 * Use the `num_params` and `params` fields.
146 *
147 * @note:
148 * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
149 * are mutually exclusive.
150 *}
151 FT_OPEN_MEMORY = $1;
152 FT_OPEN_STREAM = $2;
153 FT_OPEN_PATHNAME = $4;
154 FT_OPEN_DRIVER = $8;
155 FT_OPEN_PARAMS = $10;
156
157 type
158 FT_Bool = boolean;
159 FT_FWord = smallint;
160 FT_UFWord = word;
161 FT_Char = AnsiChar;
162 FT_Byte = byte;
163 FT_String = Ansichar;
164 PFT_String = PAnsiChar;
165 FT_Short = smallint;
166 FT_UShort = word;
167 FT_Int = CInt32;
168 FT_UInt = CUInt32;
169 {$if defined(cpu64) and not(defined(win64) and defined(cpux86_64))}
170 FT_Long = int64;
171 FT_ULong = {$ifdef FPC} qword {$else} UInt64 {$endif};
172 FT_Pos = int64;
173 {$ELSE}
174 FT_Long = CInt32;
175 FT_ULong = CUInt32;
176 FT_Pos = CInt32;
177 {$ENDIF}
178 FT_F2Dot14 = smallint;
179 FT_F26Dot6 = CInt32;
180 FT_Fixed = FT_Long;
181 FT_Error = CInt32;
182 FT_Pointer = pointer;
183 //FT_Offset = size_t;
184 //FT_PtrDist = size_t;
185
186 {$ifndef FPC}{$MinEnumSize 4}{$endif}
187 FT_Render_Mode = (FT_RENDER_MODE_NORMAL = 0, FT_RENDER_MODE_LIGHT,
188 FT_RENDER_MODE_MONO, FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V,
189 FT_RENDER_MODE_MAX);
190 {$ifndef FPC}{$MinEnumSize 1}{$endif}
191
192 FT_UnitVector_ = record
193 x : FT_F2Dot14;
194 y : FT_F2Dot14;
195 end;
196 FT_UnitVector = FT_UnitVector_;
197
198 FT_Matrix = record
199 xx : FT_Fixed;
200 xy : FT_Fixed;
201 yx : FT_Fixed;
202 yy : FT_Fixed;
203 end;
204 PFT_Matrix = ^FT_Matrix;
205
206 FT_Data = record
207 pointer : ^FT_Byte;
208 length : FT_Int;
209 end;
210
211 FT_Generic_Finalizer = procedure (AnObject:pointer);cdecl;
212
213 FT_Generic = record
214 data : pointer;
215 finalizer : FT_Generic_Finalizer;
216 end;
217
218 FT_Glyph_Metrics = record
219 width : FT_Pos;
220 height : FT_Pos;
221 horiBearingX : FT_Pos;
222 horiBearingY : FT_Pos;
223 horiAdvance : FT_Pos;
224 vertBearingX : FT_Pos;
225 vertBearingY : FT_Pos;
226 vertAdvance : FT_Pos;
227 end;
228
229 FT_Bitmap_Size = record
230 height : FT_Short;
231 width : FT_Short;
232 end;
233 AFT_Bitmap_Size = array [0..1023] of FT_Bitmap_Size;
234 PFT_Bitmap_Size = ^AFT_Bitmap_Size;
235
236 FT_Vector = record
237 x : FT_Pos;
238 y : FT_Pos;
239 end;
240 PFT_Vector = ^FT_Vector;
241
242 FT_BBox = record
243 xMin, yMin : FT_Pos;
244 xMax, yMax : FT_Pos;
245 end;
246 PFT_BBox = ^FT_BBox;
247
248 FT_Bitmap = record
249 rows : integer;
250 width : integer;
251 pitch : integer;
252 buffer : pointer;
253 num_grays : shortint;
254 pixel_mode : Ansichar;
255 palette_mode : Ansichar;
256 palette : pointer;
257 end;
258
259 FT_Outline = record
260 n_contours,
261 n_points : smallint;
262 points : PFT_Vector;
263 tags : PAnsiChar;
264 contours : ^smallint;
265 flags : integer;
266 end;
267 PFT_Outline = ^FT_Outline;
268
269 FT_Outline_MoveToFunc = function(const to_: PFT_Vector; user: Pointer): integer; cdecl;
270 FT_Outline_LineToFunc = function(const to_: PFT_Vector; user: Pointer): integer; cdecl;
271 FT_Outline_ConicToFunc = function(const control, to_: PFT_Vector; user: Pointer): integer; cdecl;
272 FT_Outline_CubicToFunc = function(const control1, control2, to_: PFT_Vector; user: Pointer): integer; cdecl;
273
274 FT_Outline_Funcs = record
275 move_to: FT_Outline_MoveToFunc;
276 line_to: FT_Outline_LineToFunc;
277 conic_to: FT_Outline_ConicToFunc;
278 cubic_to: FT_Outline_CubicToFunc;
279 shift: integer;
280 delta: FT_Pos;
281 end;
282 PFT_Outline_Funcs = ^FT_Outline_Funcs;
283
284 FT_Size_Metrics = record
285 x_ppem : FT_UShort;
286 y_ppem : FT_UShort;
287 x_scale : FT_Fixed;
288 y_scale : FT_Fixed;
289 ascender : FT_Pos;
290 descender : FT_Pos;
291 height : FT_Pos;
292 max_advance : FT_Pos;
293 end;
294
295
296 PFT_Library = ^TFT_Library;
297 //PPFT_Library = ^PFT_Library;
298 PFT_Face = ^TFT_Face;
299 //PPFT_Face = ^PFT_Face;
300 PFT_Charmap = ^TFT_Charmap;
301 PPFT_Charmap = ^PFT_Charmap;
302 PFT_GlyphSlot = ^TFT_GlyphSlot;
303 PFT_Subglyph = ^TFT_Subglyph;
304 PFT_Size = ^TFT_Size;
305
306 PFT_Glyph = ^TFT_Glyph;
307 //PPFT_Glyph = ^PFT_Glyph;
308 PFT_BitmapGlyph = ^TFT_BitmapGlyph;
309 PFT_OutlineGlyph = ^TFT_OutlineGlyph;
310
311
312 TFT_Library = record
313 end;
314
315 TFT_Charmap = record
316 face : PFT_Face;
317 encoding : FT_Encoding;
318 platform_id, encoding_id : FT_UShort;
319 end;
320
321 TFT_Size = record
322 face : PFT_Face;
323 generic : FT_Generic;
324 metrics : FT_Size_Metrics;
325 //internal : FT_Size_Internal;
326 end;
327
328 TFT_Subglyph = record // TODO
329 end;
330
331 TFT_GlyphSlot = record
332 alibrary : PFT_Library;
333 face : PFT_Face;
334 next : PFT_GlyphSlot;
335 flags : FT_UInt;
336 generic : FT_Generic;
337 metrics : FT_Glyph_Metrics;
338 linearHoriAdvance : FT_Fixed;
339 linearVertAdvance : FT_Fixed;
340 advance : FT_Vector;
341 format : CUInt32;
342 bitmap : FT_Bitmap;
343 bitmap_left : FT_Int;
344 bitmap_top : FT_Int;
345 outline : FT_Outline;
346 num_subglyphs : FT_UInt;
347 subglyphs : PFT_SubGlyph;
348 control_data : pointer;
349 control_len : CInt32;
350 other : pointer;
351 end;
352
353 TFT_Face = record
354 num_faces : FT_Long;
355 face_index : FT_Long;
356 face_flags : FT_Long;
357 style_flags : FT_Long;
358 num_glyphs : FT_Long;
359 family_name : PAnsiChar;
360 style_name : PAnsiChar;
361 num_fixed_sizes : FT_Int;
362 available_sizes : PFT_Bitmap_Size; // is array
363 num_charmaps : FT_Int;
364 charmaps : PPFT_CharMap; // is array
365 generic : FT_Generic;
366 bbox : FT_BBox;
367 units_per_EM : FT_UShort;
368 ascender : FT_Short;
369 descender : FT_Short;
370 height : FT_Short;
371 max_advance_width : FT_Short;
372 max_advance_height : FT_Short;
373 underline_position : FT_Short;
374 underline_thickness : FT_Short;
375 glyph : PFT_GlyphSlot;
376 size : PFT_Size;
377 charmap : PFT_CharMap;
378 end;
379
380 TFT_Glyph = record
381 FTlibrary : PFT_Library;
382 clazz : pointer;
383 aFormat : CUInt32;
384 advance : FT_Vector;
385 end;
386
387 TFT_BitmapGlyph = record
388 root : TFT_Glyph;
389 left, top : FT_Int;
390 bitmap : FT_Bitmap;
391 end;
392
393 TFT_OutlineGlyph = record
394 root : TFT_Glyph;
395 outline : FT_Outline;
396 end;
397
398 { Structure that describes a custom stream, used e.g. with FT_Open_Face .
399 See https://freetype.org/freetype2/docs/reference/ft2-base_interface.html#ft_open_args }
400 TFT_Open_Args = record
401 flags: FT_UInt;
402 memory_base: ^FT_Byte;
403 memory_size: FT_Long;
404 pathname: PFT_String;
405 stream: Pointer; // FT_Stream; TODO: Not translated yet
406 driver: Pointer; // FT_Module; TODO: Not translated yet
407 num_params: FT_Int;
408 params: Pointer; // FT_Parameter*; TODO: Not translated yet
409 end;
410 PFT_Open_Args = ^TFT_Open_Args;
411
412 {$ifdef CASTLE_FREETYPE_STATIC}
413
414 //Base Interface
415 function FT_Done_Face(face: PFT_Face): integer; cdecl; external;
416 function FT_Done_FreeType(alibrary: PFT_Library): integer; cdecl; external;
417 function FT_Get_Char_Index(face: PFT_Face; charcode: FT_ULong): FT_UInt; cdecl; external;
418 function FT_Get_Kerning(face: PFT_Face; left_glyph, right_glyph, kern_mode: FT_UInt; out akerning: FT_Vector): integer; cdecl; external;
419 function FT_Init_FreeType(var alibrary: PFT_Library): integer; cdecl; external;
420 function FT_Load_Char(face: PFT_Face; charcode: FT_ULong; load_flags: CInt32): integer; cdecl; external;
421 function FT_Load_Glyph(face: PFT_Face; glyph_index: FT_UInt; load_flags: CInt32): integer; cdecl; external;
422 { TODO:
423 Is this right?
424 - face_index should be FT_Long (makes different on 64-bit non-Windows)? }
425 function FT_New_Face(alibrary: PFT_Library; filepathname: PAnsiChar; face_index: integer; var aface: PFT_Face): integer; cdecl; external;
426 function FT_Open_Face(alibrary: PFT_Library; Args: PFT_Open_Args; face_index: FT_Long; var aface: PFT_Face): integer; cdecl; external;
427 function FT_New_Memory_Face(alibrary: PFT_Library; file_base: Pointer; file_size: FT_Long; face_index: FT_Long; var aface: PFT_Face): integer; cdecl; external;
428 function FT_Set_Char_Size(face: PFT_Face; char_width, char_height: FT_F26dot6; horz_res, vert_res: FT_UInt): integer; cdecl; external;
429 function FT_Set_Pixel_Sizes(face: PFT_Face; pixel_width, pixel_height: FT_UInt): integer; cdecl; external;
430 procedure FT_Set_Transform(face: PFT_Face; matrix: PFT_Matrix; delta: PFT_Vector); cdecl; external;
431
432 //Outline Processing
433 function FT_Outline_Decompose(outline: PFT_Outline; const func_interface: PFT_Outline_Funcs; user: Pointer): integer; cdecl; external;
434
435 //FreeType Version
436 procedure FT_Library_Version(alibrary: PFT_Library; var amajor, aminor, apatch: integer); cdecl; external;
437
438 //Glyph Management
439 function FT_Get_Glyph(slot: PFT_GlyphSlot; out aglyph: PFT_Glyph): integer; cdecl; external;
440 function FT_Glyph_Copy(Source: PFT_Glyph; out target: PFT_Glyph): integer; cdecl; external;
441 function FT_Glyph_To_Bitmap(var the_glyph: PFT_Glyph; render_mode: FT_Render_Mode; origin: PFT_Vector; Destroy: FT_Bool): integer; cdecl; external;
442 function FT_Glyph_Transform(glyph: PFT_Glyph; matrix: PFT_Matrix; delta: PFT_Vector): integer; cdecl; external;
443 procedure FT_Done_Glyph(glyph: PFT_Glyph); cdecl; external;
444 procedure FT_Glyph_Get_CBox(glyph: PFT_Glyph; bbox_mode: FT_UInt; var acbox: FT_BBox); cdecl; external;
445
446 {$else}
447
448 var
449 //Base Interface
450 FT_Done_Face: function(face: PFT_Face): integer; cdecl;
451 FT_Done_FreeType: function(alibrary: PFT_Library): integer; cdecl;
452 FT_Get_Char_Index: function(face: PFT_Face; charcode: FT_ULong): FT_UInt; cdecl;
453 FT_Get_Kerning: function(face: PFT_Face; left_glyph, right_glyph, kern_mode: FT_UInt; out akerning: FT_Vector): integer; cdecl;
454 FT_Init_FreeType: function(var alibrary: PFT_Library): integer; cdecl;
455 FT_Load_Char: function(face: PFT_Face; charcode: FT_ULong; load_flags: CInt32): integer; cdecl;
456 FT_Load_Glyph: function(face: PFT_Face; glyph_index: FT_UInt; load_flags: CInt32): integer; cdecl;
457 FT_New_Face: function(alibrary: PFT_Library; filepathname: PAnsiChar; face_index: integer; var aface: PFT_Face): integer; cdecl;
458 FT_Open_Face: function(alibrary: PFT_Library; Args: PFT_Open_Args; face_index: FT_Long; var aface: PFT_Face): integer; cdecl;
459 FT_New_Memory_Face: function(alibrary: PFT_Library; file_base: Pointer; file_size: FT_Long; face_index: FT_Long; var aface: PFT_Face): integer; cdecl;
460 FT_Set_Char_Size: function(face: PFT_Face; char_width, char_height: FT_F26dot6; horz_res, vert_res: FT_UInt): integer; cdecl;
461 FT_Set_Pixel_Sizes: function(face: PFT_Face; pixel_width, pixel_height: FT_UInt): integer; cdecl;
462 FT_Set_Transform: procedure(face: PFT_Face; matrix: PFT_Matrix; delta: PFT_Vector); cdecl;
463
464 //Outline Processing
465 FT_Outline_Decompose: function(outline: PFT_Outline; const func_interface: PFT_Outline_Funcs; user: Pointer): integer; cdecl;
466
467 //FreeType Version
468 FT_Library_Version: procedure(alibrary: PFT_Library; var amajor, aminor, apatch: integer); cdecl;
469
470 //Glyph Management
471 FT_Get_Glyph: function(slot: PFT_GlyphSlot; out aglyph: PFT_Glyph): integer; cdecl;
472 FT_Glyph_Copy: function(Source: PFT_Glyph; out target: PFT_Glyph): integer; cdecl;
473 FT_Glyph_To_Bitmap: function(var the_glyph: PFT_Glyph; render_mode: FT_Render_Mode; origin: PFT_Vector; Destroy: FT_Bool): integer; cdecl;
474 FT_Glyph_Transform: function(glyph: PFT_Glyph; matrix: PFT_Matrix; delta: PFT_Vector): integer; cdecl;
475 FT_Done_Glyph: procedure(glyph: PFT_Glyph); cdecl;
476 FT_Glyph_Get_CBox: procedure(glyph: PFT_Glyph; bbox_mode: FT_UInt; var acbox: FT_BBox); cdecl;
477 {$endif CASTLE_FREETYPE_STATIC}
478
479 //Base Interface - macros
480 function FT_IS_SCALABLE(face: PFT_Face): boolean;
481
482 procedure LoadFreeTypeLibrary;
483
484 { Did we found FreeType library and loaded it's symbols.
485 When this is @false, do not use any functions from this unit, they are @nil. }
486 function FreeTypeLibraryInitialized: boolean;
487
488 implementation
489
490 uses SysUtils, CastleDynLib;
491
492 { FreeType macros ------------------------------------------------------------ }
493
494 function FT_IS_SCALABLE(face: PFT_Face): boolean;
495 begin
496 Result := (face^.face_flags and FT_FACE_FLAG_SCALABLE) = 1;
497 end;
498
499 { Loading FreeType library --------------------------------------------------- }
500
501 {$ifdef CASTLE_FREETYPE_STATIC}
502
503 procedure LoadFreeTypeLibrary;
504 begin
505 end;
506
507 function FreeTypeLibraryInitialized: boolean;
508 begin
509 Result := true;
510 end;
511
512 end.
513 {$else CASTLE_FREETYPE_STATIC}
514
515 var
516 FreeTypeLibrary: TDynLib;
517
518 function FreeTypeLibraryInitialized: boolean;
519 begin
520 Result := FreeTypeLibrary <> nil;
521 end;
522
523 procedure LoadFreeTypeLibrary;
524 begin
525 // Windows
526 {$ifdef MSWINDOWS}
527 {$define ft_found_platform}
528 FreeTypeLibrary := TDynLib.Load('freetype.dll', false);
529 if FreeTypeLibrary = nil then
530 FreeTypeLibrary := TDynLib.Load('freetype-6.dll', false);
531 {$endif}
532
533 // macOS
534 {$ifdef DARWIN}
535 {$define ft_found_platform}
536 FreeTypeLibrary := TDynLib.Load('libfreetype.dylib', false);
537 if FreeTypeLibrary = nil then
538 FreeTypeLibrary := TDynLib.Load('libfreetype.6.dylib', false);
539 // try in typical location
540 if FreeTypeLibrary = nil then
541 FreeTypeLibrary := TDynLib.Load('/usr/X11/lib/libfreetype.dylib', false);
542 if FreeTypeLibrary = nil then
543 FreeTypeLibrary := TDynLib.Load('/usr/X11/lib/libfreetype.dylib.6', false);
544 {$endif}
545
546 // UNIX
547 {$if defined(UNIX) and not defined(darwin)}
548 {$define ft_found_platform}
549 FreeTypeLibrary := TDynLib.Load('libfreetype.so', false);
550 if FreeTypeLibrary = nil then
551 FreeTypeLibrary := TDynLib.Load('libfreetype.so.6', false);
552 {$endif}
553
554 if FreeTypeLibrary <> nil then
555 begin
556 Pointer({$ifndef FPC}@{$endif} FT_Done_Face) := FreeTypeLibrary.Symbol('FT_Done_Face');
557 Pointer({$ifndef FPC}@{$endif} FT_Done_FreeType) := FreeTypeLibrary.Symbol('FT_Done_FreeType');
558 Pointer({$ifndef FPC}@{$endif} FT_Get_Char_Index) := FreeTypeLibrary.Symbol('FT_Get_Char_Index');
559 Pointer({$ifndef FPC}@{$endif} FT_Get_Kerning) := FreeTypeLibrary.Symbol('FT_Get_Kerning');
560 Pointer({$ifndef FPC}@{$endif} FT_Init_FreeType) := FreeTypeLibrary.Symbol('FT_Init_FreeType');
561 Pointer({$ifndef FPC}@{$endif} FT_Load_Char) := FreeTypeLibrary.Symbol('FT_Load_Char');
562 Pointer({$ifndef FPC}@{$endif} FT_Load_Glyph) := FreeTypeLibrary.Symbol('FT_Load_Glyph');
563 Pointer({$ifndef FPC}@{$endif} FT_New_Face) := FreeTypeLibrary.Symbol('FT_New_Face');
564 Pointer({$ifndef FPC}@{$endif} FT_Open_Face) := FreeTypeLibrary.Symbol('FT_Open_Face');
565 Pointer({$ifndef FPC}@{$endif} FT_New_Memory_Face) := FreeTypeLibrary.Symbol('FT_New_Memory_Face');
566 Pointer({$ifndef FPC}@{$endif} FT_Set_Char_Size) := FreeTypeLibrary.Symbol('FT_Set_Char_Size');
567 Pointer({$ifndef FPC}@{$endif} FT_Set_Pixel_Sizes) := FreeTypeLibrary.Symbol('FT_Set_Pixel_Sizes');
568 Pointer({$ifndef FPC}@{$endif} FT_Set_Transform) := FreeTypeLibrary.Symbol('FT_Set_Transform');
569 Pointer({$ifndef FPC}@{$endif} FT_Outline_Decompose) := FreeTypeLibrary.Symbol('FT_Outline_Decompose');
570 Pointer({$ifndef FPC}@{$endif} FT_Library_Version) := FreeTypeLibrary.Symbol('FT_Library_Version');
571 Pointer({$ifndef FPC}@{$endif} FT_Get_Glyph) := FreeTypeLibrary.Symbol('FT_Get_Glyph');
572 Pointer({$ifndef FPC}@{$endif} FT_Glyph_Copy) := FreeTypeLibrary.Symbol('FT_Glyph_Copy');
573 Pointer({$ifndef FPC}@{$endif} FT_Glyph_To_Bitmap) := FreeTypeLibrary.Symbol('FT_Glyph_To_Bitmap');
574 Pointer({$ifndef FPC}@{$endif} FT_Glyph_Transform) := FreeTypeLibrary.Symbol('FT_Glyph_Transform');
575 Pointer({$ifndef FPC}@{$endif} FT_Done_Glyph) := FreeTypeLibrary.Symbol('FT_Done_Glyph');
576 Pointer({$ifndef FPC}@{$endif} FT_Glyph_Get_CBox) := FreeTypeLibrary.Symbol('FT_Glyph_Get_CBox');
577 end;
578 end;
579
580 initialization
581 {$ifdef ALLOW_DLOPEN_FROM_UNIT_INITIALIZATION}
582 LoadFreeTypeLibrary;
583 {$endif}
584 finalization
585 FreeAndNil(FreeTypeLibrary);
586 end.
587
588 {$endif CASTLE_FREETYPE_STATIC}