-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuFreeType.pas
More file actions
1730 lines (1457 loc) · 60.3 KB
/
uFreeType.pas
File metadata and controls
1730 lines (1457 loc) · 60.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Translation of the FreeType interface into Delphi Language/Object Pascal
// Based on version 2.11.0
// This header file is Copyright (C) 2021 by Benjamin Desef
// You may use it under the same conditions as FreeType itself, i.e., you may choose to
// either apply the FreeType License or the GNU General Public License version 2.
// The original FreeType copyright header is
// Copyright (C) 1996-2021 by
// David Turner, Robert Wilhelm, and Werner Lemberg.
{$Z1}
Unit uFreeType;
Interface
{$IFDEF FPC}
{$MODE Delphi}
{$MESSAGE FATAL 'Replace every instance of "[Ref] Const" in this file by "Constref", then disable this error.'}
{$ENDIF}
Uses SysUtils{$IFNDEF VER230}, AnsiStrings{$ENDIF};
Const
FreeTypeDLL = 'freetype.dll';
Type
EFreeType = Class(Exception)
End;
{$REGION 'fttypes.h'}
// Basic Data Types
TFTTag = Type Cardinal;
TFTF2Dot14 = Type SmallInt;
TFTF26Dot6 = Type LongInt;
TFTFixed = Type LongInt;
TFTError = Integer;
TFTErrorHelper = Record Helper For TFTError
Public
Function Base: Byte; Inline;
Function Module: Word; Inline;
Function Equals(Const AError: TFTError): Boolean; Inline;
Function Inequals(Const AError: TFTError): Boolean; Inline;
End;
TFTUnitVector = Record
X, Y: TFTF2Dot14;
End;
PFTMatrix = ^TFTMatrix;
TFTMatrix = Record
XX, XY, YX, YY: TFTFixed;
End;
TFTData = Record
Pointer: PByte;
Length: Integer;
End;
TFTGeneric = Record
Data: Pointer;
Finalizer: Procedure(AObject: Pointer); Cdecl;
End;
// List management
PFTListNode = ^TFTListNode;
TFTListNode = Record
Prev, Next: PFTListNode;
Data: Pointer;
End;
PFTList = ^TFTList;
TFTList = Record
Head, Tail: PFTListNode;
Function IsEmpty: Boolean; Inline;
End;
{$ENDREGION}
{$REGION 'ftsystem.h'}
// System interface. How FreeType manages memory and i/o
// Memory management
PFTMemory = ^TFTMemory;
TFTMemory = Record
User: Pointer;
AllocFunc: Function([Ref] Const AMemory: TFTMemory; Const ASize: LongInt): Pointer; Cdecl;
FreeFunc: Procedure([Ref] Const AMemory: TFTMemory; Const ABlock: Pointer); Cdecl;
ReallocFunc: Function([Ref] Const AMemory: TFTMemory; Const ACurSize, ANewSize: LongInt; Const ABlock: Pointer): Pointer; Cdecl;
Function Alloc(Const ASize: LongInt): Pointer; Inline;
Procedure Free(Const ABlock: Pointer); Inline;
Function Realloc(Const ACurSize, ANewSize: LongInt; Const ABlock: Pointer): Pointer; Inline;
End;
// I/O management
PFTStream = ^TFTStream;
TFTStream = Record
Strict Private
Type
TFTStreamDesc = Record
Case Boolean Of
False:
(Value: LongInt);
True:
(Pointer: Pointer);
End;
Public
Base: PByte;
Size, Pos: LongWord;
Strict Private
FDescriptor: TFTStreamDesc;
Public
Property DescriptorInt: LongInt Read FDescriptor.Value Write FDescriptor.Value;
Property DescriptorPointer: Pointer Read FDescriptor.Pointer Write FDescriptor.Pointer;
Public
Pathname: PAnsiChar;
ReadFunc: Function(Var Stream: TFTStream; Const AOffset: LongWord; Var ABuffer; Const ACount: LongWord): LongWord; Cdecl;
CloseFunc: Procedure(Var Stream: TFTStream); Cdecl;
Strict Private
{$HINTS OFF}
Memory: PFTMemory; // internal, do not use
Cursor, Limit: PByte;
{$HINTS ON}
Public
Function Read(Const AOffset: LongWord; Var ABuffer; Const ACount: LongWord): LongWord; Inline;
Procedure Close; Inline;
End;
{$ENDREGION}
{$REGION 'ftcolor.h'}
// Glyph Color Management
PFTColor = ^TFTColor;
TFTColor = Record
Public
Blue, Green, Red, Alpha: Byte;
Constructor Mix(Const ABlue, AGreen, ARed, AAlpha: Byte);
End;
TFTPaletteFlag = (ftPaletteForLightBackground, ftPaletteForDarkBackground);
TFTPaletteFlags = Set Of ftPaletteForLightBackground .. TFTPaletteFlag($F);
TFTPaletteData = Record
NumPalettes: Word;
PaletteNameIds: Word;
PaletteFlags: ^TFTPaletteFlags;
NumPaletteEntries: Word;
PaletteEntryNameIds: PWord;
End;
// Layer management
TFTLayerIterator = Record
NumLayers, Layer: Cardinal;
P: PByte;
End;
{$ENDREGION}
{$REGION 'ftimage.h'}
// Basic types
TFTPos = Type LongInt;
PFTVector = ^TFTVector;
TFTVector = Record
X, Y: TFTPos;
End;
TFTBBox = Record
XMin, YMin, XMax, YMax: TFTPos;
End;
TFTPixelMode = (ftpmNone, ftpmMono, ftpmGray, ftpmGray2, ftpmGray4, ftpmLcd, ftpmLcdV, ftpmBgra);
PFTBitmap = ^TFTBitmap;
TFTBitmap = Record
Public
Rows, Width: Cardinal;
Pitch: Integer;
Buffer: PByte;
NumGrays: Word;
PixelMode: TFTPixelMode;
Strict Private
{$HINTS OFF}
FPaletteMode: Byte;
FPalette: Pointer;
{$HINTS ON}
Function GetScanLine(Const ALine: Cardinal): PByte; Inline;
Public
Procedure Init; Inline;
Procedure Copy(Var Target: TFTBitmap); Inline;
Procedure Embolden(Const AXStrength, AYStrength: TFTPos); Inline;
Procedure Convert(Var Target: TFTBitmap; Const Alignment: Integer); Inline;
Procedure Blend(Const ASourceOffset: TFTVector; Var Target: TFTBitmap; Var TargetOffset: TFTVector; Const AColor: TFTColor); Inline;
Procedure Done; Inline;
Property ScanLine[Const ALine: Cardinal]: PByte Read GetScanLine;
End;
TFTOutlineFlag = (ftofOwner, ftofEvenOddFill, ftofReverseFill, ftofIgnoreDropouts, ftofSmartDropouts, ftofIncludeStubs, ftofOverlap, ftofHighPrecision = 8, ftofSinglePass);
TFTOutlineFlags = Set Of ftofOwner .. TFTOutlineFlag($1F);
TFTCurveTag = (ftctOn, ftctCubic, ftctHasScanmode, ftctTouchX, ftctTouchY);
TFTCurveTags = Set Of ftctOn .. ftctTouchY;
// bits 5-7 should contain the drop-out mode according to the OpenType specification (SCANMODE).
// Probably this should be SCANTYPE?
TFTCurveTagsHelper = Record Helper For TFTCurveTags
Public Type
TFTDropoutRules = Set Of 1 .. 6;
Public
Function GetDropoutMode: TFTDropoutRules;
End;
Const
ftctTouchBoth = [ftctTouchX, ftctTouchY];
Type
TFTOutline = Record
Strict Private
FNContours, FNPoints: SmallInt;
FPoints: PFTVector;
FTags: ^TFTCurveTags;
FContourEndPoints: PSmallInt;
Strict Private
Function GetPoints: TArray<TFTVector>; Inline;
Function GetTags: TArray<TFTCurveTags>; Inline;
Function GetContours: TArray<SmallInt>; Inline;
Public
Property Points: TArray<TFTVector> Read GetPoints;
Property Tags: TArray<TFTCurveTags> Read GetTags;
Property Contours: TArray<SmallInt> Read GetContours;
Public Const
cOutlineContoursMax = High(SmallInt);
cOutlinePointsMax = High(SmallInt);
Public
Flags: TFTOutlineFlags;
End;
TFTOutlineFuncs = Record
MoveTo: Function([Ref] Const ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl;
LineTo: Function([Ref] Const ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl;
ConicTo: Function([Ref] Const AControl, ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl;
CubicTo: Function([Ref] Const AControl1, AControl2, ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl;
Shift: Integer;
Delta: TFTPos;
End;
TFTGlyphFormat = (ftgfNone = $00000000, ftgfComposite = $636F6D70 { comp } , ftgfBitmap = $62697473 { bits } , ftgfOutline = $6F75746C { outl } , ftgfPlotter = $706C6F74 { plot } );
// Raster definitions
TFTSpan = Record
X: SmallInt;
Len: Word;
Coverage: Byte;
End;
TFTRasterFlag = (ftrfAA, ftrfDirect, ftrfClip, ftrfSDF);
TFTRasterFlags = Set Of ftrfAA .. TFTRasterFlag($1F);
TFTRasterParams = Record
Public
Target: PFTBitmap;
Source: Pointer;
Flags: TFTRasterFlags;
Strict Private
{$HINTS OFF}
FGraySpans, FBlackSpans: Procedure(Const AY, ACount: Integer; [Ref] Const ASpans: TFTSpan; Const AUser: Pointer); Cdecl;
FBitTest: Function(Const AY, AX: Integer; Const AUser: Pointer): Integer; Cdecl;
FBitSet: Procedure(Const AY, AX: Integer; Const AUser: Pointer); Cdecl;
{$HINTS ON}
Public
User: Pointer;
ClipBox: TFTBBox;
End;
TFTRaster = Record
// internal type
End;
TFTRasterFuncs = Record
Public
GlyphFormat: TFTGlyphFormat;
RasterNew: Function([Ref] Const AMemory: TFTMemory; Out ORaster: TFTRaster): Integer; Cdecl;
RasterReset: Procedure(Const ARaster: TFTRaster; Const APoolBase: PByte; Const APoolSize: LongWord); Cdecl;
RasterSetMode: Function(Const ARaster: TFTRaster; Const AMode: LongWord; Const AArgs: Pointer): Integer; Cdecl;
RasterRender: Function(Const ARaster: TFTRaster; [Ref] Const AParams: TFTRasterParams): Integer; Cdecl;
RasterDone: Procedure(Const ARaster: TFTRaster); Cdecl;
End;
{$ENDREGION}
{$REGION 'ftcolor.h experimental interface'}
// experimental interface
TFTPaintFormat = (ftpfColrLayers = 1, ftpfSolid = 2, ftpfLinearGradient = 4, ftptRadialGradient = 6, ftptSweepGradient = 8, ftpfGlyph = 10, ftpfColrGlyph = 11, ftpfTransform = 12,
ftpfTranslate = 14, ftpfScale = 16, ftpfRotate = 24, ftpfSkew = 28, ftpfComposite = 32, ftpfFormatMax = 33, ftpfUnsupported = 255);
TFTColorStopIterator = Record
NumColorStops, CurrentColorStop: Cardinal;
P: PByte;
End;
TFTColorIndex = Record
PaletteIndex: Word;
Alpha: TFTF2Dot14;
End;
TFTColorStop = Record
StopOffset: TFTF2Dot14;
Color: TFTColorIndex;
End;
TFTPaintExtend = (ftpePad, ftpeRepeat, ftpeReflect);
TFTColorLine = Record
Extend: TFTPaintExtend;
ColorStopIterator: TFTColorStopIterator;
End;
TFTAffine23 = Record
XX, XY, dX, YX, YY, dY: TFTFixed;
End;
TFTCompositeMode = (ftcmClear, ftcmSrc, ftcmDest, ftcmSrcOver, ftcmDestOver, ftcmSrcIn, ftcmDestIn, ftcmSrcOut, ftcmDestOut, ftcmSrcAtop, ftcmDestAtop, ftcmXor, ftcmScreen, ftcmOverlay, ftcmDarken,
ftcmLighten, ftcmColorDodge, ftcmColorBurn, ftcmHardLight, ftcmSoftLight, ftcmDifference, ftcmExclusion, ftcmMultiply, ftcmHSLHue, ftcmHSLSaturation, ftcmHSLColor, ftcmHSLLuminosity, ftcmMAX);
TFTOpaquePaint = Record
P: PByte;
InsertRootTransform: ByteBool;
End;
TFTPaintColrLayers = Record
LayerIterator: TFTLayerIterator;
End;
TFTPaintSolid = Record
Color: TFTColorIndex;
End;
TFTPaintLinearGradient = Record
ColorLine: TFTColorLine;
P0, P1, P2: TFTVector;
End;
TFTPaintRadialGradient = Record
ColorLine: TFTColorLine;
C0: TFTVector;
R0: Word;
C1: TFTVector;
R1: Word;
End;
TFTPaintSweepGradient = Record
ColorLine: TFTColorLine;
Center: TFTVector;
StartAngle, EndAngle: TFTFixed;
End;
TFTPaintGlyph = Record
Paint: TFTOpaquePaint;
GlyphID: Cardinal;
End;
TFTPaintColrGlyph = Record
GlyphID: Cardinal;
End;
TFTPaintTransform = Record
Paint: TFTOpaquePaint;
Affine: TFTAffine23;
End;
TFTPaintTranslate = Record
Paint: TFTOpaquePaint;
dX, dY: TFTFixed;
End;
TFTPaintScale = Record
Paint: TFTOpaquePaint;
ScaleX, ScaleY, CenterX, CenterY: TFTFixed;
End;
TFTPaintRotate = Record
Paint: TFTOpaquePaint;
Angle, CenterX, CenterY: TFTFixed;
End;
TFTPaintSkew = Record
Paint: TFTOpaquePaint;
XSkewAngle, YSkewAngle, CenterX, CenterY: TFTFixed;
End;
TFTPaintComposite = Record
SourcePaint: TFTOpaquePaint;
CompositeMode: TFTCompositeMode;
BackdropPaint: TFTOpaquePaint;
End;
TFTColrPaint = Record
Format: TFTPaintFormat;
Case Byte Of
0:
(ColrLayers: TFTPaintColrLayers);
1:
(Glyph: TFTPaintGlyph);
2:
(Solid: TFTPaintSolid);
3:
(LinearGradient: TFTPaintLinearGradient);
4:
(RadialGradient: TFTPaintRadialGradient);
5:
(SweepGradient: TFTPaintSweepGradient);
6:
(Transform: TFTPaintTransform);
7:
(Translate: TFTPaintTranslate);
8:
(Scale: TFTPaintScale);
9:
(Rotate: TFTPaintRotate);
10:
(Skew: TFTPaintSkew);
11:
(Composite: TFTPaintComposite);
12:
(ColrGlyph: TFTPaintColrGlyph);
End;
TFTColorRootTransform = (ftrtIncludeRootTransform, ftrtNoRootTransform, ftrtRootTransformMax);
{$ENDREGION}
{$REGION 'ftlcdfil.h'}
// Subpixel Rendering
TFTLcdFilter = (ftlcdfNone = 0, ftlcdfDefault = 1, ftlcdfLight = 2, ftlcdfLegacy1 = 3, ftlcdfLegacy = 16);
TFTLCDFiveTapFilter = Array [0 .. 4] Of Byte;
TFTLCDThreeVecs = Array [0 .. 2] Of TFTVector;
{$ENDREGION}
{$REGION 'freetype.h'}
// Base interface
TFTGlyphMetrics = Record
Width, Height: TFTPos;
HorzBearingX, HorzBearingY, HorzAdvance: TFTPos;
VertBearingX, VertBearingY, VertAdvance: TFTPos;
End;
PFTBitmapSize = ^TFTBitmapSize;
TFTBitmapSize = Record
Height, Width: SmallInt;
Size, XPpEM, YPpEM: TFTPos;
End;
// Object classes
TFTLibrary = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
End;
TFTModule = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
End;
TFTDriver = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
End;
TFTRenderer = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
End;
PFTSize = ^TFTSize;
PFTGlyphSlot = ^TFTGlyphSlot;
PFTCharMap = ^TFTCharMap;
TFTEncoding = (fteNone = $00000000, fteMsSymbol = $73796D62 { symb } , fteUnicode = $756E6963 { unic } , fteSjis = $736A6973 { sjis } , ftePrc = $67622020 { gb } , fteBig5 = $62696735 { big5 } ,
fteWansung = $77616E73 { wans } , fteJohab = $6A6F6861 { joha } ,
// for backward compatibility
fteGb2312 = ftePrc, fteMsSjis = fteSjis, fteMsGb2312 = ftePrc, fteMsBig5 = fteBig5, fteMsWansung = fteWansung, fteMsJohab = fteJohab, fteAdobeStandard = $41444F42 { ADOB } ,
fteAdobeExpert = $41444245 { ADBE } , fteAdobeCustom = $41444243 { ADBC } , fteAdobeLatin1 = $6C617431 { lat1 } , fteOldLatin2 = $6C617432 { lat2 } , fteAppleRoman = $61726D6E { armn }
);
TFTCharMap = Record
Strict Private
{$HINTS OFF}
FFace: Pointer;
{$HINTS ON}
Public
Encoding: TFTEncoding;
PlatformID, EncodingID: Word;
Function GetCharMapIndex: Integer; Inline;
End;
// Base object classes
TFTFaceFlag = (ftffScalable, ftffFixedSizes, ftffFixedWidth, ftffSFNT, ftffHorizontal, ftffVertical, ftffKerning, ftffFastGlyphs, ftffMultipleMasters, ftffGlyphNames, ftffExternalStream,
ftffHinter, ftffCIDKeyed, ftffTricky, ftffColor, ftffVariation);
TFTFaceFlags = Set Of ftffScalable .. TFTFaceFlag(8 * SizeOf(LongInt) - 1);
TFTStyleFlag = (ftsfItalic, ftsfBold);
TFTStyleFlags = ftsfItalic .. TFTStyleFlag(8 * SizeOf(LongInt) - 1);
TFTStyleFlagsHelper = Record Helper For TFTStyleFlags
Public
Function CountNamedInstances: Cardinal; Inline;
End;
TFTSizeRequestType = (ftsrtNominal, ftsrtRealDim, ftsrtBBox, ftsrtCell, ftsrtScales);
TFTSizeRequest = Record
&Type: TFTSizeRequestType;
Width, Height: LongInt;
HorzResolution, VertResolution: Cardinal;
End;
TFTLoadFlag = (ftlfNoScale, ftlfNoHinting, ftlfRender, ftlfNoBitmap, ftlfVerticalLayout, ftlfForceAutohint, ftlfCropBitmap, ftlfPedantic, ftlfAdvanceOnly, ftlfIgnoreGlobalAdvanceWidth,
ftlfNoRecurse, ftlfIgnoreTransform, ftlfMonochrome, ftlfLinearDesign, ftlfSbitsOnly, ftlfNoAutohint, ftlfTargetLight, ftlfTargetMono, ftlfTargetLCD, ftlfTargetLCDV, ftlfColor,
ftlfComputeMetrics, ftlfBitmapMetricsOnly);
TFTLoadFlags = Set Of ftlfNoScale .. TFTLoadFlag($1F);
TFTRenderMode = (ftrmNormal, ftrmLight, ftrmMono, ftrmLcd, ftrmLcdV, ftrmSDF);
TFTLoadFlagsHelper = Record Helper For TFTLoadFlags
Strict Private
Function GetTargetMode: TFTRenderMode; Inline;
Procedure SetTargetMode(Const AMode: TFTRenderMode); Inline;
Public
Property TargetMode: TFTRenderMode Read GetTargetMode Write SetTargetMode;
End;
{$Z4}
TFTKerningMode = (ftkDefault, ftkUnfitted, ftkUnscaled);
{$Z1}
TFTFSType = Record
Public Type
TFTFSTypeEmbedding = (ftfseInstallableEmbedding = $0, ftfseRestrictedLicenseEmbedding = $2, ftfsePreviewAndPrintEmbedding = $4, ftfseEditableEmbedding = $8);
TFTFSTypeFlag = (ftfsfNoSubsetting, ftfsfBitmapEmbeddingOnly);
TFTFSTypeFlags = Set Of TFTFSTypeFlag;
Strict Private
FValue: Word;
Function GetEmbedding: TFTFSTypeEmbedding; Inline;
Function GetFlags: TFTFSTypeFlags; Inline;
Public
Property Embedding: TFTFSTypeEmbedding Read GetEmbedding;
Property Flags: TFTFSTypeFlags Read GetFlags;
End;
TFTFace = Record
Strict Private
Type
TFTFaceRec = Record
NumFaces, FaceIndex: LongInt;
FaceFlags: TFTFaceFlags;
StyleFlags: TFTStyleFlags;
NumGlyphs: LongInt;
FamilyName, StyleName: PAnsiChar;
NumFixedSizes: Integer;
AvailableSizes: PFTBitmapSize;
NumCharMaps: Integer;
CharMaps: PFTCharMap;
Generic: TFTGeneric;
// properties for scalable outlines
BBox: TFTBBox;
UnitsPerEM: Word;
Ascender, Descender, Height: SmallInt;
MaxAdvanceWidth, MaxAdvanceHeight: SmallInt;
UnderlinePosition, UnderlineThickness: SmallInt;
Glyph: PFTGlyphSlot;
Size: PFTSize;
CharMap: PFTCharMap;
FDriver: TFTDriver;
FMemory: PFTMemory;
FStream: PFTStream;
FSizesList: TFTList;
FAutohint: TFTGeneric;
FExtensions, FInternal: Pointer;
End;
Strict Private
FValue: ^TFTFaceRec;
Function GetNumFaces_: LongInt; Inline;
Function GetFaceIndex: LongInt; Inline;
Function GetFaceFlags: TFTFaceFlags; Inline;
Function GetStyleFlags_: TFTStyleFlags; Inline;
Function GetNumGlyphs: LongInt; Inline;
Function GetFamilyName: AnsiString; Inline;
Function GetStyleName: AnsiString; Inline;
Function GetAvailableSizes: TArray<TFTBitmapSize>;
Function GetCharMaps: TArray<TFTCharMap>; Inline;
Function GetGeneric: TFTGeneric; Inline;
Procedure SetGeneric(Const AValue: TFTGeneric); Inline;
Function GetBBox: TFTBBox; Inline;
Function GetUnitsPerEM: Word; Inline;
Function GetAscender: SmallInt; Inline;
Function GetDescender: SmallInt; Inline;
Function GetHeight: SmallInt; Inline;
Function GetMaxAdvanceWidth: SmallInt; Inline;
Function GetMaxAdvanceHeight: SmallInt; Inline;
Function GetUnderlinePosition: SmallInt; Inline;
Function GetUnderlineThickness: SmallInt; Inline;
Function GetGlyph: PFTGlyphSlot; Inline;
Function GetSize: PFTSize; Inline;
Function GetCharMap: PFTCharMap; Inline;
Function GetDriverName: AnsiString; Inline;
Public Type
TColorGlyphLayerItem = Record
GlyphIndex, ColorIndex: Cardinal;
End;
TFTCharVariantDefault = (ftcvdStandardCMap = 1, ftcsdVariationSelectorCMap = 0, ftcsdNoVariation = Integer( -1));
PPaletteArray = ^TPaletteArray;
TPaletteArray = Packed Array [0 .. 0] Of TFTColor;
Public
Function IsNamedInstance: Boolean; Inline;
Class Function Create(Const AFile: AnsiString; Const AFaceIndex: Word; Const ANamedInstanceIndex: Word = 0): TFTFace; Overload; Static;
Class Function Create(Const AData: Pointer; Const ASize: Cardinal; Const AFaceIndex: Word; Const ANamedInstanceIndex: Word = 0): TFTFace; Overload; Static;
Procedure Destroy;
Class Function GetNumFaces(Const AFile: AnsiString): Integer; Overload; Static;
Class Function GetNumFaces(Const AData: Pointer; Const ASize: Cardinal): Integer; Overload; Static;
Class Function GetStyleFlags(Const AFile: AnsiString; Const AFaceIndex: Word): TFTStyleFlags; Overload; Static;
Class Function GetStyleFlags(Const AData: Pointer; Const ASize: Cardinal; Const AFaceIndex: Word): TFTStyleFlags; Overload; Static;
Procedure SelectSize(Const AStrikeIndex: Integer); Inline;
Procedure RequestSize(Const ARequest: TFTSizeRequest); Overload; Inline;
Procedure RequestSize(Const AType: TFTSizeRequestType; Const AWidth, AHeight: LongInt; Const AHorzResolution, AVertResolution: Cardinal); Overload;
Procedure SetCharSize(Const ACharWidth, ACharHeight: TFTF26Dot6; Const AHorzResolution, AVertResolution: Cardinal); Inline;
Procedure SetPixelSize(Const APixelWidth, APixelHeight: Cardinal); Inline;
Procedure LoadGlyph(Const AGlyphIndex: Cardinal; Const ALoadFlags: TFTLoadFlags = []); Inline;
Procedure LoadChar(Const ACharCode: LongWord; Const ALoadFlags: TFTLoadFlags = []); Inline;
Procedure ClearTransform; Inline;
Procedure SetTransform(Const AMatrix: TFTMatrix); Overload; Inline;
Procedure SetTransform(Const ADelta: TFTVector); Overload; Inline;
Procedure SetTransform(Const AMatrix: TFTMatrix; Const ADelta: TFTVector); Overload; Inline;
Procedure GetTransform(Out OMatrix: TFTMatrix); Overload; Inline;
Procedure GetTransform(Out ODelta: TFTVector); Overload; Inline;
Procedure GetTransform(Out OMatrix: TFTMatrix; Out ODelta: TFTVector); Overload; Inline;
Function GetKerning(Const ALeftGlyph, ARightGlyph: Cardinal; Const AKernMode: TFTKerningMode): TFTVector; Inline;
Function GetTrackKerning(Const APointSize: TFTFixed; Const ADegree: Integer): TFTFixed; Inline;
Function GetGlyphName(Const AGlyphIndex: Cardinal): AnsiString;
Function GetPostscriptName: AnsiString; Inline;
Procedure SelectCharMap(Const AEncoding: TFTEncoding); Inline;
Procedure SetCharMap(Var CharMap: TFTCharMap); Inline;
Function GetCharIndex(Const ACharCode: LongWord): Cardinal; Inline;
Function GetFirstChar(Out OGlyphIndex: Cardinal): LongWord; Inline;
Function GetNextChar(Const ACharCode: LongWord; Out OGlyphIndex: Cardinal): LongWord; Inline;
Procedure Properties(Const AStemDarkening: ByteBool); Overload; Inline;
Procedure Properties(Const ALCDFilterWeights: TFTLCDFiveTapFilter); Overload; Inline;
Procedure Properties(Const ARandomSeed: Integer); Overload; Inline;
Procedure Properties(Const AStemDarkening: ByteBool; Const ALCDFilterWeights: TFTLCDFiveTapFilter); Overload;
Procedure Properties(Const AStemDarkening: ByteBool; Const ARandomSeed: Integer); Overload;
Procedure Properties(Const ALCDFilterWeights: TFTLCDFiveTapFilter; Const ARandomSeed: Integer); Overload;
Procedure Properties(Const AStemDarkening: ByteBool; Const ALCDFilterWeights: TFTLCDFiveTapFilter; Const ARandomSeed: Integer); Overload;
Function GetNameIndex(Const GlyphName: AnsiString): Cardinal; Inline;
Function GetColorGlyphLayers(Const ABaseGlyph: Cardinal): TArray<TColorGlyphLayerItem>;
Function GetFSTypeFlags: TFTFSType; Inline;
Function GetCharVariantIndex(Const ACharCode, AVariantSelector: LongWord): Cardinal; Inline;
Function GetCharVariantIsDefault(Const ACharCode, AVariantSelector: LongWord): TFTCharVariantDefault; Inline;
Function GetVariantSelectors: TArray<Cardinal>;
Function GetVariantsOfChar(Const ACharCode: LongWord): TArray<Cardinal>;
Function GetCharsOfVariant(Const AVariantSelector: LongWord): TArray<Cardinal>;
Function GetPalette: TFTPaletteData; Inline;
Function SelectPalette(Const APaletteIndex: Word): PPaletteArray; Inline;
Procedure SetForegroundColor(Const AForegroundColor: TFTColor); Inline;
Function GetColorGlyphPaint(Const ABaseGlyph: Cardinal; Const ARootTransform: TFTColorRootTransform): TFTOpaquePaint; Inline;
Function GetPaintLayers: TArray<TFTOpaquePaint>;
Function GetColorLineStops: TArray<TFTColorStop>;
Function GetPaint(Const AOpaquePaint: TFTOpaquePaint): TFTColrPaint; Inline;
Property NumFaces: LongInt Read GetNumFaces_;
Property FaceIndex: LongInt Read GetFaceIndex;
Property FaceFlags: TFTFaceFlags Read GetFaceFlags;
Property StyleFlags: TFTStyleFlags Read GetStyleFlags_;
Property NumGlyphs: LongInt Read GetNumGlyphs;
Property FamilyName: AnsiString Read GetFamilyName;
Property StyleName: AnsiString Read GetStyleName;
Property AvailableSizes: TArray<TFTBitmapSize> Read GetAvailableSizes;
Property CharMaps: TArray<TFTCharMap> Read GetCharMaps;
Property Generic: TFTGeneric Read GetGeneric Write SetGeneric;
Property BBox: TFTBBox Read GetBBox;
Property UnitsPerEM: Word Read GetUnitsPerEM;
Property Ascender: SmallInt Read GetAscender;
Property Descender: SmallInt Read GetDescender;
Property Height: SmallInt Read GetHeight;
Property MaxAdvanceWidth: SmallInt Read GetMaxAdvanceWidth;
Property MaxAdvanceHeight: SmallInt Read GetMaxAdvanceHeight;
Property UnderlinePosition: SmallInt Read GetUnderlinePosition;
Property UnderlineThickness: SmallInt Read GetUnderlineThickness;
Property Glyph: PFTGlyphSlot Read GetGlyph;
Property Size: PFTSize Read GetSize;
Property CharMap: PFTCharMap Read GetCharMap;
Property DriverName: AnsiString Read GetDriverName;
End;
TFTSizeMetrics = Record
XPpEM, YPpEM: Word;
XScale, YScale: TFTFixed;
Ascender, Descender, Height, MaxAdvance: TFTPos;
End;
TFTSize = Record
Public
Face: TFTFace;
Generic: TFTGeneric;
Metrics: TFTSizeMetrics;
Strict Private
{$HINTS OFF}
FInternal: Pointer;
{$HINTS ON}
End;
TFTSubGlyphFlag = (ftsgfArgsAreWords, ftsgfArgsAreXyValues, ftsgfRoundXyToGrid, ftsgfScale, ftsgfXyScale = 6, ftsgf2x2, ftsgfUseMyMetrics = 9);
TFTSubGlyphFlags = Set Of ftsgfArgsAreWords .. TFTSubGlyphFlag($1F);
TFTGlyphSlot = Record
Public
&Library: TFTLibrary;
Face: TFTFace;
Next: PFTGlyphSlot;
GlyphIndex: Cardinal;
Generic: TFTGeneric;
Metrics: TFTGlyphMetrics;
LinearHorzAdvance, LinearVertAdvance: TFTFixed;
Advance: TFTVector;
Format: TFTGlyphFormat;
Bitmap: TFTBitmap;
BitmapLeft, BitmapTop: Integer;
Outline: TFTOutline;
NumSubGlyphs: Cardinal;
Strict Private {$HINTS OFF}
FSubGlyphs, FControlData: Pointer;
FControlLen: Integer; {$HINTS ON}
Public
LsbDelta, RsbDelta: TFTPos;
Strict Private {$HINTS OFF}
FOther, FInternal: Pointer;
{$HINTS ON}
Public
Procedure RenderGlyph(Const ARenderMode: TFTRenderMode); Inline;
Procedure SubGlyphInfo(Const SubIndex: Cardinal; Out OIndex: Integer; Out OFlags: TFTSubGlyphFlags; Out OArg1, OArg2: Integer; Out OTransform: TFTMatrix); Inline;
Procedure OwnBitmap; Inline;
End;
// Functions
TFTOpenFlag = (ftofMemory, ftofStream, ftofPathname, ftofDriver, ftofParams);
TFTOpenFlags = ftofMemory .. TFTOpenFlag($1F);
TFTParameterTag = (ftptIgnoreTypographicFamily = $69677066 { igpf } , ftptIgnoreTypographicSubfamily = $69677073 { igps } , ftptIncremental = $696E6372 { incr } ,
ftptLCDFilterWeights = $6C636466 { lcdf } , ftptRandomSeed = $73656564 { seed } , ftptStemDarkening = $6461726B { dark } , ftptUnpatentedHinting = $756E7061 { unpa } );
PFTParameter = ^TFTParameter;
TFTParameter = Record
Tag: TFTParameterTag;
Data: Pointer;
End;
TFTOpenArgs = Record
Flags: TFTOpenFlags;
MemoryBase: PByte;
MemorySize: LongInt;
Pathname: PAnsiChar;
Stream: PFTStream;
Driver: TFTModule;
NumParams: Integer;
Params: PFTParameter;
End;
{$ENDREGION}
{$REGION 'ftmodapi.h'}
// Module Management
TFTModuleFlag = (ftmfFontDriver, ftmfRenderer, ftmfHinter, ftmfStyler, ftmfDriverScalable = 8, ftmfDriverNoOutlines, ftmfDriverHasHinter, ftmfDriverHintsLightly);
TFTModuleFlags = Set Of ftmfFontDriver .. TFTModuleFlag(8 * SizeOf(LongWord) - 1);
PFTModuleInterface = Pointer;
TFTModuleClass = Record
ModuleFlags: TFTModuleFlags;
ModuleSize: LongInt;
ModuleName: PAnsiChar;
ModuleVersion, ModuleRequires: TFTFixed;
ModuleInterface: PFTModuleInterface;
ModuleInit: Function(Module: TFTModule): TFTError; Cdecl;
ModuleDone: Procedure(Module: TFTModule); Cdecl;
GetInterface: Function(Const Module: TFTModule; Const Name: PAnsiChar): PFTModuleInterface; Cdecl;
End;
TFTDebugHookFunc = Function(Const AArg: Pointer): TFTError; Cdecl;
{$Z4}
TFTDebugHook = (ftdhTrueType);
{$Z1}
TFTTrueTypeEngineType = (fttteNone, fttteUnpatented, ftttePatented);
{$ENDREGION}
TFTManager = Class Abstract
Strict Private
Class Var FLibrary: TFTLibrary;
Class Var FMajor, FMinor, FPatch: Integer;
Class Function MemAlloc([Ref] Const AMemory: TFTMemory; Const ASize: Integer): Pointer; Static; Cdecl;
Class Procedure MemFree([Ref] Const AMemory: TFTMemory; Const ABlock: Pointer); Static; Cdecl;
Class Function MemRealloc([Ref] Const AMemory: TFTMemory; Const ACurSize, ANewSize: Integer; Const ABlock: Pointer): Pointer; Static; Cdecl;
Const
sError = 'The error %d occured in a FreeType call: %s.';
FREETYPE_MAJOR = 2;
FREETYPE_MINOR = 11;
FREETYPE_PATCH = 0;
cMem: TFTMemory = (User: NIL; AllocFunc: TFTManager.MemAlloc; FreeFunc: TFTManager.MemFree; ReallocFunc: TFTManager.MemRealloc);
Private
Class Procedure Initialize; Static;
Class Procedure Finalize; Static;
Public
Class Procedure Error(Const AErrorCode: TFTError); Static; // Inline;
Class Property &Library: TFTLibrary Read FLibrary;
Class Property MajorVersion: Integer Read FMajor;
Class Property MinorVersion: Integer Read FMinor;
Class Property PatchVersion: Integer Read FPatch;
End;
{$REGION 'fterrors.h'}
Function FT_Error_String(Const AErrorCode: TFTError): PAnsiChar; Cdecl; External FreeTypeDLL;
{$ENDREGION}
{$REGION 'ftlcdfil.h'}
Function FT_Library_SetLcdFilter(&Library: TFTLibrary; Const AFilter: TFTLcdFilter): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Library_SetLcdFilterWeights(&Library: TFTLibrary; [Ref] Const AWeights: TFTLCDFiveTapFilter): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Library_SetLcdGeometry(&Library: TFTLibrary; [Ref] Const ASub: TFTLCDThreeVecs): TFTError; Cdecl; External FreeTypeDLL;
{$ENDREGION}
{$REGION 'freetype.h'}
Function FT_Init_FreeType(Out OLibrary: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Done_FreeType(&Library: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL;
Function FT_New_Face(Const ALibrary: TFTLibrary; Const AFilePathName: PAnsiChar; Const AFaceIndex: LongInt; Out AFace: TFTFace): TFTError; Cdecl; External FreeTypeDLL;
Function FT_New_Memory_Face(Const ALibrary: TFTLibrary; Const AFileBase: PByte; Const AFileSize, AFaceIndex: LongInt; Out OFace: TFTFace): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Open_Face(Const ALibrary: TFTLibrary; [Ref] Const AArgs: TFTOpenArgs; Const FaceIndex: LongInt; Out OFace: TFTFace): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Attach_File(Face: TFTFace; Const AFilePathName: PAnsiChar): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Attach_Stream(Face: TFTFace; [Ref] Const AParameters: TFTOpenArgs): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Reference_Face(Face: TFTFace): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Done_Face(Face: TFTFace): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Select_Size(Face: TFTFace; Const AStrikeIndex: Integer): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Request_Size(Face: TFTFace; [Ref] Const AReq: TFTSizeRequest): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Set_Char_Size(Face: TFTFace; Const ACharWidth, ACharHeight: TFTF26Dot6; Const AHorzResolution, AVertResolution: Cardinal): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Set_Pixel_Sizes(Face: TFTFace; Const APixelWidth, APixelHeight: Cardinal): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Load_Glyph(Face: TFTFace; Const AGlyphIndex: Cardinal; Const ALoadFlags: TFTLoadFlags): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Load_Char(Face: TFTFace; Const ACharCode: LongWord; Const ALoadFlags: TFTLoadFlags): TFTError; Cdecl; External FreeTypeDLL;
Procedure FT_Set_Transform(Face: TFTFace; Const AMatrix: PFTMatrix; Const ADelta: PFTVector); Cdecl; External FreeTypeDLL;
Procedure FT_Get_Transform(Const AFace: TFTFace; OMatrix: PFTMatrix; ODelta: PFTVector); Cdecl; External FreeTypeDLL;
Function FT_Render_Glyph(Var Slot: TFTGlyphSlot; Const RenderMode: TFTRenderMode): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Kerning(Const AFace: TFTFace; Const ALeftGlyph, ARightGlyph: Cardinal; Const AKernMode: TFTKerningMode; Out OKerning: TFTVector): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Track_Kerning(Const AFace: TFTFace; Const APointSize: TFTFixed; Const ADegree: Integer; Out OKerning: TFTFixed): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Glyph_Name(Const AFace: TFTFace; Const AGlyphIndex: Cardinal; Const ABuffer: Pointer; Const ABufferMax: Cardinal): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Postscript_Name(Const AFace: TFTFace): PAnsiChar; Cdecl; External FreeTypeDLL;
Function FT_Select_Charmap(Face: TFTFace; Const AEncoding: TFTEncoding): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Set_Charmap(Face: TFTFace; Var CharMap: TFTCharMap): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Charmap_Index([Ref] Const ACharmap: TFTCharMap): Integer; Cdecl; External FreeTypeDLL;
Function FT_Get_Char_Index(Const AFace: TFTFace; Const ACharCode: LongWord): Cardinal; Cdecl; External FreeTypeDLL;
Function FT_Get_First_Char(Const AFace: TFTFace; Out OGlyphIndex: Cardinal): LongWord; Cdecl; External FreeTypeDLL;
Function FT_Get_Next_Char(Const AFace: TFTFace; Const ACharCode: LongWord; Out OGlyphIndex: Cardinal): LongWord; Cdecl; External FreeTypeDLL;
Function FT_Face_Properties(Face: TFTFace; Const ANumProperties: Cardinal; Const AProperties: PFTParameter): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Name_Index(Const AFace: TFTFace; Const AGlyphName: PAnsiChar): Cardinal; Cdecl; External FreeTypeDLL;
Function FT_Get_SubGlyph_Info([Ref] Const AGlyph: TFTGlyphSlot; Const ASubIndex: Cardinal; Out OIndex: Integer; Out OFlags: TFTSubGlyphFlags; Out OArg1, OArg2: Integer; Out OTransform: TFTMatrix)
: TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_FSType_Flags(Const AFace: TFTFace): TFTFSType; Cdecl; External FreeTypeDLL;
Function FT_Face_GetCharVariantIndex(Const AFace: TFTFace; Const ACharCode, AVariantSelector: LongWord): Cardinal; Cdecl; External FreeTypeDLL;
Function FT_Face_GetCharVariantIsDefault(Const AFace: TFTFace; Const ACharCode, AVariantSelector: LongWord): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Face_GetVariantSelectors(Const AFace: TFTFace): PCardinal; Cdecl; External FreeTypeDLL;
Function FT_Face_GetVariantsOfChar(Const AFace: TFTFace; Const ACharCode: LongWord): PCardinal; Cdecl; External FreeTypeDLL;
Function FT_Face_GetCharsOfVariant(Const AFace: TFTFace; Const VariantSelector: LongWord): PCardinal; Cdecl; External FreeTypeDLL;
// Computations
Function FT_MulDiv(Const AMultiplier1, AMultiplier2, ADivisor: LongInt): LongInt; Cdecl; External FreeTypeDLL;
Function FT_MulFix(Const AMultiplier: LongInt; Const AMultiplierF16Dot16: TFTFixed): LongInt; Cdecl; External FreeTypeDLL; // (A*B)/$10000
Function FT_DivFix(Const ANumerator: LongInt; Const ADenominatorF16Dot16: TFTFixed): LongInt; Cdecl; External FreeTypeDLL; // (A*$10000)/B
Function FT_RoundFix(Const A: TFTFixed): TFTFixed; Cdecl; External FreeTypeDLL;
Function FT_CeilFix(Const A: TFTFixed): TFTFixed; Cdecl; External FreeTypeDLL;
Function FT_FloorFix(Const A: TFTFixed): TFTFixed; Cdecl; External FreeTypeDLL;
Procedure FT_Vector_Transform(Var Vector: TFTVector; [Ref] Const AMatrix: TFTMatrix); Cdecl; External FreeTypeDLL;
// FreeType Version
Procedure FT_Library_Version(Const ALibrary: TFTLibrary; Out OMajor, OMinor, OPatch: Integer); Cdecl; External FreeTypeDLL;
{$ENDREGION}
{$REGION 'ftcolor.h'}
Function FT_Palette_Data_Get(Const AFace: TFTFace; Out OPalette: TFTPaletteData): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Palette_Select(Const AFace: TFTFace; Const APaletteIndex: Word; Out OPalette: PFTColor): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Palette_Set_Foreground_Color(Const AFace: TFTFace; Const AForegroundColor: TFTColor): TFTError; Cdecl; External FreeTypeDLL;
// Layer management
Function FT_Get_Color_Glyph_Layer(Const AFace: TFTFace; Const ABaseGlyph: Cardinal; Out OGlyphIndex, OColorIndex: Cardinal; Var Iterator: TFTLayerIterator): ByteBool; Cdecl; External FreeTypeDLL;
// experimental interface
Function FT_Get_Color_Glyph_Paint(Const AFace: TFTFace; Const ABaseGlyph: Cardinal; Const ARootTransform: TFTColorRootTransform; Out OPaint: TFTOpaquePaint): ByteBool; Cdecl; External FreeTypeDLL;
Function FT_Get_Paint_Layers(Const AFace: TFTFace; Var Iterator: TFTLayerIterator; Out OPaint: TFTOpaquePaint): ByteBool; Cdecl; External FreeTypeDLL;
Function FT_Get_Colorline_Stops(Const AFace: TFTFace; Out OColorStop: TFTColorStop; Var Iterator: TFTColorStopIterator): ByteBool; Cdecl; External FreeTypeDLL;
Function FT_Get_Paint(Const AFace: TFTFace; Const AOpaquePaint: TFTOpaquePaint; Out OPaint: TFTColrPaint): ByteBool; Cdecl; External FreeTypeDLL;
{$ENDREGION}
{$REGION 'ftbitmap.h'}
Procedure FT_Bitmap_Init(Var Bitmap: TFTBitmap); Cdecl; External FreeTypeDLL;
Function FT_Bitmap_Copy(Const ALibrary: TFTLibrary; [Ref] Const ASource: TFTBitmap; Var Target: TFTBitmap): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Bitmap_Embolden(Const ALibrary: TFTLibrary; Var Bitmap: TFTBitmap; Const AXStrength, AYStrength: TFTPos): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Bitmap_Convert(Const ALibrary: TFTLibrary; [Ref] Const ASource: TFTBitmap; Var Target: TFTBitmap; Const Alignment: Integer): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Bitmap_Blend(Const ALibrary: TFTLibrary; [Ref] Const ASource: TFTBitmap; Const ASourceOffset: TFTVector; Var Target: TFTBitmap; Var TargetOffset: TFTVector; Const AColor: TFTColor)
: TFTError; Cdecl; External FreeTypeDLL;
Function FT_GlyphSlot_Own_Bitmap(Var Slot: TFTGlyphSlot): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Bitmap_Done(Const ALibrary: TFTLibrary; Var Bitmap: TFTBitmap): TFTError; Cdecl; External FreeTypeDLL;
{$ENDREGION}
{$REGION 'ftmodapi.h'}
Function FT_Add_Module(&Library: TFTLibrary; [Ref] Const AClass: TFTModuleClass): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Get_Module(&Library: TFTLibrary; Const AModuleName: PAnsiChar): TFTModule; Cdecl; External FreeTypeDLL;
Function FT_Remove_Module(&Library: TFTLibrary; Module: TFTModule): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Property_Set(&Library: TFTLibrary; Const AModuleName, APropertyName: PAnsiChar; Const AValue): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Property_Get(Const ALibrary: TFTLibrary; Const AModuleName, APropertyName: PAnsiChar; Var Value): TFTError; Cdecl; External FreeTypeDLL;
Procedure FT_Set_Default_Properties(&Library: TFTLibrary); Cdecl; External FreeTypeDLL;
Function FT_Reference_Library(&Library: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL;
Function FT_New_Library([Ref] Const AMemory: TFTMemory; Out OLibrary: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL;
Function FT_Done_Library(&Library: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL;
Procedure FT_Set_Debug_Hook(&Library: TFTLibrary; Const AHookIndex: TFTDebugHook; Const ADebugHook: TFTDebugHookFunc); Cdecl; External FreeTypeDLL;
Procedure FT_Add_Default_Modules(&Library: TFTLibrary); Cdecl; External FreeTypeDLL;
// The TrueType Engine
Function FT_Get_TrueType_Engine_Type(Const ALibrary: TFTLibrary): TFTTrueTypeEngineType; Cdecl; External FreeTypeDLL;
{$ENDREGION}
Implementation
{ TFTMemory }
Function TFTMemory.Alloc(Const ASize: LongInt): Pointer;
Begin
Result := AllocFunc(Self, ASize);
End;
Procedure TFTMemory.Free(Const ABlock: Pointer);
Begin
FreeFunc(Self, ABlock);
End;
Function TFTMemory.Realloc(Const ACurSize, ANewSize: LongInt; Const ABlock: Pointer): Pointer;
Begin
Result := ReallocFunc(Self, ACurSize, ANewSize, ABlock);
End;
{ TFTStream }
Function TFTStream.Read(Const AOffset: LongWord; Var ABuffer; Const ACount: LongWord): LongWord;
Begin
Result := ReadFunc(Self, AOffset, ABuffer, ACount);
End;
Procedure TFTStream.Close;
Begin
CloseFunc(Self);
End;
{ TFTColor }
Constructor TFTColor.Mix(Const ABlue, AGreen, ARed, AAlpha: Byte);
Begin
Blue := ABlue;
Green := AGreen;
Red := ARed;
Alpha := AAlpha;
End;
{ TFTBitmap }