├── .gitattributes ├── .gitignore ├── README.md ├── uFreeType.pas ├── uHarfBuzz.pas └── uICU.pas /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | #*.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | # C++ object files produced when C/C++ Output file generation is configured. 25 | # Uncomment this if you are not using external objects (zlib library for example). 26 | #*.obj 27 | # 28 | 29 | # Delphi compiler-generated binaries (safe to delete) 30 | *.exe 31 | *.dll 32 | *.bpl 33 | *.bpi 34 | *.dcp 35 | *.so 36 | *.apk 37 | *.drc 38 | *.map 39 | *.dres 40 | *.rsm 41 | *.tds 42 | *.dcu 43 | *.lib 44 | *.a 45 | *.o 46 | *.ocx 47 | 48 | # Delphi autogenerated files (duplicated info) 49 | *.cfg 50 | *.hpp 51 | *Resource.rc 52 | 53 | # Delphi local files (user-specific info) 54 | *.local 55 | *.identcache 56 | *.projdata 57 | *.tvsconfig 58 | *.dsk 59 | 60 | # Delphi history and backups 61 | __history/ 62 | __recovery/ 63 | *.~* 64 | 65 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi) 66 | *.stat 67 | 68 | # Boss dependency manager vendor folder https://github.com/HashLoad/boss 69 | modules/ 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TextShaping4Delphi 2 | This contains partial Delphi headers for FreeType, harfbuzz, and ICU. 3 | All headers require at least version XE3. They may be compatible with FreePascal, just be sure to replace `[Ref] Const` by `Constref` in all source files. They should be compatible with both x86_32 and x86_64. 4 | 5 | ## FreeType 6 | The header translation is based on version 2.11.0. It includes the header files `ftsystem.h`, `fterrors.h`, `ftcolor.h`, `ftbitmap.h`, `ftimage.h`, `fttypes.h`, `ftlcdfil.h`, `freetype.h`, `ftmodapi.h`, and `ftobj.h`. 7 | 8 | ## HarzBuzz 9 | The header translation is based on version 2.9.0. It includes the header files `hb-common.h`, `hb-blob.h`, `hb-unicode.h`, `hb-set.h`, `hb-face.h`, `hb-font.h`, `hb-buffer.h`, `hb-map.h`, `hb-shape-plan.h`, `hb-version.h`, and `hb-ft.h`. 10 | 11 | ## ICU 12 | The header translation is based on version 69.1. It includes the header files `utypes.h`, `uvernum.h`, `uversion.h`, `umachine.h`, `uenum.h`, `uloc.h`, `stringoptions.h`, `ucpmap.h`, `uchar.h`, `utext.h`, `parseerr.h`, and `ubrk.h`. Note that ICU can be compiled with a weird "feature" (and the precompiled binaries available from the GitHub Releases of ICU are!) that appends a suffix which contains the version number to each function; therefore, the DLLs cannot easily be swapped without changing the corresponding string (or introducing dynamic binding that tries to determine this string). 13 | 14 | ## Interface 15 | The translations often use native Delphi features (e.g., sets instead of bitmasks) where possible in order to give a natural feel for the Delphi developer. All types (including the most important pointer types) are implemented as records, so that we do not get any overhead. The functional C interface is of course available, but a much more natural approach is to use the advanced record capabilities - basically treat your records as if they were classes. The overhead for this can be zero if the compiler inlines properly, and it is negligible even under the not-so-optimal inlining performance of the compiler. 16 | 17 | ## Contributing 18 | In all cases, the translated headers comprise only a small subset of the features of the libraries. I may expand it when I need it, but feel free to create pull requests that cover another feature set. It should provide both the function headers and types, using as much of Delphi's natural features and convenience functions in the records. 19 | 20 | Only an even smaller subset of all the functions is tested. Please report any bugs! 21 | 22 | ## Example (text shaping) 23 | This is oriented at the [simple shaping example](https://harfbuzz.github.io/a-simple-shaping-example.html) and the [harfbuzz tutorial](https://github.com/harfbuzz/harfbuzz-tutorial/blob/master/hello-harfbuzz-freetype.c). 24 | ```Delphi 25 | Uses 26 | uFreeType, uHarfBuzz; 27 | Var 28 | Face: TFTFace; 29 | Font: THBFont; 30 | Buf: THBBuffer; 31 | GlyphInfo: TArray; 32 | GlyphPos: TArray; 33 | I: Integer; 34 | CursorX, CursorY: Double; 35 | Const 36 | FontSize = 36; 37 | Begin 38 | Face := TFTFace.Create({ font file goes here }, 0); 39 | Try 40 | Face.SetCharSize(FontSize *64, FontSize *64, 0, 0); 41 | Font := THBFace.CreateReferenced(Face); 42 | Try 43 | Font.FTFontSetFuncs; 44 | Buf := THBBuffer.Create; 45 | Try 46 | Buf.Add('Sample text'); 47 | // variant 1 48 | Buf.Direction := hbdLTR; 49 | Buf.Script := hbsLatin; 50 | Buf.Language := 'en'; 51 | // variant 2 52 | Buf.GuessSegmentProperties; 53 | 54 | Buf.Shape(Font); 55 | 56 | GlyphInfo := Buf.GetGlyphInfos; 57 | GlyphPos := Buf.GetGlyphPositions; 58 | 59 | For I := 0 To High(GlyphInfo) Do Begin 60 | Face.LoadGlyph(GlyphInfo[I].Codepoint, [ftlfRender]); 61 | // Draw should draw the bitmap #1 at x position #2 and y position #3. 62 | Draw(Face.Glyph.Bitmap, 63 | Round(CursorX + GlyphPos[I].XOffset / 64 + Face.Glyph.BitmapLeft), 64 | Round(CursorY - GlyphPos[I].YOffset / 64 - Face.Glyph.BitmapTop)); 65 | CursorX := CursorX + GlyphPos[I].XAdvance / 64; 66 | CursorY := CursorY - GlyphPos[I].YAdvance / 64; 67 | End; 68 | Finally 69 | Buf.Destroy; 70 | End; 71 | Finally 72 | Font.Destroy; 73 | End; 74 | Finally 75 | Face.Destroy; 76 | End; 77 | End. 78 | ``` 79 | 80 | ## Example (text breaking) 81 | This is oriented at the [text breaking example](https://github.com/unicode-org/icu/blob/main/icu4c/source/samples/break/ubreak.c). 82 | ```Delphi 83 | Uses uICU; 84 | 85 | Procedure PrintEachForward(ABoundary: TICUBreakIterator; Const AStr: String); 86 | Var 87 | Start, &End: Integer; 88 | Begin 89 | Start := ABoundary.First; 90 | &End := ABoundary.Next; 91 | While &End <> TICUBreakIterator.cBrkDone Do Begin 92 | WriteLn(Copy(AStr, Start +1, &End - Start)); 93 | Start := &End; 94 | &End := ABoundary.Next; 95 | End; 96 | End; 97 | 98 | Procedure PrintEachBackward(ABoundary: TICUBreakIterator; Const AStr: String); 99 | Var 100 | Start, &End: Integer; 101 | Begin 102 | &End := ABoundary.Last; 103 | Start := ABoundary.Previous; 104 | While &End <> TICUBreakIterator.cBrkDone Do Begin 105 | WriteLn(Copy(AStr, Start +1, &End - Start)); 106 | &End := Start; 107 | Start := ABoundary.Previous; 108 | end; 109 | End; 110 | 111 | Const cStringToExamine = '{ put your string here }'; 112 | Var 113 | BI: TICUBreakIterator; 114 | Begin 115 | WriteLn('Sentence Boundaries'); 116 | BI := TICUBreakIterator.Create(icubitSentence, TICULocale.locUS, Blindtext); 117 | Try 118 | WriteLn('Forward'); 119 | PrintEachForward(BI, cStringToExamine); 120 | WriteLn('Backward'); 121 | PrintEachBackward(BI, cStringToExamine); 122 | Finally 123 | BI.Free; 124 | End; 125 | 126 | WriteLn('Word Boundaries'); 127 | BI := TICUBreakIterator.Create(icubitWord, TICULocale.locUS, Blindtext); 128 | Try 129 | WriteLn('Forward'); 130 | PrintEachForward(BI, cStringToExamine); 131 | WriteLn('Backward'); 132 | PrintEachBackward(BI, cStringToExamine); 133 | Finally 134 | BI.Free; 135 | End; 136 | End. 137 | ``` -------------------------------------------------------------------------------- /uFreeType.pas: -------------------------------------------------------------------------------- 1 | // Translation of the FreeType interface into Delphi Language/Object Pascal 2 | // Based on version 2.11.0 3 | // This header file is Copyright (C) 2021 by Benjamin Desef 4 | // You may use it under the same conditions as FreeType itself, i.e., you may choose to 5 | // either apply the FreeType License or the GNU General Public License version 2. 6 | // The original FreeType copyright header is 7 | // Copyright (C) 1996-2021 by 8 | // David Turner, Robert Wilhelm, and Werner Lemberg. 9 | 10 | {$Z1} 11 | Unit uFreeType; 12 | 13 | Interface 14 | 15 | {$IFDEF FPC} 16 | {$MODE Delphi} 17 | {$MESSAGE FATAL 'Replace every instance of "[Ref] Const" in this file by "Constref", then disable this error.'} 18 | {$ENDIF} 19 | 20 | Uses SysUtils{$IFNDEF VER230}, AnsiStrings{$ENDIF}; 21 | 22 | Const 23 | FreeTypeDLL = 'freetype.dll'; 24 | 25 | Type 26 | EFreeType = Class(Exception) 27 | End; 28 | 29 | {$REGION 'fttypes.h'} 30 | // Basic Data Types 31 | 32 | TFTTag = Type Cardinal; 33 | TFTF2Dot14 = Type SmallInt; 34 | TFTF26Dot6 = Type LongInt; 35 | TFTFixed = Type LongInt; 36 | 37 | TFTError = Integer; 38 | 39 | TFTErrorHelper = Record Helper For TFTError 40 | Public 41 | Function Base: Byte; Inline; 42 | Function Module: Word; Inline; 43 | Function Equals(Const AError: TFTError): Boolean; Inline; 44 | Function Inequals(Const AError: TFTError): Boolean; Inline; 45 | End; 46 | 47 | TFTUnitVector = Record 48 | X, Y: TFTF2Dot14; 49 | End; 50 | 51 | PFTMatrix = ^TFTMatrix; 52 | 53 | TFTMatrix = Record 54 | XX, XY, YX, YY: TFTFixed; 55 | End; 56 | 57 | TFTData = Record 58 | Pointer: PByte; 59 | Length: Integer; 60 | End; 61 | 62 | TFTGeneric = Record 63 | Data: Pointer; 64 | Finalizer: Procedure(AObject: Pointer); Cdecl; 65 | End; 66 | 67 | // List management 68 | PFTListNode = ^TFTListNode; 69 | 70 | TFTListNode = Record 71 | Prev, Next: PFTListNode; 72 | Data: Pointer; 73 | End; 74 | 75 | PFTList = ^TFTList; 76 | 77 | TFTList = Record 78 | Head, Tail: PFTListNode; 79 | 80 | Function IsEmpty: Boolean; Inline; 81 | End; 82 | {$ENDREGION} 83 | {$REGION 'ftsystem.h'} 84 | // System interface. How FreeType manages memory and i/o 85 | 86 | // Memory management 87 | PFTMemory = ^TFTMemory; 88 | 89 | TFTMemory = Record 90 | User: Pointer; 91 | AllocFunc: Function([Ref] Const AMemory: TFTMemory; Const ASize: LongInt): Pointer; Cdecl; 92 | FreeFunc: Procedure([Ref] Const AMemory: TFTMemory; Const ABlock: Pointer); Cdecl; 93 | ReallocFunc: Function([Ref] Const AMemory: TFTMemory; Const ACurSize, ANewSize: LongInt; Const ABlock: Pointer): Pointer; Cdecl; 94 | 95 | Function Alloc(Const ASize: LongInt): Pointer; Inline; 96 | Procedure Free(Const ABlock: Pointer); Inline; 97 | Function Realloc(Const ACurSize, ANewSize: LongInt; Const ABlock: Pointer): Pointer; Inline; 98 | End; 99 | 100 | // I/O management 101 | PFTStream = ^TFTStream; 102 | 103 | TFTStream = Record 104 | Strict Private 105 | Type 106 | TFTStreamDesc = Record 107 | Case Boolean Of 108 | False: 109 | (Value: LongInt); 110 | True: 111 | (Pointer: Pointer); 112 | End; 113 | Public 114 | Base: PByte; 115 | Size, Pos: LongWord; 116 | Strict Private 117 | FDescriptor: TFTStreamDesc; 118 | Public 119 | Property DescriptorInt: LongInt Read FDescriptor.Value Write FDescriptor.Value; 120 | Property DescriptorPointer: Pointer Read FDescriptor.Pointer Write FDescriptor.Pointer; 121 | Public 122 | Pathname: PAnsiChar; 123 | ReadFunc: Function(Var Stream: TFTStream; Const AOffset: LongWord; Var ABuffer; Const ACount: LongWord): LongWord; Cdecl; 124 | CloseFunc: Procedure(Var Stream: TFTStream); Cdecl; 125 | Strict Private 126 | {$HINTS OFF} 127 | Memory: PFTMemory; // internal, do not use 128 | Cursor, Limit: PByte; 129 | {$HINTS ON} 130 | Public 131 | Function Read(Const AOffset: LongWord; Var ABuffer; Const ACount: LongWord): LongWord; Inline; 132 | Procedure Close; Inline; 133 | End; 134 | {$ENDREGION} 135 | {$REGION 'ftcolor.h'} 136 | // Glyph Color Management 137 | 138 | PFTColor = ^TFTColor; 139 | 140 | TFTColor = Record 141 | Public 142 | Blue, Green, Red, Alpha: Byte; 143 | Constructor Mix(Const ABlue, AGreen, ARed, AAlpha: Byte); 144 | End; 145 | 146 | TFTPaletteFlag = (ftPaletteForLightBackground, ftPaletteForDarkBackground); 147 | TFTPaletteFlags = Set Of ftPaletteForLightBackground .. TFTPaletteFlag($F); 148 | 149 | TFTPaletteData = Record 150 | NumPalettes: Word; 151 | PaletteNameIds: Word; 152 | PaletteFlags: ^TFTPaletteFlags; 153 | NumPaletteEntries: Word; 154 | PaletteEntryNameIds: PWord; 155 | End; 156 | 157 | // Layer management 158 | TFTLayerIterator = Record 159 | NumLayers, Layer: Cardinal; 160 | P: PByte; 161 | End; 162 | {$ENDREGION} 163 | {$REGION 'ftimage.h'} 164 | 165 | // Basic types 166 | TFTPos = Type LongInt; 167 | 168 | PFTVector = ^TFTVector; 169 | 170 | TFTVector = Record 171 | X, Y: TFTPos; 172 | End; 173 | 174 | TFTBBox = Record 175 | XMin, YMin, XMax, YMax: TFTPos; 176 | End; 177 | 178 | TFTPixelMode = (ftpmNone, ftpmMono, ftpmGray, ftpmGray2, ftpmGray4, ftpmLcd, ftpmLcdV, ftpmBgra); 179 | 180 | PFTBitmap = ^TFTBitmap; 181 | 182 | TFTBitmap = Record 183 | Public 184 | Rows, Width: Cardinal; 185 | Pitch: Integer; 186 | Buffer: PByte; 187 | NumGrays: Word; 188 | PixelMode: TFTPixelMode; 189 | Strict Private 190 | {$HINTS OFF} 191 | FPaletteMode: Byte; 192 | FPalette: Pointer; 193 | {$HINTS ON} 194 | Function GetScanLine(Const ALine: Cardinal): PByte; Inline; 195 | Public 196 | Procedure Init; Inline; 197 | Procedure Copy(Var Target: TFTBitmap); Inline; 198 | Procedure Embolden(Const AXStrength, AYStrength: TFTPos); Inline; 199 | Procedure Convert(Var Target: TFTBitmap; Const Alignment: Integer); Inline; 200 | Procedure Blend(Const ASourceOffset: TFTVector; Var Target: TFTBitmap; Var TargetOffset: TFTVector; Const AColor: TFTColor); Inline; 201 | Procedure Done; Inline; 202 | 203 | Property ScanLine[Const ALine: Cardinal]: PByte Read GetScanLine; 204 | End; 205 | 206 | TFTOutlineFlag = (ftofOwner, ftofEvenOddFill, ftofReverseFill, ftofIgnoreDropouts, ftofSmartDropouts, ftofIncludeStubs, ftofOverlap, ftofHighPrecision = 8, ftofSinglePass); 207 | TFTOutlineFlags = Set Of ftofOwner .. TFTOutlineFlag($1F); 208 | 209 | TFTCurveTag = (ftctOn, ftctCubic, ftctHasScanmode, ftctTouchX, ftctTouchY); 210 | TFTCurveTags = Set Of ftctOn .. ftctTouchY; 211 | 212 | // bits 5-7 should contain the drop-out mode according to the OpenType specification (SCANMODE). 213 | // Probably this should be SCANTYPE? 214 | TFTCurveTagsHelper = Record Helper For TFTCurveTags 215 | Public Type 216 | TFTDropoutRules = Set Of 1 .. 6; 217 | Public 218 | Function GetDropoutMode: TFTDropoutRules; 219 | End; 220 | 221 | Const 222 | ftctTouchBoth = [ftctTouchX, ftctTouchY]; 223 | 224 | Type 225 | TFTOutline = Record 226 | Strict Private 227 | FNContours, FNPoints: SmallInt; 228 | FPoints: PFTVector; 229 | FTags: ^TFTCurveTags; 230 | FContourEndPoints: PSmallInt; 231 | Strict Private 232 | Function GetPoints: TArray; Inline; 233 | Function GetTags: TArray; Inline; 234 | Function GetContours: TArray; Inline; 235 | Public 236 | Property Points: TArray Read GetPoints; 237 | Property Tags: TArray Read GetTags; 238 | Property Contours: TArray Read GetContours; 239 | Public Const 240 | cOutlineContoursMax = High(SmallInt); 241 | cOutlinePointsMax = High(SmallInt); 242 | Public 243 | Flags: TFTOutlineFlags; 244 | End; 245 | 246 | TFTOutlineFuncs = Record 247 | MoveTo: Function([Ref] Const ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl; 248 | LineTo: Function([Ref] Const ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl; 249 | ConicTo: Function([Ref] Const AControl, ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl; 250 | CubicTo: Function([Ref] Const AControl1, AControl2, ATo: TFTVector; Const AUser: Pointer): Integer; Cdecl; 251 | Shift: Integer; 252 | Delta: TFTPos; 253 | End; 254 | 255 | TFTGlyphFormat = (ftgfNone = $00000000, ftgfComposite = $636F6D70 { comp } , ftgfBitmap = $62697473 { bits } , ftgfOutline = $6F75746C { outl } , ftgfPlotter = $706C6F74 { plot } ); 256 | 257 | // Raster definitions 258 | TFTSpan = Record 259 | X: SmallInt; 260 | Len: Word; 261 | Coverage: Byte; 262 | End; 263 | 264 | TFTRasterFlag = (ftrfAA, ftrfDirect, ftrfClip, ftrfSDF); 265 | TFTRasterFlags = Set Of ftrfAA .. TFTRasterFlag($1F); 266 | 267 | TFTRasterParams = Record 268 | Public 269 | Target: PFTBitmap; 270 | Source: Pointer; 271 | Flags: TFTRasterFlags; 272 | Strict Private 273 | {$HINTS OFF} 274 | FGraySpans, FBlackSpans: Procedure(Const AY, ACount: Integer; [Ref] Const ASpans: TFTSpan; Const AUser: Pointer); Cdecl; 275 | FBitTest: Function(Const AY, AX: Integer; Const AUser: Pointer): Integer; Cdecl; 276 | FBitSet: Procedure(Const AY, AX: Integer; Const AUser: Pointer); Cdecl; 277 | {$HINTS ON} 278 | Public 279 | User: Pointer; 280 | ClipBox: TFTBBox; 281 | End; 282 | 283 | TFTRaster = Record 284 | // internal type 285 | End; 286 | 287 | TFTRasterFuncs = Record 288 | Public 289 | GlyphFormat: TFTGlyphFormat; 290 | RasterNew: Function([Ref] Const AMemory: TFTMemory; Out ORaster: TFTRaster): Integer; Cdecl; 291 | RasterReset: Procedure(Const ARaster: TFTRaster; Const APoolBase: PByte; Const APoolSize: LongWord); Cdecl; 292 | RasterSetMode: Function(Const ARaster: TFTRaster; Const AMode: LongWord; Const AArgs: Pointer): Integer; Cdecl; 293 | RasterRender: Function(Const ARaster: TFTRaster; [Ref] Const AParams: TFTRasterParams): Integer; Cdecl; 294 | RasterDone: Procedure(Const ARaster: TFTRaster); Cdecl; 295 | End; 296 | {$ENDREGION} 297 | {$REGION 'ftcolor.h experimental interface'} 298 | 299 | // experimental interface 300 | TFTPaintFormat = (ftpfColrLayers = 1, ftpfSolid = 2, ftpfLinearGradient = 4, ftptRadialGradient = 6, ftptSweepGradient = 8, ftpfGlyph = 10, ftpfColrGlyph = 11, ftpfTransform = 12, 301 | ftpfTranslate = 14, ftpfScale = 16, ftpfRotate = 24, ftpfSkew = 28, ftpfComposite = 32, ftpfFormatMax = 33, ftpfUnsupported = 255); 302 | 303 | TFTColorStopIterator = Record 304 | NumColorStops, CurrentColorStop: Cardinal; 305 | P: PByte; 306 | End; 307 | 308 | TFTColorIndex = Record 309 | PaletteIndex: Word; 310 | Alpha: TFTF2Dot14; 311 | End; 312 | 313 | TFTColorStop = Record 314 | StopOffset: TFTF2Dot14; 315 | Color: TFTColorIndex; 316 | End; 317 | 318 | TFTPaintExtend = (ftpePad, ftpeRepeat, ftpeReflect); 319 | 320 | TFTColorLine = Record 321 | Extend: TFTPaintExtend; 322 | ColorStopIterator: TFTColorStopIterator; 323 | End; 324 | 325 | TFTAffine23 = Record 326 | XX, XY, dX, YX, YY, dY: TFTFixed; 327 | End; 328 | 329 | TFTCompositeMode = (ftcmClear, ftcmSrc, ftcmDest, ftcmSrcOver, ftcmDestOver, ftcmSrcIn, ftcmDestIn, ftcmSrcOut, ftcmDestOut, ftcmSrcAtop, ftcmDestAtop, ftcmXor, ftcmScreen, ftcmOverlay, ftcmDarken, 330 | ftcmLighten, ftcmColorDodge, ftcmColorBurn, ftcmHardLight, ftcmSoftLight, ftcmDifference, ftcmExclusion, ftcmMultiply, ftcmHSLHue, ftcmHSLSaturation, ftcmHSLColor, ftcmHSLLuminosity, ftcmMAX); 331 | 332 | TFTOpaquePaint = Record 333 | P: PByte; 334 | InsertRootTransform: ByteBool; 335 | End; 336 | 337 | TFTPaintColrLayers = Record 338 | LayerIterator: TFTLayerIterator; 339 | End; 340 | 341 | TFTPaintSolid = Record 342 | Color: TFTColorIndex; 343 | End; 344 | 345 | TFTPaintLinearGradient = Record 346 | ColorLine: TFTColorLine; 347 | P0, P1, P2: TFTVector; 348 | End; 349 | 350 | TFTPaintRadialGradient = Record 351 | ColorLine: TFTColorLine; 352 | C0: TFTVector; 353 | R0: Word; 354 | C1: TFTVector; 355 | R1: Word; 356 | End; 357 | 358 | TFTPaintSweepGradient = Record 359 | ColorLine: TFTColorLine; 360 | Center: TFTVector; 361 | StartAngle, EndAngle: TFTFixed; 362 | End; 363 | 364 | TFTPaintGlyph = Record 365 | Paint: TFTOpaquePaint; 366 | GlyphID: Cardinal; 367 | End; 368 | 369 | TFTPaintColrGlyph = Record 370 | GlyphID: Cardinal; 371 | End; 372 | 373 | TFTPaintTransform = Record 374 | Paint: TFTOpaquePaint; 375 | Affine: TFTAffine23; 376 | End; 377 | 378 | TFTPaintTranslate = Record 379 | Paint: TFTOpaquePaint; 380 | dX, dY: TFTFixed; 381 | End; 382 | 383 | TFTPaintScale = Record 384 | Paint: TFTOpaquePaint; 385 | ScaleX, ScaleY, CenterX, CenterY: TFTFixed; 386 | End; 387 | 388 | TFTPaintRotate = Record 389 | Paint: TFTOpaquePaint; 390 | Angle, CenterX, CenterY: TFTFixed; 391 | End; 392 | 393 | TFTPaintSkew = Record 394 | Paint: TFTOpaquePaint; 395 | XSkewAngle, YSkewAngle, CenterX, CenterY: TFTFixed; 396 | End; 397 | 398 | TFTPaintComposite = Record 399 | SourcePaint: TFTOpaquePaint; 400 | CompositeMode: TFTCompositeMode; 401 | BackdropPaint: TFTOpaquePaint; 402 | End; 403 | 404 | TFTColrPaint = Record 405 | Format: TFTPaintFormat; 406 | Case Byte Of 407 | 0: 408 | (ColrLayers: TFTPaintColrLayers); 409 | 1: 410 | (Glyph: TFTPaintGlyph); 411 | 2: 412 | (Solid: TFTPaintSolid); 413 | 3: 414 | (LinearGradient: TFTPaintLinearGradient); 415 | 4: 416 | (RadialGradient: TFTPaintRadialGradient); 417 | 5: 418 | (SweepGradient: TFTPaintSweepGradient); 419 | 6: 420 | (Transform: TFTPaintTransform); 421 | 7: 422 | (Translate: TFTPaintTranslate); 423 | 8: 424 | (Scale: TFTPaintScale); 425 | 9: 426 | (Rotate: TFTPaintRotate); 427 | 10: 428 | (Skew: TFTPaintSkew); 429 | 11: 430 | (Composite: TFTPaintComposite); 431 | 12: 432 | (ColrGlyph: TFTPaintColrGlyph); 433 | End; 434 | 435 | TFTColorRootTransform = (ftrtIncludeRootTransform, ftrtNoRootTransform, ftrtRootTransformMax); 436 | {$ENDREGION} 437 | {$REGION 'ftlcdfil.h'} 438 | // Subpixel Rendering 439 | 440 | TFTLcdFilter = (ftlcdfNone = 0, ftlcdfDefault = 1, ftlcdfLight = 2, ftlcdfLegacy1 = 3, ftlcdfLegacy = 16); 441 | 442 | TFTLCDFiveTapFilter = Array [0 .. 4] Of Byte; 443 | 444 | TFTLCDThreeVecs = Array [0 .. 2] Of TFTVector; 445 | {$ENDREGION} 446 | {$REGION 'freetype.h'} 447 | 448 | // Base interface 449 | TFTGlyphMetrics = Record 450 | Width, Height: TFTPos; 451 | HorzBearingX, HorzBearingY, HorzAdvance: TFTPos; 452 | VertBearingX, VertBearingY, VertAdvance: TFTPos; 453 | End; 454 | 455 | PFTBitmapSize = ^TFTBitmapSize; 456 | 457 | TFTBitmapSize = Record 458 | Height, Width: SmallInt; 459 | Size, XPpEM, YPpEM: TFTPos; 460 | End; 461 | 462 | // Object classes 463 | TFTLibrary = Record 464 | Strict Private 465 | {$HINTS OFF} 466 | FValue: Pointer; 467 | {$HINTS ON} 468 | // internal type 469 | End; 470 | 471 | TFTModule = Record 472 | Strict Private 473 | {$HINTS OFF} 474 | FValue: Pointer; 475 | {$HINTS ON} 476 | // internal type 477 | End; 478 | 479 | TFTDriver = Record 480 | Strict Private 481 | {$HINTS OFF} 482 | FValue: Pointer; 483 | {$HINTS ON} 484 | // internal type 485 | End; 486 | 487 | TFTRenderer = Record 488 | Strict Private 489 | {$HINTS OFF} 490 | FValue: Pointer; 491 | {$HINTS ON} 492 | // internal type 493 | End; 494 | 495 | PFTSize = ^TFTSize; 496 | 497 | PFTGlyphSlot = ^TFTGlyphSlot; 498 | 499 | PFTCharMap = ^TFTCharMap; 500 | 501 | TFTEncoding = (fteNone = $00000000, fteMsSymbol = $73796D62 { symb } , fteUnicode = $756E6963 { unic } , fteSjis = $736A6973 { sjis } , ftePrc = $67622020 { gb } , fteBig5 = $62696735 { big5 } , 502 | fteWansung = $77616E73 { wans } , fteJohab = $6A6F6861 { joha } , 503 | // for backward compatibility 504 | fteGb2312 = ftePrc, fteMsSjis = fteSjis, fteMsGb2312 = ftePrc, fteMsBig5 = fteBig5, fteMsWansung = fteWansung, fteMsJohab = fteJohab, fteAdobeStandard = $41444F42 { ADOB } , 505 | fteAdobeExpert = $41444245 { ADBE } , fteAdobeCustom = $41444243 { ADBC } , fteAdobeLatin1 = $6C617431 { lat1 } , fteOldLatin2 = $6C617432 { lat2 } , fteAppleRoman = $61726D6E { armn } 506 | ); 507 | 508 | TFTCharMap = Record 509 | Strict Private 510 | {$HINTS OFF} 511 | FFace: Pointer; 512 | {$HINTS ON} 513 | Public 514 | Encoding: TFTEncoding; 515 | PlatformID, EncodingID: Word; 516 | Function GetCharMapIndex: Integer; Inline; 517 | End; 518 | 519 | // Base object classes 520 | TFTFaceFlag = (ftffScalable, ftffFixedSizes, ftffFixedWidth, ftffSFNT, ftffHorizontal, ftffVertical, ftffKerning, ftffFastGlyphs, ftffMultipleMasters, ftffGlyphNames, ftffExternalStream, 521 | ftffHinter, ftffCIDKeyed, ftffTricky, ftffColor, ftffVariation); 522 | TFTFaceFlags = Set Of ftffScalable .. TFTFaceFlag(8 * SizeOf(LongInt) - 1); 523 | 524 | TFTStyleFlag = (ftsfItalic, ftsfBold); 525 | TFTStyleFlags = ftsfItalic .. TFTStyleFlag(8 * SizeOf(LongInt) - 1); 526 | 527 | TFTStyleFlagsHelper = Record Helper For TFTStyleFlags 528 | Public 529 | Function CountNamedInstances: Cardinal; Inline; 530 | End; 531 | 532 | TFTSizeRequestType = (ftsrtNominal, ftsrtRealDim, ftsrtBBox, ftsrtCell, ftsrtScales); 533 | 534 | TFTSizeRequest = Record 535 | &Type: TFTSizeRequestType; 536 | Width, Height: LongInt; 537 | HorzResolution, VertResolution: Cardinal; 538 | End; 539 | 540 | TFTLoadFlag = (ftlfNoScale, ftlfNoHinting, ftlfRender, ftlfNoBitmap, ftlfVerticalLayout, ftlfForceAutohint, ftlfCropBitmap, ftlfPedantic, ftlfAdvanceOnly, ftlfIgnoreGlobalAdvanceWidth, 541 | ftlfNoRecurse, ftlfIgnoreTransform, ftlfMonochrome, ftlfLinearDesign, ftlfSbitsOnly, ftlfNoAutohint, ftlfTargetLight, ftlfTargetMono, ftlfTargetLCD, ftlfTargetLCDV, ftlfColor, 542 | ftlfComputeMetrics, ftlfBitmapMetricsOnly); 543 | TFTLoadFlags = Set Of ftlfNoScale .. TFTLoadFlag($1F); 544 | 545 | TFTRenderMode = (ftrmNormal, ftrmLight, ftrmMono, ftrmLcd, ftrmLcdV, ftrmSDF); 546 | 547 | TFTLoadFlagsHelper = Record Helper For TFTLoadFlags 548 | Strict Private 549 | Function GetTargetMode: TFTRenderMode; Inline; 550 | Procedure SetTargetMode(Const AMode: TFTRenderMode); Inline; 551 | Public 552 | Property TargetMode: TFTRenderMode Read GetTargetMode Write SetTargetMode; 553 | End; 554 | 555 | {$Z4} 556 | 557 | TFTKerningMode = (ftkDefault, ftkUnfitted, ftkUnscaled); 558 | {$Z1} 559 | 560 | TFTFSType = Record 561 | Public Type 562 | TFTFSTypeEmbedding = (ftfseInstallableEmbedding = $0, ftfseRestrictedLicenseEmbedding = $2, ftfsePreviewAndPrintEmbedding = $4, ftfseEditableEmbedding = $8); 563 | TFTFSTypeFlag = (ftfsfNoSubsetting, ftfsfBitmapEmbeddingOnly); 564 | TFTFSTypeFlags = Set Of TFTFSTypeFlag; 565 | Strict Private 566 | FValue: Word; 567 | Function GetEmbedding: TFTFSTypeEmbedding; Inline; 568 | Function GetFlags: TFTFSTypeFlags; Inline; 569 | Public 570 | Property Embedding: TFTFSTypeEmbedding Read GetEmbedding; 571 | Property Flags: TFTFSTypeFlags Read GetFlags; 572 | End; 573 | 574 | TFTFace = Record 575 | Strict Private 576 | Type 577 | TFTFaceRec = Record 578 | NumFaces, FaceIndex: LongInt; 579 | FaceFlags: TFTFaceFlags; 580 | StyleFlags: TFTStyleFlags; 581 | NumGlyphs: LongInt; 582 | FamilyName, StyleName: PAnsiChar; 583 | NumFixedSizes: Integer; 584 | AvailableSizes: PFTBitmapSize; 585 | NumCharMaps: Integer; 586 | CharMaps: PFTCharMap; 587 | Generic: TFTGeneric; 588 | // properties for scalable outlines 589 | BBox: TFTBBox; 590 | UnitsPerEM: Word; 591 | Ascender, Descender, Height: SmallInt; 592 | MaxAdvanceWidth, MaxAdvanceHeight: SmallInt; 593 | UnderlinePosition, UnderlineThickness: SmallInt; 594 | Glyph: PFTGlyphSlot; 595 | Size: PFTSize; 596 | CharMap: PFTCharMap; 597 | FDriver: TFTDriver; 598 | FMemory: PFTMemory; 599 | FStream: PFTStream; 600 | FSizesList: TFTList; 601 | FAutohint: TFTGeneric; 602 | FExtensions, FInternal: Pointer; 603 | End; 604 | Strict Private 605 | FValue: ^TFTFaceRec; 606 | Function GetNumFaces_: LongInt; Inline; 607 | Function GetFaceIndex: LongInt; Inline; 608 | Function GetFaceFlags: TFTFaceFlags; Inline; 609 | Function GetStyleFlags_: TFTStyleFlags; Inline; 610 | Function GetNumGlyphs: LongInt; Inline; 611 | Function GetFamilyName: AnsiString; Inline; 612 | Function GetStyleName: AnsiString; Inline; 613 | Function GetAvailableSizes: TArray; 614 | Function GetCharMaps: TArray; Inline; 615 | Function GetGeneric: TFTGeneric; Inline; 616 | Procedure SetGeneric(Const AValue: TFTGeneric); Inline; 617 | Function GetBBox: TFTBBox; Inline; 618 | Function GetUnitsPerEM: Word; Inline; 619 | Function GetAscender: SmallInt; Inline; 620 | Function GetDescender: SmallInt; Inline; 621 | Function GetHeight: SmallInt; Inline; 622 | Function GetMaxAdvanceWidth: SmallInt; Inline; 623 | Function GetMaxAdvanceHeight: SmallInt; Inline; 624 | Function GetUnderlinePosition: SmallInt; Inline; 625 | Function GetUnderlineThickness: SmallInt; Inline; 626 | Function GetGlyph: PFTGlyphSlot; Inline; 627 | Function GetSize: PFTSize; Inline; 628 | Function GetCharMap: PFTCharMap; Inline; 629 | Function GetDriverName: AnsiString; Inline; 630 | Public Type 631 | TColorGlyphLayerItem = Record 632 | GlyphIndex, ColorIndex: Cardinal; 633 | End; 634 | 635 | TFTCharVariantDefault = (ftcvdStandardCMap = 1, ftcsdVariationSelectorCMap = 0, ftcsdNoVariation = Integer( -1)); 636 | 637 | PPaletteArray = ^TPaletteArray; 638 | TPaletteArray = Packed Array [0 .. 0] Of TFTColor; 639 | Public 640 | Function IsNamedInstance: Boolean; Inline; 641 | 642 | Class Function Create(Const AFile: AnsiString; Const AFaceIndex: Word; Const ANamedInstanceIndex: Word = 0): TFTFace; Overload; Static; 643 | Class Function Create(Const AData: Pointer; Const ASize: Cardinal; Const AFaceIndex: Word; Const ANamedInstanceIndex: Word = 0): TFTFace; Overload; Static; 644 | Procedure Destroy; 645 | 646 | Class Function GetNumFaces(Const AFile: AnsiString): Integer; Overload; Static; 647 | Class Function GetNumFaces(Const AData: Pointer; Const ASize: Cardinal): Integer; Overload; Static; 648 | Class Function GetStyleFlags(Const AFile: AnsiString; Const AFaceIndex: Word): TFTStyleFlags; Overload; Static; 649 | Class Function GetStyleFlags(Const AData: Pointer; Const ASize: Cardinal; Const AFaceIndex: Word): TFTStyleFlags; Overload; Static; 650 | 651 | Procedure SelectSize(Const AStrikeIndex: Integer); Inline; 652 | Procedure RequestSize(Const ARequest: TFTSizeRequest); Overload; Inline; 653 | Procedure RequestSize(Const AType: TFTSizeRequestType; Const AWidth, AHeight: LongInt; Const AHorzResolution, AVertResolution: Cardinal); Overload; 654 | Procedure SetCharSize(Const ACharWidth, ACharHeight: TFTF26Dot6; Const AHorzResolution, AVertResolution: Cardinal); Inline; 655 | Procedure SetPixelSize(Const APixelWidth, APixelHeight: Cardinal); Inline; 656 | 657 | Procedure LoadGlyph(Const AGlyphIndex: Cardinal; Const ALoadFlags: TFTLoadFlags = []); Inline; 658 | Procedure LoadChar(Const ACharCode: LongWord; Const ALoadFlags: TFTLoadFlags = []); Inline; 659 | 660 | Procedure ClearTransform; Inline; 661 | Procedure SetTransform(Const AMatrix: TFTMatrix); Overload; Inline; 662 | Procedure SetTransform(Const ADelta: TFTVector); Overload; Inline; 663 | Procedure SetTransform(Const AMatrix: TFTMatrix; Const ADelta: TFTVector); Overload; Inline; 664 | Procedure GetTransform(Out OMatrix: TFTMatrix); Overload; Inline; 665 | Procedure GetTransform(Out ODelta: TFTVector); Overload; Inline; 666 | Procedure GetTransform(Out OMatrix: TFTMatrix; Out ODelta: TFTVector); Overload; Inline; 667 | 668 | Function GetKerning(Const ALeftGlyph, ARightGlyph: Cardinal; Const AKernMode: TFTKerningMode): TFTVector; Inline; 669 | Function GetTrackKerning(Const APointSize: TFTFixed; Const ADegree: Integer): TFTFixed; Inline; 670 | 671 | Function GetGlyphName(Const AGlyphIndex: Cardinal): AnsiString; 672 | Function GetPostscriptName: AnsiString; Inline; 673 | 674 | Procedure SelectCharMap(Const AEncoding: TFTEncoding); Inline; 675 | Procedure SetCharMap(Var CharMap: TFTCharMap); Inline; 676 | 677 | Function GetCharIndex(Const ACharCode: LongWord): Cardinal; Inline; 678 | Function GetFirstChar(Out OGlyphIndex: Cardinal): LongWord; Inline; 679 | Function GetNextChar(Const ACharCode: LongWord; Out OGlyphIndex: Cardinal): LongWord; Inline; 680 | 681 | Procedure Properties(Const AStemDarkening: ByteBool); Overload; Inline; 682 | Procedure Properties(Const ALCDFilterWeights: TFTLCDFiveTapFilter); Overload; Inline; 683 | Procedure Properties(Const ARandomSeed: Integer); Overload; Inline; 684 | Procedure Properties(Const AStemDarkening: ByteBool; Const ALCDFilterWeights: TFTLCDFiveTapFilter); Overload; 685 | Procedure Properties(Const AStemDarkening: ByteBool; Const ARandomSeed: Integer); Overload; 686 | Procedure Properties(Const ALCDFilterWeights: TFTLCDFiveTapFilter; Const ARandomSeed: Integer); Overload; 687 | Procedure Properties(Const AStemDarkening: ByteBool; Const ALCDFilterWeights: TFTLCDFiveTapFilter; Const ARandomSeed: Integer); Overload; 688 | 689 | Function GetNameIndex(Const GlyphName: AnsiString): Cardinal; Inline; 690 | Function GetColorGlyphLayers(Const ABaseGlyph: Cardinal): TArray; 691 | Function GetFSTypeFlags: TFTFSType; Inline; 692 | 693 | Function GetCharVariantIndex(Const ACharCode, AVariantSelector: LongWord): Cardinal; Inline; 694 | Function GetCharVariantIsDefault(Const ACharCode, AVariantSelector: LongWord): TFTCharVariantDefault; Inline; 695 | Function GetVariantSelectors: TArray; 696 | Function GetVariantsOfChar(Const ACharCode: LongWord): TArray; 697 | Function GetCharsOfVariant(Const AVariantSelector: LongWord): TArray; 698 | 699 | Function GetPalette: TFTPaletteData; Inline; 700 | Function SelectPalette(Const APaletteIndex: Word): PPaletteArray; Inline; 701 | Procedure SetForegroundColor(Const AForegroundColor: TFTColor); Inline; 702 | 703 | Function GetColorGlyphPaint(Const ABaseGlyph: Cardinal; Const ARootTransform: TFTColorRootTransform): TFTOpaquePaint; Inline; 704 | Function GetPaintLayers: TArray; 705 | Function GetColorLineStops: TArray; 706 | Function GetPaint(Const AOpaquePaint: TFTOpaquePaint): TFTColrPaint; Inline; 707 | 708 | Property NumFaces: LongInt Read GetNumFaces_; 709 | Property FaceIndex: LongInt Read GetFaceIndex; 710 | Property FaceFlags: TFTFaceFlags Read GetFaceFlags; 711 | Property StyleFlags: TFTStyleFlags Read GetStyleFlags_; 712 | Property NumGlyphs: LongInt Read GetNumGlyphs; 713 | Property FamilyName: AnsiString Read GetFamilyName; 714 | Property StyleName: AnsiString Read GetStyleName; 715 | Property AvailableSizes: TArray Read GetAvailableSizes; 716 | Property CharMaps: TArray Read GetCharMaps; 717 | Property Generic: TFTGeneric Read GetGeneric Write SetGeneric; 718 | Property BBox: TFTBBox Read GetBBox; 719 | Property UnitsPerEM: Word Read GetUnitsPerEM; 720 | Property Ascender: SmallInt Read GetAscender; 721 | Property Descender: SmallInt Read GetDescender; 722 | Property Height: SmallInt Read GetHeight; 723 | Property MaxAdvanceWidth: SmallInt Read GetMaxAdvanceWidth; 724 | Property MaxAdvanceHeight: SmallInt Read GetMaxAdvanceHeight; 725 | Property UnderlinePosition: SmallInt Read GetUnderlinePosition; 726 | Property UnderlineThickness: SmallInt Read GetUnderlineThickness; 727 | Property Glyph: PFTGlyphSlot Read GetGlyph; 728 | Property Size: PFTSize Read GetSize; 729 | Property CharMap: PFTCharMap Read GetCharMap; 730 | Property DriverName: AnsiString Read GetDriverName; 731 | End; 732 | 733 | TFTSizeMetrics = Record 734 | XPpEM, YPpEM: Word; 735 | XScale, YScale: TFTFixed; 736 | Ascender, Descender, Height, MaxAdvance: TFTPos; 737 | End; 738 | 739 | TFTSize = Record 740 | Public 741 | Face: TFTFace; 742 | Generic: TFTGeneric; 743 | Metrics: TFTSizeMetrics; 744 | Strict Private 745 | {$HINTS OFF} 746 | FInternal: Pointer; 747 | {$HINTS ON} 748 | End; 749 | 750 | TFTSubGlyphFlag = (ftsgfArgsAreWords, ftsgfArgsAreXyValues, ftsgfRoundXyToGrid, ftsgfScale, ftsgfXyScale = 6, ftsgf2x2, ftsgfUseMyMetrics = 9); 751 | TFTSubGlyphFlags = Set Of ftsgfArgsAreWords .. TFTSubGlyphFlag($1F); 752 | 753 | TFTGlyphSlot = Record 754 | Public 755 | &Library: TFTLibrary; 756 | Face: TFTFace; 757 | Next: PFTGlyphSlot; 758 | GlyphIndex: Cardinal; 759 | Generic: TFTGeneric; 760 | Metrics: TFTGlyphMetrics; 761 | LinearHorzAdvance, LinearVertAdvance: TFTFixed; 762 | Advance: TFTVector; 763 | Format: TFTGlyphFormat; 764 | Bitmap: TFTBitmap; 765 | BitmapLeft, BitmapTop: Integer; 766 | Outline: TFTOutline; 767 | NumSubGlyphs: Cardinal; 768 | Strict Private {$HINTS OFF} 769 | FSubGlyphs, FControlData: Pointer; 770 | FControlLen: Integer; {$HINTS ON} 771 | Public 772 | LsbDelta, RsbDelta: TFTPos; 773 | Strict Private {$HINTS OFF} 774 | FOther, FInternal: Pointer; 775 | {$HINTS ON} 776 | Public 777 | Procedure RenderGlyph(Const ARenderMode: TFTRenderMode); Inline; 778 | Procedure SubGlyphInfo(Const SubIndex: Cardinal; Out OIndex: Integer; Out OFlags: TFTSubGlyphFlags; Out OArg1, OArg2: Integer; Out OTransform: TFTMatrix); Inline; 779 | Procedure OwnBitmap; Inline; 780 | End; 781 | 782 | // Functions 783 | TFTOpenFlag = (ftofMemory, ftofStream, ftofPathname, ftofDriver, ftofParams); 784 | TFTOpenFlags = ftofMemory .. TFTOpenFlag($1F); 785 | 786 | TFTParameterTag = (ftptIgnoreTypographicFamily = $69677066 { igpf } , ftptIgnoreTypographicSubfamily = $69677073 { igps } , ftptIncremental = $696E6372 { incr } , 787 | ftptLCDFilterWeights = $6C636466 { lcdf } , ftptRandomSeed = $73656564 { seed } , ftptStemDarkening = $6461726B { dark } , ftptUnpatentedHinting = $756E7061 { unpa } ); 788 | 789 | PFTParameter = ^TFTParameter; 790 | 791 | TFTParameter = Record 792 | Tag: TFTParameterTag; 793 | Data: Pointer; 794 | End; 795 | 796 | TFTOpenArgs = Record 797 | Flags: TFTOpenFlags; 798 | MemoryBase: PByte; 799 | MemorySize: LongInt; 800 | Pathname: PAnsiChar; 801 | Stream: PFTStream; 802 | Driver: TFTModule; 803 | NumParams: Integer; 804 | Params: PFTParameter; 805 | End; 806 | {$ENDREGION} 807 | {$REGION 'ftmodapi.h'} 808 | 809 | // Module Management 810 | TFTModuleFlag = (ftmfFontDriver, ftmfRenderer, ftmfHinter, ftmfStyler, ftmfDriverScalable = 8, ftmfDriverNoOutlines, ftmfDriverHasHinter, ftmfDriverHintsLightly); 811 | TFTModuleFlags = Set Of ftmfFontDriver .. TFTModuleFlag(8 * SizeOf(LongWord) - 1); 812 | 813 | PFTModuleInterface = Pointer; 814 | 815 | TFTModuleClass = Record 816 | ModuleFlags: TFTModuleFlags; 817 | ModuleSize: LongInt; 818 | ModuleName: PAnsiChar; 819 | ModuleVersion, ModuleRequires: TFTFixed; 820 | ModuleInterface: PFTModuleInterface; 821 | ModuleInit: Function(Module: TFTModule): TFTError; Cdecl; 822 | ModuleDone: Procedure(Module: TFTModule); Cdecl; 823 | GetInterface: Function(Const Module: TFTModule; Const Name: PAnsiChar): PFTModuleInterface; Cdecl; 824 | End; 825 | 826 | TFTDebugHookFunc = Function(Const AArg: Pointer): TFTError; Cdecl; 827 | 828 | {$Z4} 829 | TFTDebugHook = (ftdhTrueType); 830 | {$Z1} 831 | TFTTrueTypeEngineType = (fttteNone, fttteUnpatented, ftttePatented); 832 | {$ENDREGION} 833 | 834 | TFTManager = Class Abstract 835 | Strict Private 836 | Class Var FLibrary: TFTLibrary; 837 | Class Var FMajor, FMinor, FPatch: Integer; 838 | 839 | Class Function MemAlloc([Ref] Const AMemory: TFTMemory; Const ASize: Integer): Pointer; Static; Cdecl; 840 | Class Procedure MemFree([Ref] Const AMemory: TFTMemory; Const ABlock: Pointer); Static; Cdecl; 841 | Class Function MemRealloc([Ref] Const AMemory: TFTMemory; Const ACurSize, ANewSize: Integer; Const ABlock: Pointer): Pointer; Static; Cdecl; 842 | 843 | Const 844 | sError = 'The error %d occured in a FreeType call: %s.'; 845 | FREETYPE_MAJOR = 2; 846 | FREETYPE_MINOR = 11; 847 | FREETYPE_PATCH = 0; 848 | cMem: TFTMemory = (User: NIL; AllocFunc: TFTManager.MemAlloc; FreeFunc: TFTManager.MemFree; ReallocFunc: TFTManager.MemRealloc); 849 | Private 850 | Class Procedure Initialize; Static; 851 | Class Procedure Finalize; Static; 852 | Public 853 | Class Procedure Error(Const AErrorCode: TFTError); Static; // Inline; 854 | Class Property &Library: TFTLibrary Read FLibrary; 855 | 856 | Class Property MajorVersion: Integer Read FMajor; 857 | Class Property MinorVersion: Integer Read FMinor; 858 | Class Property PatchVersion: Integer Read FPatch; 859 | End; 860 | 861 | {$REGION 'fterrors.h'} 862 | 863 | Function FT_Error_String(Const AErrorCode: TFTError): PAnsiChar; Cdecl; External FreeTypeDLL; 864 | {$ENDREGION} 865 | {$REGION 'ftlcdfil.h'} 866 | Function FT_Library_SetLcdFilter(&Library: TFTLibrary; Const AFilter: TFTLcdFilter): TFTError; Cdecl; External FreeTypeDLL; 867 | Function FT_Library_SetLcdFilterWeights(&Library: TFTLibrary; [Ref] Const AWeights: TFTLCDFiveTapFilter): TFTError; Cdecl; External FreeTypeDLL; 868 | Function FT_Library_SetLcdGeometry(&Library: TFTLibrary; [Ref] Const ASub: TFTLCDThreeVecs): TFTError; Cdecl; External FreeTypeDLL; 869 | {$ENDREGION} 870 | {$REGION 'freetype.h'} 871 | Function FT_Init_FreeType(Out OLibrary: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL; 872 | Function FT_Done_FreeType(&Library: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL; 873 | Function FT_New_Face(Const ALibrary: TFTLibrary; Const AFilePathName: PAnsiChar; Const AFaceIndex: LongInt; Out AFace: TFTFace): TFTError; Cdecl; External FreeTypeDLL; 874 | Function FT_New_Memory_Face(Const ALibrary: TFTLibrary; Const AFileBase: PByte; Const AFileSize, AFaceIndex: LongInt; Out OFace: TFTFace): TFTError; Cdecl; External FreeTypeDLL; 875 | Function FT_Open_Face(Const ALibrary: TFTLibrary; [Ref] Const AArgs: TFTOpenArgs; Const FaceIndex: LongInt; Out OFace: TFTFace): TFTError; Cdecl; External FreeTypeDLL; 876 | Function FT_Attach_File(Face: TFTFace; Const AFilePathName: PAnsiChar): TFTError; Cdecl; External FreeTypeDLL; 877 | Function FT_Attach_Stream(Face: TFTFace; [Ref] Const AParameters: TFTOpenArgs): TFTError; Cdecl; External FreeTypeDLL; 878 | Function FT_Reference_Face(Face: TFTFace): TFTError; Cdecl; External FreeTypeDLL; 879 | Function FT_Done_Face(Face: TFTFace): TFTError; Cdecl; External FreeTypeDLL; 880 | Function FT_Select_Size(Face: TFTFace; Const AStrikeIndex: Integer): TFTError; Cdecl; External FreeTypeDLL; 881 | Function FT_Request_Size(Face: TFTFace; [Ref] Const AReq: TFTSizeRequest): TFTError; Cdecl; External FreeTypeDLL; 882 | Function FT_Set_Char_Size(Face: TFTFace; Const ACharWidth, ACharHeight: TFTF26Dot6; Const AHorzResolution, AVertResolution: Cardinal): TFTError; Cdecl; External FreeTypeDLL; 883 | Function FT_Set_Pixel_Sizes(Face: TFTFace; Const APixelWidth, APixelHeight: Cardinal): TFTError; Cdecl; External FreeTypeDLL; 884 | Function FT_Load_Glyph(Face: TFTFace; Const AGlyphIndex: Cardinal; Const ALoadFlags: TFTLoadFlags): TFTError; Cdecl; External FreeTypeDLL; 885 | Function FT_Load_Char(Face: TFTFace; Const ACharCode: LongWord; Const ALoadFlags: TFTLoadFlags): TFTError; Cdecl; External FreeTypeDLL; 886 | Procedure FT_Set_Transform(Face: TFTFace; Const AMatrix: PFTMatrix; Const ADelta: PFTVector); Cdecl; External FreeTypeDLL; 887 | Procedure FT_Get_Transform(Const AFace: TFTFace; OMatrix: PFTMatrix; ODelta: PFTVector); Cdecl; External FreeTypeDLL; 888 | Function FT_Render_Glyph(Var Slot: TFTGlyphSlot; Const RenderMode: TFTRenderMode): TFTError; Cdecl; External FreeTypeDLL; 889 | Function FT_Get_Kerning(Const AFace: TFTFace; Const ALeftGlyph, ARightGlyph: Cardinal; Const AKernMode: TFTKerningMode; Out OKerning: TFTVector): TFTError; Cdecl; External FreeTypeDLL; 890 | Function FT_Get_Track_Kerning(Const AFace: TFTFace; Const APointSize: TFTFixed; Const ADegree: Integer; Out OKerning: TFTFixed): TFTError; Cdecl; External FreeTypeDLL; 891 | Function FT_Get_Glyph_Name(Const AFace: TFTFace; Const AGlyphIndex: Cardinal; Const ABuffer: Pointer; Const ABufferMax: Cardinal): TFTError; Cdecl; External FreeTypeDLL; 892 | Function FT_Get_Postscript_Name(Const AFace: TFTFace): PAnsiChar; Cdecl; External FreeTypeDLL; 893 | Function FT_Select_Charmap(Face: TFTFace; Const AEncoding: TFTEncoding): TFTError; Cdecl; External FreeTypeDLL; 894 | Function FT_Set_Charmap(Face: TFTFace; Var CharMap: TFTCharMap): TFTError; Cdecl; External FreeTypeDLL; 895 | Function FT_Get_Charmap_Index([Ref] Const ACharmap: TFTCharMap): Integer; Cdecl; External FreeTypeDLL; 896 | Function FT_Get_Char_Index(Const AFace: TFTFace; Const ACharCode: LongWord): Cardinal; Cdecl; External FreeTypeDLL; 897 | Function FT_Get_First_Char(Const AFace: TFTFace; Out OGlyphIndex: Cardinal): LongWord; Cdecl; External FreeTypeDLL; 898 | Function FT_Get_Next_Char(Const AFace: TFTFace; Const ACharCode: LongWord; Out OGlyphIndex: Cardinal): LongWord; Cdecl; External FreeTypeDLL; 899 | Function FT_Face_Properties(Face: TFTFace; Const ANumProperties: Cardinal; Const AProperties: PFTParameter): TFTError; Cdecl; External FreeTypeDLL; 900 | Function FT_Get_Name_Index(Const AFace: TFTFace; Const AGlyphName: PAnsiChar): Cardinal; Cdecl; External FreeTypeDLL; 901 | 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) 902 | : TFTError; Cdecl; External FreeTypeDLL; 903 | Function FT_Get_FSType_Flags(Const AFace: TFTFace): TFTFSType; Cdecl; External FreeTypeDLL; 904 | Function FT_Face_GetCharVariantIndex(Const AFace: TFTFace; Const ACharCode, AVariantSelector: LongWord): Cardinal; Cdecl; External FreeTypeDLL; 905 | Function FT_Face_GetCharVariantIsDefault(Const AFace: TFTFace; Const ACharCode, AVariantSelector: LongWord): TFTError; Cdecl; External FreeTypeDLL; 906 | Function FT_Face_GetVariantSelectors(Const AFace: TFTFace): PCardinal; Cdecl; External FreeTypeDLL; 907 | Function FT_Face_GetVariantsOfChar(Const AFace: TFTFace; Const ACharCode: LongWord): PCardinal; Cdecl; External FreeTypeDLL; 908 | Function FT_Face_GetCharsOfVariant(Const AFace: TFTFace; Const VariantSelector: LongWord): PCardinal; Cdecl; External FreeTypeDLL; 909 | // Computations 910 | Function FT_MulDiv(Const AMultiplier1, AMultiplier2, ADivisor: LongInt): LongInt; Cdecl; External FreeTypeDLL; 911 | Function FT_MulFix(Const AMultiplier: LongInt; Const AMultiplierF16Dot16: TFTFixed): LongInt; Cdecl; External FreeTypeDLL; // (A*B)/$10000 912 | Function FT_DivFix(Const ANumerator: LongInt; Const ADenominatorF16Dot16: TFTFixed): LongInt; Cdecl; External FreeTypeDLL; // (A*$10000)/B 913 | Function FT_RoundFix(Const A: TFTFixed): TFTFixed; Cdecl; External FreeTypeDLL; 914 | Function FT_CeilFix(Const A: TFTFixed): TFTFixed; Cdecl; External FreeTypeDLL; 915 | Function FT_FloorFix(Const A: TFTFixed): TFTFixed; Cdecl; External FreeTypeDLL; 916 | Procedure FT_Vector_Transform(Var Vector: TFTVector; [Ref] Const AMatrix: TFTMatrix); Cdecl; External FreeTypeDLL; 917 | // FreeType Version 918 | Procedure FT_Library_Version(Const ALibrary: TFTLibrary; Out OMajor, OMinor, OPatch: Integer); Cdecl; External FreeTypeDLL; 919 | {$ENDREGION} 920 | {$REGION 'ftcolor.h'} 921 | Function FT_Palette_Data_Get(Const AFace: TFTFace; Out OPalette: TFTPaletteData): TFTError; Cdecl; External FreeTypeDLL; 922 | Function FT_Palette_Select(Const AFace: TFTFace; Const APaletteIndex: Word; Out OPalette: PFTColor): TFTError; Cdecl; External FreeTypeDLL; 923 | Function FT_Palette_Set_Foreground_Color(Const AFace: TFTFace; Const AForegroundColor: TFTColor): TFTError; Cdecl; External FreeTypeDLL; 924 | // Layer management 925 | Function FT_Get_Color_Glyph_Layer(Const AFace: TFTFace; Const ABaseGlyph: Cardinal; Out OGlyphIndex, OColorIndex: Cardinal; Var Iterator: TFTLayerIterator): ByteBool; Cdecl; External FreeTypeDLL; 926 | // experimental interface 927 | Function FT_Get_Color_Glyph_Paint(Const AFace: TFTFace; Const ABaseGlyph: Cardinal; Const ARootTransform: TFTColorRootTransform; Out OPaint: TFTOpaquePaint): ByteBool; Cdecl; External FreeTypeDLL; 928 | Function FT_Get_Paint_Layers(Const AFace: TFTFace; Var Iterator: TFTLayerIterator; Out OPaint: TFTOpaquePaint): ByteBool; Cdecl; External FreeTypeDLL; 929 | Function FT_Get_Colorline_Stops(Const AFace: TFTFace; Out OColorStop: TFTColorStop; Var Iterator: TFTColorStopIterator): ByteBool; Cdecl; External FreeTypeDLL; 930 | Function FT_Get_Paint(Const AFace: TFTFace; Const AOpaquePaint: TFTOpaquePaint; Out OPaint: TFTColrPaint): ByteBool; Cdecl; External FreeTypeDLL; 931 | {$ENDREGION} 932 | {$REGION 'ftbitmap.h'} 933 | Procedure FT_Bitmap_Init(Var Bitmap: TFTBitmap); Cdecl; External FreeTypeDLL; 934 | Function FT_Bitmap_Copy(Const ALibrary: TFTLibrary; [Ref] Const ASource: TFTBitmap; Var Target: TFTBitmap): TFTError; Cdecl; External FreeTypeDLL; 935 | Function FT_Bitmap_Embolden(Const ALibrary: TFTLibrary; Var Bitmap: TFTBitmap; Const AXStrength, AYStrength: TFTPos): TFTError; Cdecl; External FreeTypeDLL; 936 | Function FT_Bitmap_Convert(Const ALibrary: TFTLibrary; [Ref] Const ASource: TFTBitmap; Var Target: TFTBitmap; Const Alignment: Integer): TFTError; Cdecl; External FreeTypeDLL; 937 | Function FT_Bitmap_Blend(Const ALibrary: TFTLibrary; [Ref] Const ASource: TFTBitmap; Const ASourceOffset: TFTVector; Var Target: TFTBitmap; Var TargetOffset: TFTVector; Const AColor: TFTColor) 938 | : TFTError; Cdecl; External FreeTypeDLL; 939 | Function FT_GlyphSlot_Own_Bitmap(Var Slot: TFTGlyphSlot): TFTError; Cdecl; External FreeTypeDLL; 940 | Function FT_Bitmap_Done(Const ALibrary: TFTLibrary; Var Bitmap: TFTBitmap): TFTError; Cdecl; External FreeTypeDLL; 941 | {$ENDREGION} 942 | {$REGION 'ftmodapi.h'} 943 | Function FT_Add_Module(&Library: TFTLibrary; [Ref] Const AClass: TFTModuleClass): TFTError; Cdecl; External FreeTypeDLL; 944 | Function FT_Get_Module(&Library: TFTLibrary; Const AModuleName: PAnsiChar): TFTModule; Cdecl; External FreeTypeDLL; 945 | Function FT_Remove_Module(&Library: TFTLibrary; Module: TFTModule): TFTError; Cdecl; External FreeTypeDLL; 946 | Function FT_Property_Set(&Library: TFTLibrary; Const AModuleName, APropertyName: PAnsiChar; Const AValue): TFTError; Cdecl; External FreeTypeDLL; 947 | Function FT_Property_Get(Const ALibrary: TFTLibrary; Const AModuleName, APropertyName: PAnsiChar; Var Value): TFTError; Cdecl; External FreeTypeDLL; 948 | Procedure FT_Set_Default_Properties(&Library: TFTLibrary); Cdecl; External FreeTypeDLL; 949 | Function FT_Reference_Library(&Library: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL; 950 | Function FT_New_Library([Ref] Const AMemory: TFTMemory; Out OLibrary: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL; 951 | Function FT_Done_Library(&Library: TFTLibrary): TFTError; Cdecl; External FreeTypeDLL; 952 | Procedure FT_Set_Debug_Hook(&Library: TFTLibrary; Const AHookIndex: TFTDebugHook; Const ADebugHook: TFTDebugHookFunc); Cdecl; External FreeTypeDLL; 953 | Procedure FT_Add_Default_Modules(&Library: TFTLibrary); Cdecl; External FreeTypeDLL; 954 | // The TrueType Engine 955 | Function FT_Get_TrueType_Engine_Type(Const ALibrary: TFTLibrary): TFTTrueTypeEngineType; Cdecl; External FreeTypeDLL; 956 | {$ENDREGION} 957 | 958 | Implementation 959 | 960 | { TFTMemory } 961 | 962 | Function TFTMemory.Alloc(Const ASize: LongInt): Pointer; 963 | Begin 964 | Result := AllocFunc(Self, ASize); 965 | End; 966 | 967 | Procedure TFTMemory.Free(Const ABlock: Pointer); 968 | Begin 969 | FreeFunc(Self, ABlock); 970 | End; 971 | 972 | Function TFTMemory.Realloc(Const ACurSize, ANewSize: LongInt; Const ABlock: Pointer): Pointer; 973 | Begin 974 | Result := ReallocFunc(Self, ACurSize, ANewSize, ABlock); 975 | End; 976 | 977 | { TFTStream } 978 | 979 | Function TFTStream.Read(Const AOffset: LongWord; Var ABuffer; Const ACount: LongWord): LongWord; 980 | Begin 981 | Result := ReadFunc(Self, AOffset, ABuffer, ACount); 982 | End; 983 | 984 | Procedure TFTStream.Close; 985 | Begin 986 | CloseFunc(Self); 987 | End; 988 | 989 | { TFTColor } 990 | 991 | Constructor TFTColor.Mix(Const ABlue, AGreen, ARed, AAlpha: Byte); 992 | Begin 993 | Blue := ABlue; 994 | Green := AGreen; 995 | Red := ARed; 996 | Alpha := AAlpha; 997 | End; 998 | 999 | { TFTBitmap } 1000 | 1001 | Procedure TFTBitmap.Blend(Const ASourceOffset: TFTVector; Var Target: TFTBitmap; Var TargetOffset: TFTVector; Const AColor: TFTColor); 1002 | Begin 1003 | TFTManager.Error(FT_Bitmap_Blend(TFTManager.&Library, Self, ASourceOffset, Target, TargetOffset, AColor)); 1004 | End; 1005 | 1006 | Procedure TFTBitmap.Convert(Var Target: TFTBitmap; Const Alignment: Integer); 1007 | Begin 1008 | TFTManager.Error(FT_Bitmap_Convert(TFTManager.&Library, Self, Target, Alignment)); 1009 | End; 1010 | 1011 | Procedure TFTBitmap.Copy(Var Target: TFTBitmap); 1012 | Begin 1013 | TFTManager.Error(FT_Bitmap_Copy(TFTManager.&Library, Self, Target)); 1014 | End; 1015 | 1016 | Procedure TFTBitmap.Done; 1017 | Begin 1018 | TFTManager.Error(FT_Bitmap_Done(TFTManager.&Library, Self)); 1019 | End; 1020 | 1021 | Procedure TFTBitmap.Embolden(Const AXStrength, AYStrength: TFTPos); 1022 | Begin 1023 | TFTManager.Error(FT_Bitmap_Embolden(TFTManager.&Library, Self, AXStrength, AYStrength)); 1024 | End; 1025 | 1026 | Function TFTBitmap.GetScanLine(Const ALine: Cardinal): PByte; 1027 | Begin 1028 | Result := PByte(NativeInt(Buffer) + NativeInt(ALine) * Pitch); 1029 | End; 1030 | 1031 | Procedure TFTBitmap.Init; 1032 | Begin 1033 | FT_Bitmap_Init(Self); 1034 | End; 1035 | 1036 | { TFTCurveTagsHelper } 1037 | 1038 | Function TFTCurveTagsHelper.GetDropoutMode: TFTDropoutRules; 1039 | Begin 1040 | // https://docs.microsoft.com/en-us/typography/opentype/spec/tt_instructions#scantype 1041 | Case PByte(@Self)^ Shr 5 Of 1042 | 0: 1043 | Result := [1, 2, 3]; 1044 | 1: 1045 | Result := [1, 2, 4]; 1046 | 2, 3, 6, 7: 1047 | Result := [1, 2]; 1048 | 4: 1049 | Result := [1, 2, 5]; 1050 | 5: 1051 | Result := [1, 2, 6]; 1052 | End; 1053 | End; 1054 | 1055 | { TFTOutline } 1056 | 1057 | Function TFTOutline.GetContours: TArray; 1058 | Begin 1059 | SetLength(Result, FNContours); 1060 | Move(FContourEndPoints^, Result[0], FNContours * SizeOf(SmallInt)); 1061 | End; 1062 | 1063 | Function TFTOutline.GetPoints: TArray; 1064 | Begin 1065 | SetLength(Result, FNPoints); 1066 | Move(FPoints^, Result[0], FNPoints * SizeOf(TFTVector)); 1067 | End; 1068 | 1069 | Function TFTOutline.GetTags: TArray; 1070 | Begin 1071 | SetLength(Result, FNPoints); 1072 | {$IF SizeOf(TFTCurveTags) <> 1} 1073 | {$MESSAGE FATAL 'Unexpected set size (should be byte)'} 1074 | {$IFEND} 1075 | Move(FTags^, Result[0], FNPoints); 1076 | End; 1077 | 1078 | { TFTErrorHelper } 1079 | 1080 | Function TFTErrorHelper.Base: Byte; 1081 | Begin 1082 | Result := Byte(Self And $FF); 1083 | End; 1084 | 1085 | Function TFTErrorHelper.Equals(Const AError: TFTError): Boolean; 1086 | Begin 1087 | Result := Base = AError.Base; 1088 | End; 1089 | 1090 | Function TFTErrorHelper.Inequals(Const AError: TFTError): Boolean; 1091 | Begin 1092 | Result := Base <> AError.Base; 1093 | End; 1094 | 1095 | Function TFTErrorHelper.Module: Word; 1096 | Begin 1097 | Result := Word(Self And $FF00); 1098 | End; 1099 | 1100 | { TFTList } 1101 | 1102 | Function TFTList.IsEmpty: Boolean; 1103 | Begin 1104 | Result := Not Assigned(Head); 1105 | End; 1106 | 1107 | { TFTGlyphSlot } 1108 | 1109 | Procedure TFTGlyphSlot.OwnBitmap; 1110 | Begin 1111 | TFTManager.Error(FT_GlyphSlot_Own_Bitmap(Self)); 1112 | End; 1113 | 1114 | Procedure TFTGlyphSlot.RenderGlyph(Const ARenderMode: TFTRenderMode); 1115 | Begin 1116 | TFTManager.Error(FT_Render_Glyph(Self, ARenderMode)); 1117 | End; 1118 | 1119 | Procedure TFTGlyphSlot.SubGlyphInfo(Const SubIndex: Cardinal; Out OIndex: Integer; Out OFlags: TFTSubGlyphFlags; Out OArg1, OArg2: Integer; Out OTransform: TFTMatrix); 1120 | Begin 1121 | TFTManager.Error(FT_Get_SubGlyph_Info(Self, SubIndex, OIndex, OFlags, OArg1, OArg2, OTransform)); 1122 | End; 1123 | 1124 | { TFTCharmap } 1125 | 1126 | Function TFTCharMap.GetCharMapIndex: Integer; 1127 | Begin 1128 | Result := FT_Get_Charmap_Index(Self); 1129 | If Result = -1 Then 1130 | Raise EFreeType.Create('Error while getting charmap index'); 1131 | End; 1132 | 1133 | { TFTStyleFlagsHelper } 1134 | 1135 | Function TFTStyleFlagsHelper.CountNamedInstances: Cardinal; 1136 | Begin 1137 | Result := (Cardinal(Pointer(@Self)^) Shr 16) And $7FFF; 1138 | End; 1139 | 1140 | { TFTLoadFlagsHelper } 1141 | 1142 | Function TFTLoadFlagsHelper.GetTargetMode: TFTRenderMode; 1143 | Begin 1144 | Result := TFTRenderMode((PCardinal(@Self)^ Shr 16) And 15); 1145 | End; 1146 | 1147 | Procedure TFTLoadFlagsHelper.SetTargetMode(Const AMode: TFTRenderMode); 1148 | Begin 1149 | Self := Self - [ftlfTargetLight, ftlfTargetMono, ftlfTargetLCD, ftlfTargetLCDV]; 1150 | If AMode <> ftrmNormal Then 1151 | Include(Self, TFTLoadFlag(Cardinal(AMode) + 16)); 1152 | End; 1153 | 1154 | { TFTFSType } 1155 | 1156 | Function TFTFSType.GetEmbedding: TFTFSTypeEmbedding; 1157 | Begin 1158 | Result := TFTFSTypeEmbedding(FValue And $F); 1159 | End; 1160 | 1161 | Function TFTFSType.GetFlags: TFTFSTypeFlags; 1162 | Begin 1163 | PWord(@Result)^ := FValue Shr 8; 1164 | End; 1165 | 1166 | { TFTFace } 1167 | 1168 | Class Function TFTFace.Create(Const AFile: AnsiString; Const AFaceIndex, ANamedInstanceIndex: Word): TFTFace; 1169 | Begin 1170 | TFTManager.Error(FT_New_Face(TFTManager.&Library, PAnsiChar(AFile), AFaceIndex Or (ANamedInstanceIndex Shl 16), Result)); 1171 | End; 1172 | 1173 | Class Function TFTFace.Create(Const AData: Pointer; Const ASize: Cardinal; Const AFaceIndex: Word; Const ANamedInstanceIndex: Word): TFTFace; 1174 | Begin 1175 | TFTManager.Error(FT_New_Memory_Face(TFTManager.&Library, AData, ASize, AFaceIndex Or (ANamedInstanceIndex Shl 16), Result)); 1176 | End; 1177 | 1178 | Procedure TFTFace.ClearTransform; 1179 | Begin 1180 | FT_Set_Transform(Self, NIL, NIL); 1181 | End; 1182 | 1183 | Procedure TFTFace.Destroy; 1184 | Begin 1185 | FT_Done_Face(Self); 1186 | End; 1187 | 1188 | Function TFTFace.GetAscender: SmallInt; 1189 | Begin 1190 | Result := FValue^.Ascender; 1191 | End; 1192 | 1193 | Function TFTFace.GetAvailableSizes: TArray; 1194 | Begin 1195 | SetLength(Result, FValue^.NumFixedSizes); 1196 | Move(FValue^.AvailableSizes^, Result[0], SizeOf(Result[0]) * Length(Result)); 1197 | End; 1198 | 1199 | Function TFTFace.GetBBox: TFTBBox; 1200 | Begin 1201 | Result := FValue^.BBox; 1202 | End; 1203 | 1204 | Function TFTFace.GetCharIndex(Const ACharCode: LongWord): Cardinal; 1205 | Begin 1206 | Result := FT_Get_Char_Index(Self, ACharCode); 1207 | End; 1208 | 1209 | Function TFTFace.GetCharMap: PFTCharMap; 1210 | Begin 1211 | Result := FValue^.CharMap; 1212 | End; 1213 | 1214 | Function TFTFace.GetCharMaps: TArray; 1215 | Begin 1216 | SetLength(Result, FValue^.NumCharMaps); 1217 | Move(FValue^.CharMaps^, Result[0], SizeOf(Result[0]) * Length(Result)); 1218 | End; 1219 | 1220 | Function TFTFace.GetCharsOfVariant(Const AVariantSelector: LongWord): TArray; 1221 | Var 1222 | V, W: PCardinal; 1223 | Begin 1224 | V := PCardinal(FT_Face_GetCharsOfVariant(Self, AVariantSelector)); 1225 | If Not Assigned(V) Then 1226 | Exit(NIL); 1227 | W := V; 1228 | While W^ <> 0 Do 1229 | Inc(W); 1230 | SetLength(Result, NativeUInt(W) - NativeUInt(V)); 1231 | Move(V^, Result[0], Length(Result) * SizeOf(Cardinal)); 1232 | End; 1233 | 1234 | Function TFTFace.GetCharVariantIndex(Const ACharCode, AVariantSelector: LongWord): Cardinal; 1235 | Begin 1236 | Result := FT_Face_GetCharVariantIndex(Self, ACharCode, AVariantSelector); 1237 | End; 1238 | 1239 | Function TFTFace.GetCharVariantIsDefault(Const ACharCode, AVariantSelector: LongWord): TFTCharVariantDefault; 1240 | Begin 1241 | Result := TFTCharVariantDefault(FT_Face_GetCharVariantIsDefault(Self, ACharCode, AVariantSelector)); 1242 | End; 1243 | 1244 | Function TFTFace.GetColorGlyphLayers(Const ABaseGlyph: Cardinal): TArray; 1245 | Var 1246 | Iterator: TFTLayerIterator; 1247 | Item: TColorGlyphLayerItem; 1248 | I: Integer; 1249 | Begin 1250 | Iterator.P := NIL; 1251 | If FT_Get_Color_Glyph_Layer(Self, ABaseGlyph, Item.GlyphIndex, Item.ColorIndex, Iterator) Then Begin 1252 | SetLength(Result, Iterator.NumLayers); 1253 | Move(Item, Result[0], SizeOf(Item)); 1254 | For I := 1 To High(Result) Do 1255 | If Not FT_Get_Color_Glyph_Layer(Self, ABaseGlyph, Result[I].GlyphIndex, Result[I].ColorIndex, Iterator) Then 1256 | Raise EFreeType.Create('Error while getting glyph layers'); 1257 | End; 1258 | End; 1259 | 1260 | Function TFTFace.GetColorGlyphPaint(Const ABaseGlyph: Cardinal; Const ARootTransform: TFTColorRootTransform): TFTOpaquePaint; 1261 | Begin 1262 | If Not FT_Get_Color_Glyph_Paint(Self, ABaseGlyph, ARootTransform, Result) Then 1263 | Raise EFreeType.Create('No color glyph found, or the root paint could not be retrieved'); 1264 | End; 1265 | 1266 | Function TFTFace.GetColorLineStops: TArray; 1267 | Var 1268 | Iterator: TFTColorStopIterator; 1269 | Item: TFTColorStop; 1270 | I: Integer; 1271 | Begin 1272 | Iterator.P := NIL; 1273 | If FT_Get_Colorline_Stops(Self, Item, Iterator) Then Begin 1274 | SetLength(Result, Iterator.NumColorStops); 1275 | Move(Item, Result[0], SizeOf(Item)); 1276 | For I := 1 To High(Result) Do 1277 | If Not FT_Get_Colorline_Stops(Self, Result[I], Iterator) Then 1278 | Raise EFreeType.Create('Error while getting colorline stops'); 1279 | End; 1280 | End; 1281 | 1282 | Function TFTFace.GetDescender: SmallInt; 1283 | Begin 1284 | Result := FValue^.Descender; 1285 | End; 1286 | 1287 | Function TFTFace.GetDriverName: AnsiString; 1288 | Type 1289 | PFTModuleClass = ^TFTModuleClass; 1290 | PPFTModuleClass = ^PFTModuleClass; 1291 | Begin 1292 | Result := PPFTModuleClass(FValue^.FDriver)^.ModuleName; 1293 | End; 1294 | 1295 | Function TFTFace.GetFaceFlags: TFTFaceFlags; 1296 | Begin 1297 | Result := FValue^.FaceFlags; 1298 | End; 1299 | 1300 | Function TFTFace.GetFaceIndex: LongInt; 1301 | Begin 1302 | Result := FValue^.FaceIndex; 1303 | End; 1304 | 1305 | Function TFTFace.GetFamilyName: AnsiString; 1306 | Begin 1307 | Result := AnsiString(FValue^.FamilyName); 1308 | End; 1309 | 1310 | Function TFTFace.GetFirstChar(Out OGlyphIndex: Cardinal): LongWord; 1311 | Begin 1312 | Result := FT_Get_First_Char(Self, OGlyphIndex); 1313 | End; 1314 | 1315 | Function TFTFace.GetFSTypeFlags: TFTFSType; 1316 | Begin 1317 | Result := FT_Get_FSType_Flags(Self); 1318 | End; 1319 | 1320 | Function TFTFace.GetGeneric: TFTGeneric; 1321 | Begin 1322 | Result := FValue^.Generic; 1323 | End; 1324 | 1325 | Function TFTFace.GetGlyph: PFTGlyphSlot; 1326 | Begin 1327 | Result := FValue^.Glyph; 1328 | End; 1329 | 1330 | Function TFTFace.GetGlyphName(Const AGlyphIndex: Cardinal): AnsiString; 1331 | Begin 1332 | SetLength(Result, 255); 1333 | TFTManager.Error(FT_Get_Glyph_Name(Self, AGlyphIndex, @Result[1], 255)); 1334 | SetLength(Result, {$IFNDEF VER230}AnsiStrings.{$ENDIF}StrLen(PAnsiChar(@Result[1]))); 1335 | End; 1336 | 1337 | Function TFTFace.GetHeight: SmallInt; 1338 | Begin 1339 | Result := FValue^.Height; 1340 | End; 1341 | 1342 | Function TFTFace.GetKerning(Const ALeftGlyph, ARightGlyph: Cardinal; Const AKernMode: TFTKerningMode): TFTVector; 1343 | Begin 1344 | TFTManager.Error(FT_Get_Kerning(Self, ALeftGlyph, ARightGlyph, AKernMode, Result)); 1345 | End; 1346 | 1347 | Function TFTFace.GetMaxAdvanceHeight: SmallInt; 1348 | Begin 1349 | Result := FValue^.MaxAdvanceHeight; 1350 | End; 1351 | 1352 | Function TFTFace.GetMaxAdvanceWidth: SmallInt; 1353 | Begin 1354 | Result := FValue^.MaxAdvanceWidth; 1355 | End; 1356 | 1357 | Function TFTFace.GetNameIndex(Const GlyphName: AnsiString): Cardinal; 1358 | Begin 1359 | Result := FT_Get_Name_Index(Self, PAnsiChar(GlyphName)); 1360 | End; 1361 | 1362 | Function TFTFace.GetNextChar(Const ACharCode: LongWord; Out OGlyphIndex: Cardinal): LongWord; 1363 | Begin 1364 | Result := FT_Get_Next_Char(Self, ACharCode, OGlyphIndex); 1365 | End; 1366 | 1367 | Function TFTFace.GetNumFaces_: LongInt; 1368 | Begin 1369 | Result := FValue^.NumFaces; 1370 | End; 1371 | 1372 | Class Function TFTFace.GetNumFaces(Const AFile: AnsiString): Integer; 1373 | Var 1374 | Face: TFTFace; 1375 | Begin 1376 | TFTManager.Error(FT_New_Face(TFTManager.&Library, PAnsiChar(AFile), -1, Face)); 1377 | Result := Face.NumFaces; 1378 | TFTManager.Error(FT_Done_Face(Face)); 1379 | End; 1380 | 1381 | Class Function TFTFace.GetNumFaces(Const AData: Pointer; Const ASize: Cardinal): Integer; 1382 | Var 1383 | Face: TFTFace; 1384 | Begin 1385 | TFTManager.Error(FT_New_Memory_Face(TFTManager.&Library, AData, ASize, -1, Face)); 1386 | Result := Face.NumFaces; 1387 | TFTManager.Error(FT_Done_Face(Face)); 1388 | End; 1389 | 1390 | Function TFTFace.GetNumGlyphs: LongInt; 1391 | Begin 1392 | Result := FValue^.NumGlyphs; 1393 | End; 1394 | 1395 | Function TFTFace.GetPaint(Const AOpaquePaint: TFTOpaquePaint): TFTColrPaint; 1396 | Begin 1397 | If Not FT_Get_Paint(Self, AOpaquePaint, Result) Then 1398 | Raise EFreeType.Create('Error while getting details for a paint'); 1399 | End; 1400 | 1401 | Function TFTFace.GetPaintLayers: TArray; 1402 | Var 1403 | Iterator: TFTLayerIterator; 1404 | Item: TFTOpaquePaint; 1405 | I: Integer; 1406 | Begin 1407 | Iterator.P := NIL; 1408 | If FT_Get_Paint_Layers(Self, Iterator, Item) Then Begin 1409 | SetLength(Result, Iterator.NumLayers); 1410 | Move(Item, Result[0], SizeOf(Item)); 1411 | For I := 1 To High(Result) Do 1412 | If Not FT_Get_Paint_Layers(Self, Iterator, Result[I]) Then 1413 | Raise EFreeType.Create('Error while getting paint layers'); 1414 | End; 1415 | End; 1416 | 1417 | Function TFTFace.GetPalette: TFTPaletteData; 1418 | Begin 1419 | TFTManager.Error(FT_Palette_Data_Get(Self, Result)); 1420 | End; 1421 | 1422 | Function TFTFace.GetPostscriptName: AnsiString; 1423 | Begin 1424 | Result := AnsiString(FT_Get_Postscript_Name(Self)); 1425 | End; 1426 | 1427 | Class Function TFTFace.GetStyleFlags(Const AFile: AnsiString; Const AFaceIndex: Word): TFTStyleFlags; 1428 | Var 1429 | Face: TFTFace; 1430 | Begin 1431 | TFTManager.Error(FT_New_Face(TFTManager.&Library, PAnsiChar(AFile), -(AFaceIndex + 1), Face)); 1432 | Result := Face.StyleFlags; 1433 | TFTManager.Error(FT_Done_Face(Face)); 1434 | End; 1435 | 1436 | Function TFTFace.GetSize: PFTSize; 1437 | Begin 1438 | Result := FValue^.Size; 1439 | End; 1440 | 1441 | Class Function TFTFace.GetStyleFlags(Const AData: Pointer; Const ASize: Cardinal; Const AFaceIndex: Word): TFTStyleFlags; 1442 | Var 1443 | Face: TFTFace; 1444 | Begin 1445 | TFTManager.Error(FT_New_Memory_Face(TFTManager.&Library, AData, ASize, -(AFaceIndex + 1), Face)); 1446 | Result := Face.StyleFlags; 1447 | TFTManager.Error(FT_Done_Face(Face)); 1448 | End; 1449 | 1450 | Function TFTFace.GetStyleFlags_: TFTStyleFlags; 1451 | Begin 1452 | Result := FValue^.StyleFlags; 1453 | End; 1454 | 1455 | Function TFTFace.GetStyleName: AnsiString; 1456 | Begin 1457 | Result := AnsiString(FValue^.StyleName); 1458 | End; 1459 | 1460 | Function TFTFace.GetTrackKerning(Const APointSize: TFTFixed; Const ADegree: Integer): TFTFixed; 1461 | Begin 1462 | TFTManager.Error(FT_Get_Track_Kerning(Self, APointSize, ADegree, Result)); 1463 | End; 1464 | 1465 | Procedure TFTFace.GetTransform(Out OMatrix: TFTMatrix); 1466 | Begin 1467 | FT_Get_Transform(Self, @OMatrix, NIL); 1468 | End; 1469 | 1470 | Procedure TFTFace.GetTransform(Out ODelta: TFTVector); 1471 | Begin 1472 | FT_Get_Transform(Self, NIL, @ODelta); 1473 | End; 1474 | 1475 | Procedure TFTFace.GetTransform(Out OMatrix: TFTMatrix; Out ODelta: TFTVector); 1476 | Begin 1477 | FT_Get_Transform(Self, @OMatrix, @ODelta); 1478 | End; 1479 | 1480 | Function TFTFace.GetUnderlinePosition: SmallInt; 1481 | Begin 1482 | Result := FValue^.UnderlinePosition; 1483 | End; 1484 | 1485 | Function TFTFace.GetUnderlineThickness: SmallInt; 1486 | Begin 1487 | Result := FValue^.UnderlineThickness; 1488 | End; 1489 | 1490 | Function TFTFace.GetUnitsPerEM: Word; 1491 | Begin 1492 | Result := FValue^.UnitsPerEM; 1493 | End; 1494 | 1495 | Function TFTFace.GetVariantSelectors: TArray; 1496 | Var 1497 | V, W: PCardinal; 1498 | Begin 1499 | V := PCardinal(FT_Face_GetVariantSelectors(Self)); 1500 | If Not Assigned(V) Then 1501 | Exit(NIL); 1502 | W := V; 1503 | While W^ <> 0 Do 1504 | Inc(W); 1505 | SetLength(Result, NativeUInt(W) - NativeUInt(V)); 1506 | Move(V^, Result[0], Length(Result) * SizeOf(Cardinal)); 1507 | End; 1508 | 1509 | Function TFTFace.GetVariantsOfChar(Const ACharCode: LongWord): TArray; 1510 | Var 1511 | V, W: PCardinal; 1512 | Begin 1513 | V := PCardinal(FT_Face_GetVariantsOfChar(Self, ACharCode)); 1514 | If Not Assigned(V) Then 1515 | Exit(NIL); 1516 | W := V; 1517 | While W^ <> 0 Do 1518 | Inc(W); 1519 | SetLength(Result, NativeUInt(W) - NativeUInt(V)); 1520 | Move(V^, Result[0], Length(Result) * SizeOf(Cardinal)); 1521 | End; 1522 | 1523 | Function TFTFace.IsNamedInstance: Boolean; 1524 | Begin 1525 | Result := (FaceIndex And $7FFF0000) <> 0; 1526 | End; 1527 | 1528 | Procedure TFTFace.LoadChar(Const ACharCode: LongWord; Const ALoadFlags: TFTLoadFlags); 1529 | Begin 1530 | TFTManager.Error(FT_Load_Char(Self, ACharCode, ALoadFlags)); 1531 | End; 1532 | 1533 | Procedure TFTFace.LoadGlyph(Const AGlyphIndex: Cardinal; Const ALoadFlags: TFTLoadFlags); 1534 | Begin 1535 | TFTManager.Error(FT_Load_Glyph(Self, AGlyphIndex, ALoadFlags)); 1536 | End; 1537 | 1538 | Procedure TFTFace.Properties(Const AStemDarkening: ByteBool); 1539 | Var 1540 | Props: TFTParameter; 1541 | Begin 1542 | Props.Tag := ftptStemDarkening; 1543 | Props.Data := @AStemDarkening; 1544 | TFTManager.Error(FT_Face_Properties(Self, 1, @Props)); 1545 | End; 1546 | 1547 | Procedure TFTFace.Properties(Const ALCDFilterWeights: TFTLCDFiveTapFilter); 1548 | Var 1549 | Props: TFTParameter; 1550 | Begin 1551 | Props.Tag := ftptLCDFilterWeights; 1552 | Props.Data := @ALCDFilterWeights; 1553 | TFTManager.Error(FT_Face_Properties(Self, 1, @Props)); 1554 | End; 1555 | 1556 | Procedure TFTFace.Properties(Const ARandomSeed: Integer); 1557 | Var 1558 | Props: TFTParameter; 1559 | Begin 1560 | Props.Tag := ftptRandomSeed; 1561 | Props.Data := @ARandomSeed; 1562 | TFTManager.Error(FT_Face_Properties(Self, 1, @Props)); 1563 | End; 1564 | 1565 | Procedure TFTFace.Properties(Const AStemDarkening: ByteBool; Const ALCDFilterWeights: TFTLCDFiveTapFilter); 1566 | Var 1567 | Props: Array [0 .. 1] Of TFTParameter; 1568 | Begin 1569 | Props[0].Tag := ftptStemDarkening; 1570 | Props[0].Data := @AStemDarkening; 1571 | Props[1].Tag := ftptLCDFilterWeights; 1572 | Props[1].Data := @ALCDFilterWeights; 1573 | TFTManager.Error(FT_Face_Properties(Self, 2, @Props)); 1574 | End; 1575 | 1576 | Procedure TFTFace.Properties(Const AStemDarkening: ByteBool; Const ARandomSeed: Integer); 1577 | Var 1578 | Props: Array [0 .. 1] Of TFTParameter; 1579 | Begin 1580 | Props[0].Tag := ftptStemDarkening; 1581 | Props[0].Data := @AStemDarkening; 1582 | Props[1].Tag := ftptRandomSeed; 1583 | Props[1].Data := @ARandomSeed; 1584 | TFTManager.Error(FT_Face_Properties(Self, 2, @Props)); 1585 | End; 1586 | 1587 | Procedure TFTFace.Properties(Const ALCDFilterWeights: TFTLCDFiveTapFilter; Const ARandomSeed: Integer); 1588 | Var 1589 | Props: Array [0 .. 1] Of TFTParameter; 1590 | Begin 1591 | Props[0].Tag := ftptLCDFilterWeights; 1592 | Props[0].Data := @ALCDFilterWeights; 1593 | Props[1].Tag := ftptRandomSeed; 1594 | Props[1].Data := @ARandomSeed; 1595 | TFTManager.Error(FT_Face_Properties(Self, 2, @Props)); 1596 | End; 1597 | 1598 | Procedure TFTFace.Properties(Const AStemDarkening: ByteBool; Const ALCDFilterWeights: TFTLCDFiveTapFilter; Const ARandomSeed: Integer); 1599 | Var 1600 | Props: Array [0 .. 2] Of TFTParameter; 1601 | Begin 1602 | Props[0].Tag := ftptStemDarkening; 1603 | Props[0].Data := @AStemDarkening; 1604 | Props[1].Tag := ftptLCDFilterWeights; 1605 | Props[1].Data := @ALCDFilterWeights; 1606 | Props[2].Tag := ftptRandomSeed; 1607 | Props[2].Data := @ARandomSeed; 1608 | TFTManager.Error(FT_Face_Properties(Self, 3, @Props)); 1609 | End; 1610 | 1611 | Procedure TFTFace.RequestSize(Const ARequest: TFTSizeRequest); 1612 | Begin 1613 | TFTManager.Error(FT_Request_Size(Self, ARequest)); 1614 | End; 1615 | 1616 | Procedure TFTFace.RequestSize(Const AType: TFTSizeRequestType; Const AWidth, AHeight: LongInt; Const AHorzResolution, AVertResolution: Cardinal); 1617 | Var 1618 | Req: TFTSizeRequest; 1619 | Begin 1620 | Req.&Type := AType; 1621 | Req.Width := AWidth; 1622 | Req.Height := AHeight; 1623 | Req.HorzResolution := AHorzResolution; 1624 | Req.VertResolution := AVertResolution; 1625 | TFTManager.Error(FT_Request_Size(Self, Req)); 1626 | End; 1627 | 1628 | Procedure TFTFace.SelectCharMap(Const AEncoding: TFTEncoding); 1629 | Begin 1630 | TFTManager.Error(FT_Select_Charmap(Self, AEncoding)); 1631 | End; 1632 | 1633 | Function TFTFace.SelectPalette(Const APaletteIndex: Word): PPaletteArray; 1634 | Begin 1635 | TFTManager.Error(FT_Palette_Select(Self, APaletteIndex, PFTColor(Result))); 1636 | End; 1637 | 1638 | Procedure TFTFace.SelectSize(Const AStrikeIndex: Integer); 1639 | Begin 1640 | TFTManager.Error(FT_Select_Size(Self, AStrikeIndex)); 1641 | End; 1642 | 1643 | Procedure TFTFace.SetCharMap(Var CharMap: TFTCharMap); 1644 | Begin 1645 | TFTManager.Error(FT_Set_Charmap(Self, CharMap)); 1646 | End; 1647 | 1648 | Procedure TFTFace.SetCharSize(Const ACharWidth, ACharHeight: TFTF26Dot6; Const AHorzResolution, AVertResolution: Cardinal); 1649 | Begin 1650 | TFTManager.Error(FT_Set_Char_Size(Self, ACharWidth, ACharHeight, AHorzResolution, AVertResolution)); 1651 | End; 1652 | 1653 | Procedure TFTFace.SetForegroundColor(Const AForegroundColor: TFTColor); 1654 | Begin 1655 | TFTManager.Error(FT_Palette_Set_Foreground_Color(Self, AForegroundColor)); 1656 | End; 1657 | 1658 | Procedure TFTFace.SetGeneric(Const AValue: TFTGeneric); 1659 | Begin 1660 | FValue^.Generic := AValue; 1661 | End; 1662 | 1663 | Procedure TFTFace.SetPixelSize(Const APixelWidth, APixelHeight: Cardinal); 1664 | Begin 1665 | TFTManager.Error(FT_Set_Pixel_Sizes(Self, APixelWidth, APixelHeight)); 1666 | End; 1667 | 1668 | Procedure TFTFace.SetTransform(Const AMatrix: TFTMatrix); 1669 | Begin 1670 | FT_Set_Transform(Self, @AMatrix, NIL); 1671 | End; 1672 | 1673 | Procedure TFTFace.SetTransform(Const ADelta: TFTVector); 1674 | Begin 1675 | FT_Set_Transform(Self, NIL, @ADelta); 1676 | End; 1677 | 1678 | Procedure TFTFace.SetTransform(Const AMatrix: TFTMatrix; Const ADelta: TFTVector); 1679 | Begin 1680 | FT_Set_Transform(Self, @AMatrix, @ADelta); 1681 | End; 1682 | 1683 | { TFTManager } 1684 | 1685 | Class Procedure TFTManager.Error(Const AErrorCode: TFTError); 1686 | Begin 1687 | If AErrorCode <> 0 Then 1688 | Raise EFreeType.CreateFmt(sError, [AErrorCode, AnsiString(FT_Error_String(AErrorCode))]); 1689 | End; 1690 | 1691 | Class Procedure TFTManager.Finalize; 1692 | Begin 1693 | FT_Done_Library(FLibrary); 1694 | // FT_Done_FreeType(FLibrary^); 1695 | End; 1696 | 1697 | Class Procedure TFTManager.Initialize; 1698 | Begin 1699 | Error(FT_New_Library(cMem, FLibrary)); 1700 | FT_Add_Default_Modules(FLibrary); 1701 | FT_Set_Default_Properties(FLibrary); 1702 | // FT_Init_FreeType(FLibrary); 1703 | FT_Library_Version(FLibrary, FMajor, FMinor, FPatch); 1704 | Assert((MajorVersion = FREETYPE_MAJOR) And (MinorVersion = FREETYPE_MINOR) And (PatchVersion = FREETYPE_PATCH), 'Unknown FreeType version'); 1705 | End; 1706 | 1707 | Class Function TFTManager.MemAlloc([Ref] Const AMemory: TFTMemory; Const ASize: Integer): Pointer; 1708 | Begin 1709 | Result := GetMemory(ASize); 1710 | End; 1711 | 1712 | Class Procedure TFTManager.MemFree([Ref] Const AMemory: TFTMemory; Const ABlock: Pointer); 1713 | Begin 1714 | FreeMemory(ABlock); 1715 | End; 1716 | 1717 | Class Function TFTManager.MemRealloc([Ref] Const AMemory: TFTMemory; Const ACurSize, ANewSize: Integer; Const ABlock: Pointer): Pointer; 1718 | Begin 1719 | Result := ReallocMemory(ABlock, ANewSize); 1720 | End; 1721 | 1722 | Initialization 1723 | 1724 | TFTManager.Initialize; 1725 | 1726 | Finalization 1727 | 1728 | TFTManager.Finalize; 1729 | 1730 | End. 1731 | -------------------------------------------------------------------------------- /uHarfBuzz.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projekter/TextShaping4Delphi/7ebec0666edc1dc2f1642e6e8cba27068eaa905d/uHarfBuzz.pas -------------------------------------------------------------------------------- /uICU.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projekter/TextShaping4Delphi/7ebec0666edc1dc2f1642e6e8cba27068eaa905d/uICU.pas --------------------------------------------------------------------------------