diff --git a/header/examples/fpc/example.lpi b/header/examples/fpc/example.lpi
new file mode 100644
index 0000000..c714e12
--- /dev/null
+++ b/header/examples/fpc/example.lpi
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/header/examples/fpc/example.lpr b/header/examples/fpc/example.lpr
new file mode 100644
index 0000000..f312b5c
--- /dev/null
+++ b/header/examples/fpc/example.lpr
@@ -0,0 +1,20 @@
+program example;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, uMainForm, ulibTextSuite;
+
+{$R *.res}
+
+begin
+ RequireDerivedFormResource := True;
+ Application.Initialize;
+ Application.CreateForm(TMainForm, MainForm);
+ Application.Run;
+end.
+
diff --git a/header/examples/fpc/uMainForm.lfm b/header/examples/fpc/uMainForm.lfm
new file mode 100644
index 0000000..bb5091c
--- /dev/null
+++ b/header/examples/fpc/uMainForm.lfm
@@ -0,0 +1,12 @@
+object MainForm: TMainForm
+ Left = 485
+ Height = 240
+ Top = 255
+ Width = 320
+ Caption = 'libTextSuite'
+ OnCreate = FormCreate
+ OnDestroy = FormDestroy
+ OnPaint = FormPaint
+ OnResize = FormResize
+ LCLVersion = '1.3'
+end
diff --git a/header/examples/fpc/uMainForm.pas b/header/examples/fpc/uMainForm.pas
new file mode 100644
index 0000000..681c3b7
--- /dev/null
+++ b/header/examples/fpc/uMainForm.pas
@@ -0,0 +1,95 @@
+unit uMainForm;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
+ uglcContext;
+
+type
+ TMainForm = class(TForm)
+ procedure FormCreate(Sender: TObject);
+ procedure FormDestroy(Sender: TObject);
+ procedure FormPaint(Sender: TObject);
+ procedure FormResize(Sender: TObject);
+ private
+ fContext: TglcContext;
+ procedure Render;
+ end;
+
+var
+ MainForm: TMainForm;
+
+implementation
+
+{$R *.lfm}
+
+uses
+ dglOpenGL;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//MainForm//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TMainForm.FormCreate(Sender: TObject);
+var
+ pf: TglcContextPixelFormatSettings;
+begin
+ pf := TglcContext.MakePF();
+ fContext := TglcContext.GetPlatformClass.Create(self, pf);
+ fContext.BuildContext;
+ fContext.Activate;
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TMainForm.FormDestroy(Sender: TObject);
+begin
+ FreeAndNil(fContext);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TMainForm.FormPaint(Sender: TObject);
+begin
+ Render;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TMainForm.FormResize(Sender: TObject);
+begin
+ if Assigned(fContext) then begin
+ glViewport(0, 0, ClientWidth, ClientHeight);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity;
+ glOrtho(0, ClientWidth, ClientHeight, 0, 10, -10);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity;
+ end;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TMainForm.Render;
+const
+ X = 100;
+var
+ w, h: Integer;
+begin
+ w := ClientWidth;
+ h := ClientHeight;
+
+ glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ glBegin(GL_QUADS);
+ glVertex2f(X, X);
+ glVertex2f(X, h-X);
+ glVertex2f(w-X, h-X);
+ glVertex2f(w-X, X);
+ glEnd;
+ fContext.SwapBuffers;
+end;
+
+end.
+
diff --git a/header/ulibTextSuite.pas b/header/ulibTextSuite.pas
new file mode 100644
index 0000000..b833b57
--- /dev/null
+++ b/header/ulibTextSuite.pas
@@ -0,0 +1,2030 @@
+unit ulibTextSuite;
+
+{$IFDEF fpc}
+ {$mode objfpc}{$H+}
+{$ENDIF}
+
+interface
+
+uses
+ Classes, SysUtils;
+
+type
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Enums/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ {$Z4}
+ TltsErrorCode = (
+ ltsErrUnknown = -1,
+ ltsErrNone = 0,
+
+ // misc
+ ltsErrNotInitialized = 1,
+ ltsErrInvalidEnum = 2,
+ ltsErrInvalidValue = 3,
+ ltsErrInvalidOperation = 4,
+ ltsErrInvalidType = 5,
+
+ // invalid handles
+ ltsErrInvalidContextHandle = 100,
+ ltsErrInvalidRendererHandle = 101,
+ ltsErrInvalidTextBlockHandle = 102,
+ ltsErrInvalidFontHandle = 103,
+ ltsErrInvalidFontCreatorHandle = 104,
+ ltsErrInvalidImageHandle = 105,
+ ltsErrInvalidPostProcHandle = 106
+ );
+
+ {$Z4}
+ TltsObjectType = (
+ ltsObjTypeUnknown,
+ ltsObjTypeContext,
+ ltsObjTypeRenderer,
+ ltsObjTypeFontCreator,
+ ltsObjTypeFont,
+ ltsObjTypeTextBlock,
+ ltsObjTypeImage,
+ ltsObjTypePostProcessor
+ );
+
+ {$Z4}
+ TltsRendererType = (
+ ltsRendererUnknown,
+ ltsRendererOpenGL,
+ ltsRendererOpenGLES,
+ ltsRendererCustom
+ );
+
+ {$Z4}
+ TltsFontCreatorType = (
+ ltsFontCreatorUnknown,
+ ltsFontCreatorFreeType,
+ ltsFontCreatorGDI,
+ ltsFontCreatorCustom
+ );
+
+ {$Z4}
+ TltsCodePage = (
+ ltsUTF8,
+ ltsISO_8859_1,
+ ltsISO_8859_2,
+ ltsISO_8859_3,
+ ltsISO_8859_4,
+ ltsISO_8859_5,
+ ltsISO_8859_6,
+ ltsISO_8859_7,
+ ltsISO_8859_8,
+ ltsISO_8859_9,
+ ltsISO_8859_10,
+ ltsISO_8859_11,
+ ltsISO_8859_13,
+ ltsISO_8859_14,
+ ltsISO_8859_15,
+ ltsISO_8859_16,
+ ltsISO_037,
+ ltsISO_437,
+ ltsISO_500,
+ ltsISO_737,
+ ltsISO_775,
+ ltsISO_850,
+ ltsISO_852,
+ ltsISO_855,
+ ltsISO_857,
+ ltsISO_860,
+ ltsISO_861,
+ ltsISO_862,
+ ltsISO_863,
+ ltsISO_864,
+ ltsISO_865,
+ ltsISO_866,
+ ltsISO_869,
+ ltsISO_874,
+ ltsISO_875,
+ ltsISO_1026,
+ ltsISO_1250,
+ ltsISO_1251,
+ ltsISO_1252,
+ ltsISO_1253,
+ ltsISO_1254,
+ ltsISO_1255,
+ ltsISO_1256,
+ ltsISO_1257,
+ ltsISO_1258);
+
+ TltsFormat = (
+ ltsFormatEmpty,
+ ltsFormatRGBA8,
+ ltsFormatLumAlpha8,
+ ltsFormatAlpha8,
+ ltsFormatLum8);
+
+ TltsVertAlignment = (
+ ltsVertAlignTop,
+ ltsVertAlignCenter,
+ ltsVertAlignBottom);
+
+ TltsHorzAlignment = (
+ ltsHorzAlignLeft,
+ ltsHorzAlignCenter,
+ ltsHorzAlignRight,
+ ltsHorzAlignJustify);
+
+ TltsClipping = (
+ ltsClipNone,
+ ltsClipWordBorder,
+ ltsClipCharBorder,
+ ltsClipWordComplete,
+ ltsClipCharComplete
+ );
+
+ TltsAntiAliasing = (
+ ltsAANone,
+ ltsAANormal);
+
+ TltsCharRangeUsage = (
+ ltsUsageInclude,
+ ltsUsageExclude);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Flags/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+type
+ TltsBlockFlag = (
+ ltsBlockFlagWordWrap
+ );
+ TltsBlockFlags = set of TltsBlockFlag;
+
+ TltsFontStyle = (
+ ltsStyleBold,
+ ltsStyleItalic,
+ ltsStyleUnderline,
+ ltsStyleStrikeout);
+ TltsFontStyles = set of TltsFontStyle;
+
+ TltsColorChannel = (
+ ltsChannelRed,
+ ltsChannelGreen,
+ ltsChannelBlue,
+ ltsChannelAlpha);
+ TltsColorChannels = set of TltsColorChannel;
+
+ TltsImageMode = (
+ ltsModeIgnore,
+ ltsModeReplace,
+ ltsModeModulate);
+ TltsImageModes = array[TltsColorChannel] of TltsImageMode;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Structures////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+type
+ PltsColor4f = ^TltsColor4f;
+ TltsColor4f = packed record
+ case Boolean of
+ true: (r, g, b, a: Single);
+ false: (arr: array[0..3] of Single);
+ end;
+
+ PltsPosition = ^TltsPosition;
+ TltsPosition = packed record
+ x, y: Integer;
+ end;
+
+ PltsRect = ^TltsRect;
+ TltsRect = packed record
+ case Byte of
+ 0: (TopLeft: TltsPosition; BottomRight: TltsPosition);
+ 1: (Left, Top, Right, Bottom: Integer);
+ end;
+
+ TltsVector4f = array[0..3] of Single;
+ TltsMatrix4f = array[0..3] of TltsVector4f;
+
+ TltsGlyphMetric = packed record
+ GlyphOrigin: TltsPosition;
+ GlyphRect: TltsRect;
+ Advance: Integer;
+ end;
+
+ TltsTextMetric = packed record
+ Ascent: Integer;
+ Descent: Integer;
+ ExternalLeading: Integer;
+ BaseLineOffset: Integer;
+ CharSpacing: Integer;
+ LineHeight: Integer;
+ LineSpacing: Integer;
+ end;
+
+ TltsFontNames = packed record
+ Fontname: String;
+ Copyright: String;
+ Facename: String;
+ Stylename: String;
+ Fullname: String;
+ end;
+
+ TltsFontMetric = packed record
+ Size: Integer;
+ Style: TltsFontStyles;
+ AntiAliasing: TltsAntiAliasing;
+ DefaultChar: WideChar;
+
+ Ascent: Integer;
+ Descent: Integer;
+ ExternalLeading: Integer;
+ BaseLineOffset: Integer;
+
+ UnderlinePos: Integer;
+ UnderlineSize: Integer;
+ StrikeoutPos: Integer;
+ StrikeoutSize: Integer;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Library Functions/////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+type
+ TltsHandle = Pointer;
+ TltsContextHandle = TltsHandle;
+ TltsRendererHandle = TltsHandle;
+ TltsTextBlockHandle = TltsHandle;
+ TltsFontCreatorHandle = TltsHandle;
+ TltsFontHandle = TltsHandle;
+ TltsPostProcessorHandle = TltsHandle;
+ TltsImageHandle = TltsHandle;
+
+ TltsStreamOrigin = (
+ ltsStreamOriginBegin = Integer(soBeginning),
+ ltsStreamOriginCurrent = Integer(soCurrent),
+ ltsStreamOriginEnd = Integer(soEnd)
+ );
+
+ TltsStreamFuncRead = function(const aArgs: Pointer; const aBuffer: Pointer; const aSize: Integer): Integer; stdcall;
+ TltsStreamFuncSeek = function(const aArgs: Pointer; const aOrigin: TltsStreamOrigin; const aPos: Integer): Integer; stdcall;
+ PltsStream = ^TltsStream;
+ TltsStream = packed record
+ args: Pointer;
+ read: TltsStreamFuncRead;
+ seek: TltsStreamFuncSeek;
+ end;
+
+ TltsImage = class;
+ TltsImageLoadFunc = procedure(const aImage: TltsImage; X, Y: Integer; var aPixel: TltsColor4f; aArgs: Pointer);
+ TltsImageBlendFunc = function (const aSrc, aDst: TltsColor4f; aArgs: Pointer): TltsColor4f;
+
+ TltsImageLoadInternFunc = procedure(const aHandle: TltsImageHandle; const X, Y: Integer; var aPixel: TltsColor4f; aArgs: Pointer); stdcall;
+ TltsImageBlendInternFunc = function (const aHandle: TltsImageHandle; const aSrc, aDst: TltsColor4f; aArgs: Pointer): TltsColor4f; stdcall;
+
+ TltsContextCreate = function(): TltsContextHandle; stdcall;
+ TltsContextGetCodePage = function(const aHandle: TltsContextHandle; out aCodePage: TltsCodePage): TltsErrorCode; stdcall;
+ TltsContextGetDefaultChar = function(const aHandle: TltsContextHandle; out aValue: WideChar): TltsErrorCode; stdcall;
+ TltsContextSetCodePage = function(const aHandle: TltsContextHandle; const aCodePage: TltsCodePage): TltsErrorCode; stdcall;
+ TltsContextSetDefaultChar = function(const aHandle: TltsContextHandle; const aValue: WideChar): TltsErrorCode; stdcall;
+ TltsContextAnsiToWide = function(const aHandle: TltsContextHandle; const aText: PAnsiChar): PWideChar; stdcall;
+ TltsContextDestroy = function(const aHandle: TltsContextHandle): TltsErrorCode; stdcall;
+
+ TltsRendererCreate = function(const aHandle: TltsContextHandle; const aType: TltsRendererType; const aFormat: TltsFormat): TltsRendererHandle; stdcall;
+ TltsRendererBeginBlock = function(const aHandle: TltsRendererHandle; const aTop, aLeft, aWidth, aHeight: Integer; const aFlags: TltsBlockFlags): TltsTextBlockHandle; stdcall;
+ TltsRendererEndBlock = function(const aHandle: TltsRendererHandle; const aBlock: TltsTextBlockHandle): TltsErrorCode; stdcall;
+ TltsRendererAbortBlock = function(const aHandle: TltsRendererHandle; const aBlock: TltsTextBlockHandle): TltsErrorCode; stdcall;
+ TltsRendererGetTextWidthA = function(const aHandle: TltsRendererHandle; const aFont: TltsFontHandle; const aText: PAnsiChar): Integer; stdcall;
+ TltsRendererGetTextWidthW = function(const aHandle: TltsRendererHandle; const aFont: TltsFontHandle; const aText: PWideChar): Integer; stdcall;
+ TltsRendererDestroy = function(const aHandle: TltsRendererHandle): TltsErrorCode; stdcall;
+
+ TltsFontCreatorCreate = function(const aHandle: TltsContextHandle; const aType: TltsFontCreatorType): TltsFontCreatorHandle; stdcall;
+ TltsFontCreatorGetFontByName = function(const aHandle: TltsFontCreatorHandle; const aFontname: PAnsiChar; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFontHandle; stdcall;
+ TltsFontCreatorGetFontByFile = function(const aHandle: TltsFontCreatorHandle; const aFilename: PAnsiChar; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFontHandle; stdcall;
+ TltsFontCreatorGetFontByStream = function(const aHandle: TltsFontCreatorHandle; const aStream: PltsStream; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFontHandle; stdcall;
+ TltsFontCreatorDestroy = function(const aHandle: TltsFontCreatorHandle): TltsErrorCode; stdcall;
+
+ TltsFontGetPostProcessor = function(const aHandle: TltsFontHandle): TltsPostProcessorHandle; stdcall;
+ TltsFontGetTabWidth = function(const aHandle: TltsFontHandle; out aValue: Integer): TltsErrorCode; stdcall;
+ TltsFontGetCharSpacing = function(const aHandle: TltsFontHandle; out aValue: Integer): TltsErrorCode; stdcall;
+ TltsFontGetLineSpacing = function(const aHandle: TltsFontHandle; out aValue: Single): TltsErrorCode; stdcall;
+ TltsFontGetMetric = function(const aHandle: TltsFontHandle; out aValue: TltsFontMetric): TltsErrorCode; stdcall;
+ TltsFontGetFontname = function(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
+ TltsFontGetFacename = function(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
+ TltsFontGetStylename = function(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
+ TltsFontGetFullname = function(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
+ TltsFontGetCopyright = function(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
+ TltsFontSetPostProcessor = function(const aHandle: TltsFontHandle; const aValue: TltsPostProcessorHandle): TltsErrorCode; stdcall;
+ TltsFontSetTabWidth = function(const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
+ TltsFontSetCharSpacing = function(const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
+ TltsFontSetLineSpacing = function(const aHandle: TltsFontHandle; const aValue: Single): TltsErrorCode; stdcall;
+ TltsFontDestroy = function(const aHandle: TltsFontHandle): TltsErrorCode; stdcall;
+
+ TltsTextBlockGetRect = function(const aHandle: TltsTextBlockHandle; out aValue: TltsRect): TltsErrorCode; stdcall;
+ TltsTextBlockGetWidth = function(const aHandle: TltsTextBlockHandle; out aValue: Integer): TltsErrorCode; stdcall;
+ TltsTextBlockGetHeight = function(const aHandle: TltsTextBlockHandle; out aValue: Integer): TltsErrorCode; stdcall;
+ TltsTextBlockGetFlags = function(const aHandle: TltsTextBlockHandle; out aValue: TltsBlockFlags): TltsErrorCode; stdcall;
+ TltsTextBlockGetTop = function(const aHandle: TltsTextBlockHandle; out aValue: Integer): TltsErrorCode; stdcall;
+ TltsTextBlockGetLeft = function(const aHandle: TltsTextBlockHandle; out aValue: Integer): TltsErrorCode; stdcall;
+ TltsTextBlockGetVertAlign = function(const aHandle: TltsTextBlockHandle; out aValue: TltsVertAlignment): TltsErrorCode; stdcall;
+ TltsTextBlockGetHorzAlign = function(const aHandle: TltsTextBlockHandle; out aValue: TltsHorzAlignment): TltsErrorCode; stdcall;
+ TltsTextBlockGetClipping = function(const aHandle: TltsTextBlockHandle; out aValue: TltsClipping): TltsErrorCode; stdcall;
+ TltsTextBlockGetColor = function(const aHandle: TltsTextBlockHandle; out aValue: TltsColor4f): TltsErrorCode; stdcall;
+ TltsTextBlockGetFont = function(const aHandle: TltsTextBlockHandle; out aValue: TltsFontHandle): TltsErrorCode; stdcall;
+ TltsTextBlockSetTop = function(const aHandle: TltsTextBlockHandle; const aValue: Integer): TltsErrorCode; stdcall;
+ TltsTextBlockSetLeft = function(const aHandle: TltsTextBlockHandle; const aValue: Integer): TltsErrorCode; stdcall;
+ TltsTextBlockSetVertAlign = function(const aHandle: TltsTextBlockHandle; const aValue: TltsVertAlignment): TltsErrorCode; stdcall;
+ TltsTextBlockSetHorzAlign = function(const aHandle: TltsTextBlockHandle; const aValue: TltsHorzAlignment): TltsErrorCode; stdcall;
+ TltsTextBlockSetClipping = function(const aHandle: TltsTextBlockHandle; const aValue: TltsClipping): TltsErrorCode; stdcall;
+ TltsTextBlockSetColor = function(const aHandle: TltsTextBlockHandle; const aValue: TltsColor4f): TltsErrorCode; stdcall;
+ TltsTextBlockSetFont = function(const aHandle: TltsTextBlockHandle; const aValue: TltsFontHandle): TltsErrorCode; stdcall;
+ TltsTextBlockGetActualHeight = function(const aHandle: TltsTextBlockHandle): Integer; stdcall;
+ TltsTextBlockGetTextWidthA = function(const aHandle: TltsTextBlockHandle; const aText: PAnsiChar): Integer; stdcall;
+ TltsTextBlockGetTextWidthW = function(const aHandle: TltsTextBlockHandle; const aText: PWideChar): Integer; stdcall;
+ TltsTextBlockTextOutA = function(const aHandle: TltsTextBlockHandle; const aText: PAnsiChar): TltsErrorCode; stdcall;
+ TltsTextBlockTextOutW = function(const aHandle: TltsTextBlockHandle; const aText: PWideChar): TltsErrorCode; stdcall;
+ TltsTextBlockDestroy = function(const aHandle: TltsTextBlockHandle): TltsErrorCode; stdcall;
+
+ TltsImageCreate = function(const aContext: TltsContextHandle): TltsImageHandle; stdcall;
+ TltsImageIsEmpty = function(const aHandle: TltsImageHandle; out aValue: Boolean): TltsErrorCode; stdcall;
+ TltsImageGetWidth = function(const aHandle: TltsImageHandle): Integer; stdcall;
+ TltsImageGetHeight = function(const aHandle: TltsImageHandle): Integer; stdcall;
+ TltsImageGetLineSize = function(const aHandle: TltsImageHandle): Integer; stdcall;
+ TltsImageGetDataSize = function(const aHandle: TltsImageHandle): Integer; stdcall;
+ TltsImageGetFormat = function(const aHandle: TltsImageHandle; out aValue: TltsFormat): TltsErrorCode; stdcall;
+ TltsImageGetData = function(const aHandle: TltsImageHandle): Pointer; stdcall;
+ TltsImageGetScanline = function(const aHandle: TltsImageHandle; const aIndex: Integer): Pointer; stdcall;
+ TltsImageGetPixelAt = function(const aHandle: TltsImageHandle; const aX, aY: Integer; out aColor: TltsColor4f): TltsErrorCode; stdcall;
+ TltsImageAssign = function(const aHandle, aSource: TltsImageHandle): TltsErrorCode; stdcall;
+ TltsImageCreateEmpty = function(const aHandle: TltsImageHandle; const aFormat: TltsFormat; const aWidth, aHeight: Integer): TltsErrorCode; stdcall;
+ TltsImageLoadFromFunc = function(const aHandle: TltsImageHandle; const aCallback: TltsImageLoadInternFunc; aArgs: Pointer): TltsErrorCode; stdcall;
+ TltsImageResize = function(const aHandle: TltsImageHandle; const aWidth, aHeight, aX, aY: Integer): TltsErrorCode; stdcall;
+ TltsImageFillColor = function(const aHandle: TltsImageHandle; const aColor: TltsColor4f; const aMask: TltsColorChannels; const aModes: TltsImageModes): TltsErrorCode; stdcall;
+ TltsImageFillPattern = function(const aHandle, aPattern: TltsImageHandle; const aX, aY: Integer; const aMask: TltsColorChannels; const aModes: TltsImageModes): TltsErrorCode; stdcall;
+ TltsImageBlend = function(const aHandle, aSource: TltsImageHandle; const aX, aY: Integer; const aBlendFunc: TltsImageBlendInternFunc; aArgs: Pointer): TltsErrorCode; stdcall;
+ TltsImageBlur = function(const aHandle: TltsImageHandle; const aHorzRad, aHorzStr, aVertRad, aVertStr: Single; const aMask: TltsColorChannels): TltsErrorCode; stdcall;
+ TltsImageDestroy = function(const aHandle: TltsImageHandle): TltsErrorCode; stdcall;
+
+ TltsPostProcessorAddRange = function(const aHandle: TltsPostProcessorHandle; const aUsage: TltsCharRangeUsage; const aStart, aStop: WideChar): TltsErrorCode; stdcall;
+ TltsPostProcessorAddChars = function(const aHandle: TltsPostProcessorHandle; const aUsage: TltsCharRangeUsage; const aChars: PWideChar): TltsErrorCode; stdcall;
+ TltsPostProcessorClearRanges = function(const aHandle: TltsPostProcessorHandle): TltsErrorCode; stdcall;
+ TltsPostProcessorFillColorCreate = function(const aContext: TltsContextHandle; const aColor: TltsColor4f; const aModes: TltsImageModes; const aChannels: TltsColorChannels): TltsPostProcessorHandle; stdcall;
+ TltsPostProcessorFillPatterCreate = function(const aContext: TltsContextHandle; const aPattern: TltsImageHandle; const aOwnsPatter: Boolean; const aPosition: TltsPosition; const aModes: TltsImageModes; const aChannels: TltsColorChannels): TltsPostProcessorHandle; stdcall;
+ TltsPostProcessorBorderCreate = function(const aContext: TltsContextHandle; const aWidth, aStrength: Single; const aColor: TltsColor4f; const aKeepSize: Boolean): TltsPostProcessorHandle; stdcall;
+ TltsPostProcessorShadowCreate = function(const aContext: TltsContextHandle; const aRadius, aStrength: Single; const aOffset: TltsPosition; const aColor: TltsColor4f): TltsPostProcessorHandle; stdcall;
+ TltsPostProcessorDestroy = function(const aHandle: TltsPostProcessorHandle): TltsErrorCode; stdcall;
+
+ TltsInitialize = function(): TltsErrorCode; stdcall;
+ TltsGetLastErrorCode = function(): TltsErrorCode; stdcall;
+ TltsGetLastErrorMsg = function(): PAnsiChar; stdcall;
+ TltsFinalize = function(): TltsErrorCode; stdcall;
+
+var
+ ltsContextCreate: TltsContextCreate;
+ ltsContextGetCodePage: TltsContextGetCodePage;
+ ltsContextGetDefaultChar: TltsContextGetDefaultChar;
+ ltsContextSetCodePage: TltsContextSetCodePage;
+ ltsContextSetDefaultChar: TltsContextSetDefaultChar;
+ ltsContextAnsiToWide: TltsContextAnsiToWide;
+ ltsContextDestroy: TltsContextDestroy;
+
+ ltsRendererCreate: TltsRendererCreate;
+ ltsRendererBeginBlock: TltsRendererBeginBlock;
+ ltsRendererEndBlock: TltsRendererEndBlock;
+ ltsRendererAbortBlock: TltsRendererAbortBlock;
+ ltsRendererGetTextWidthA: TltsRendererGetTextWidthA;
+ ltsRendererGetTextWidthW: TltsRendererGetTextWidthW;
+ ltsRendererDestroy: TltsRendererDestroy;
+
+ ltsFontCreatorCreate: TltsFontCreatorCreate;
+ ltsFontCreatorGetFontByName: TltsFontCreatorGetFontByName;
+ ltsFontCreatorGetFontByFile: TltsFontCreatorGetFontByFile;
+ ltsFontCreatorGetFontByStream: TltsFontCreatorGetFontByStream;
+ ltsFontCreatorDestroy: TltsFontCreatorDestroy;
+
+ ltsFontGetPostProcessor: TltsFontGetPostProcessor;
+ ltsFontGetTabWidth: TltsFontGetTabWidth;
+ ltsFontGetCharSpacing: TltsFontGetCharSpacing;
+ ltsFontGetLineSpacing: TltsFontGetLineSpacing;
+ ltsFontGetMetric: TltsFontGetMetric;
+ ltsFontGetFontname: TltsFontGetFontname;
+ ltsFontGetFacename: TltsFontGetFacename;
+ ltsFontGetStylename: TltsFontGetStylename;
+ ltsFontGetFullname: TltsFontGetFullname;
+ ltsFontGetCopyright: TltsFontGetCopyright;
+ ltsFontSetPostProcessor: TltsFontSetPostProcessor;
+ ltsFontSetTabWidth: TltsFontSetTabWidth;
+ ltsFontSetCharSpacing: TltsFontSetCharSpacing;
+ ltsFontSetLineSpacing: TltsFontSetLineSpacing;
+ ltsFontDestroy: TltsFontDestroy;
+
+ ltsTextBlockGetRect: TltsTextBlockGetRect;
+ ltsTextBlockGetWidth: TltsTextBlockGetWidth;
+ ltsTextBlockGetHeight: TltsTextBlockGetHeight;
+ ltsTextBlockGetFlags: TltsTextBlockGetFlags;
+ ltsTextBlockGetTop: TltsTextBlockGetTop;
+ ltsTextBlockGetLeft: TltsTextBlockGetLeft;
+ ltsTextBlockGetVertAlign: TltsTextBlockGetVertAlign;
+ ltsTextBlockGetHorzAlign: TltsTextBlockGetHorzAlign;
+ ltsTextBlockGetClipping: TltsTextBlockGetClipping;
+ ltsTextBlockGetColor: TltsTextBlockGetColor;
+ ltsTextBlockGetFont: TltsTextBlockGetFont;
+ ltsTextBlockSetTop: TltsTextBlockSetTop;
+ ltsTextBlockSetLeft: TltsTextBlockSetLeft;
+ ltsTextBlockSetVertAlign: TltsTextBlockSetVertAlign;
+ ltsTextBlockSetHorzAlign: TltsTextBlockSetHorzAlign;
+ ltsTextBlockSetClipping: TltsTextBlockSetClipping;
+ ltsTextBlockSetColor: TltsTextBlockSetColor;
+ ltsTextBlockSetFont: TltsTextBlockSetFont;
+ ltsTextBlockGetActualHeight: TltsTextBlockGetActualHeight;
+ ltsTextBlockGetTextWidthA: TltsTextBlockGetTextWidthA;
+ ltsTextBlockGetTextWidthW: TltsTextBlockGetTextWidthW;
+ ltsTextBlockTextOutA: TltsTextBlockTextOutA;
+ ltsTextBlockTextOutW: TltsTextBlockTextOutW;
+ ltsTextBlockDestroy: TltsTextBlockDestroy;
+
+ ltsImageCreate: TltsImageCreate;
+ ltsImageIsEmpty: TltsImageIsEmpty;
+ ltsImageGetWidth: TltsImageGetWidth;
+ ltsImageGetHeight: TltsImageGetHeight;
+ ltsImageGetLineSize: TltsImageGetLineSize;
+ ltsImageGetDataSize: TltsImageGetDataSize;
+ ltsImageGetFormat: TltsImageGetFormat;
+ ltsImageGetData: TltsImageGetData;
+ ltsImageGetScanline: TltsImageGetScanline;
+ ltsImageGetPixelAt: TltsImageGetPixelAt;
+ ltsImageAssign: TltsImageAssign;
+ ltsImageCreateEmpty: TltsImageCreateEmpty;
+ ltsImageLoadFromFunc: TltsImageLoadFromFunc;
+ ltsImageResize: TltsImageResize;
+ ltsImageFillColor: TltsImageFillColor;
+ ltsImageFillPattern: TltsImageFillPattern;
+ ltsImageBlend: TltsImageBlend;
+ ltsImageBlur: TltsImageBlur;
+ ltsImageDestroy: TltsImageDestroy;
+
+ ltsPostProcessorAddRange: TltsPostProcessorAddRange;
+ ltsPostProcessorAddChars: TltsPostProcessorAddChars;
+ ltsPostProcessorClearRanges: TltsPostProcessorClearRanges;
+ ltsPostProcessorFillColorCreate: TltsPostProcessorFillColorCreate;
+ ltsPostProcessorFillPatterCreate: TltsPostProcessorFillPatterCreate;
+ ltsPostProcessorBorderCreate: TltsPostProcessorBorderCreate;
+ ltsPostProcessorShadowCreate: TltsPostProcessorShadowCreate;
+ ltsPostProcessorDestroy: TltsPostProcessorDestroy;
+
+ ltsGetLastErrorCode: TltsGetLastErrorCode;
+ ltsGetLastErrorMsg: TltsGetLastErrorMsg;
+
+procedure ltsInitialize(const aLibName: String);
+procedure ltsFinalize;
+
+type
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsException = class(Exception)
+ private
+ fErrorCode: TltsErrorCode;
+ public
+ property ErrorCode: TltsErrorCode read fErrorCode;
+ constructor Create(const aMessage: String; const aErrorCode: TltsErrorCode = ltsErrNone);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsContext = class(TObject)
+ private
+ fHandle: TltsContextHandle;
+ function GetCodePage: TltsCodePage;
+ function GetDefaultChar: WideChar;
+ procedure SetCodePage(aValue: TltsCodePage);
+ procedure SetDefaultChar(aValue: WideChar);
+ public
+ property Handle: TltsContextHandle read fHandle;
+ property CodePage: TltsCodePage read GetCodePage write SetCodePage;
+ property DefaultChar: WideChar read GetDefaultChar write SetDefaultChar;
+
+ constructor Create;
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsFont = class(TObject)
+ private
+ fHandle: TltsFontHandle;
+ fNames: TltsFontNames;
+ fMetric: TltsFontMetric;
+
+ function GetCharSpacing: Integer;
+ function GetLineSpacing: Single;
+ function GetTabWidth: Integer;
+
+ procedure SetCharSpacing(aValue: Integer);
+ procedure SetLineSpacing(aValue: Single);
+ procedure SetTabWidth(aValue: Integer);
+ public
+ property Handle: TltsFontHandle read fHandle;
+ property Names: TltsFontNames read fNames;
+ property Metric: TltsFontMetric read fMetric;
+
+ property TabWidth: Integer read GetTabWidth write SetTabWidth;
+ property CharSpacing: Integer read GetCharSpacing write SetCharSpacing;
+ property LineSpacing: Single read GetLineSpacing write SetLineSpacing;
+
+ constructor Create(const aHandle: TltsFontHandle);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsFontCreator = class(TObject)
+ private
+ fHandle: TltsFontCreatorHandle;
+ public
+ property Handle: TltsFontCreatorHandle read fHandle;
+
+ function GetFontByName (const aFontname: String; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont;
+ function GetFontByFile (const aFilename: String; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont;
+ function GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont;
+
+ constructor Create(const aHandle: TltsFontCreatorHandle);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsFontCreatorGDI = class(TltsFontCreator)
+ public
+ constructor Create(const aContext: TltsContext);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsFontCreatorFreeType = class(TltsFontCreator)
+ public
+ constructor Create(const aContext: TltsContext);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsTextBlock = class(TObject)
+ private
+ fHandle: TltsTextBlockHandle;
+ fCurrentFont: TltsFont;
+
+ function GetClipping: TltsClipping;
+ function GetColor: TltsColor4f;
+ function GetFlags: TltsBlockFlags;
+ function GetHeight: Integer;
+ function GetHorzAlign: TltsHorzAlignment;
+ function GetLeft: Integer;
+ function GetRect: TltsRect;
+ function GetTop: Integer;
+ function GetVertAlign: TltsVertAlignment;
+ function GetWidth: Integer;
+
+ procedure SetClipping(aValue: TltsClipping);
+ procedure SetColor(aValue: TltsColor4f);
+ procedure SetCurrentFont(aValue: TltsFont);
+ procedure SetHorzAlign(aValue: TltsHorzAlignment);
+ procedure SetLeft(aValue: Integer);
+ procedure SetTop(aValue: Integer);
+ procedure SetVertAlign(aValue: TltsVertAlignment);
+ public
+ property Handle: TltsTextBlockHandle read fHandle;
+ property Rect: TltsRect read GetRect;
+ property Width: Integer read GetWidth;
+ property Height: Integer read GetHeight;
+ property Flags: TltsBlockFlags read GetFlags;
+
+ property Top: Integer read GetTop write SetTop;
+ property Left: Integer read GetLeft write SetLeft;
+ property VertAlign: TltsVertAlignment read GetVertAlign write SetVertAlign;
+ property HorzAlign: TltsHorzAlignment read GetHorzAlign write SetHorzAlign;
+ property Clipping: TltsClipping read GetClipping write SetClipping;
+ property CurrentColor: TltsColor4f read GetColor write SetColor;
+ property CurrentFont: TltsFont read fCurrentFont write SetCurrentFont;
+
+ function GetActualBlockHeight: Integer;
+
+ procedure ChangeFont(const aFont: TltsFont);
+ procedure ChangeColor(const aColor: TltsColor4f);
+
+ procedure TextOutA(const aText: PAnsiChar);
+ procedure TextOutW(const aText: PWideChar);
+
+ function GetTextWidthA(const aText: PAnsiChar): Integer;
+ function GetTextWidthW(const aText: PWideChar): Integer;
+
+ constructor Create(const aHandle: TltsTextBlockHandle);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsRenderer = class(TObject)
+ private
+ fHandle: TltsRendererHandle;
+ public
+ property Handle: TltsRendererHandle read fHandle;
+
+ function BeginBlock(const aTop, aLeft, aWidth, aHeight: Integer; const aFlags: TltsBlockFlags): TltsTextBlock;
+ procedure EndBlock(var aTextBlock: TltsTextBlock);
+ procedure AbortBlock(var aTextBlock: TltsTextBlock);
+
+ function GetTextWidthA(const aFont: TltsFont; const aText: PAnsiChar): Integer;
+ function GetTextWidthW(const aFont: TltsFont; const aText: PWideChar): Integer;
+
+ constructor Create(const aHandle: TltsRendererHandle);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsRendererOpenGL = class(TltsRenderer)
+ public
+ constructor Create(const aContext: TltsContext; const aFormat: TltsFormat);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsRendererOpenGLES = class(TltsRenderer)
+ public
+ constructor Create(const aContext: TltsContext; const aFormat: TltsFormat);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsImage = class(TObject)
+ private
+ fHandle: TltsImageHandle;
+ function GetData: Pointer;
+ function GetDataSize: Integer;
+ function GetFormat: TltsFormat;
+ function GetHeight: Integer;
+ function GetIsEmpty: Boolean;
+ function GetLineSize: Integer;
+ function GetWidth: Integer;
+ function GetScanline(const aIndex: Integer): Pointer;
+ public
+ property Handle: TltsImageHandle read fHandle;
+
+ property IsEmpty: Boolean read GetIsEmpty;
+ property Width: Integer read GetWidth;
+ property Height: Integer read GetHeight;
+ property LineSize: Integer read GetLineSize;
+ property DataSize: Integer read GetDataSize;
+ property Format: TltsFormat read GetFormat;
+ property Data: Pointer read GetData;
+
+ property Scanline[const aIndex: Integer]: Pointer read GetScanline;
+
+ function GetPixelAt(const x, y: Integer; out aColor: TltsColor4f): Boolean;
+
+ procedure Assign(const aImage: TltsImage);
+ procedure CreateEmpty(const aFormat: TltsFormat; const aWidth, aHeight: Integer);
+ procedure LoadFromFunc(const aFunc: TltsImageLoadFunc; const aArgs: Pointer);
+
+ procedure Resize(const aWidth, aHeight, X, Y: Integer);
+ procedure FillColor(const aColor: TltsColor4f; const aMask: TltsColorChannels; const aModes: TltsImageModes);
+ procedure FillPatter(const aPattern: TltsImage; const X, Y: Integer; const aMask: TltsColorChannels; const aModes: TltsImageModes);
+ procedure Blend(const aImage: TltsImage; const X, Y: Integer; const aFunc: TltsImageBlendFunc; aArgs: Pointer);
+ procedure Blur(const aHorzRad, aHorzStr, aVertRad, aVertStr: Single; const aMask: TltsColorChannels);
+
+ constructor Create(const aContext: TltsContext);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsPostProcessor = class(TObject)
+ private
+ fHandle: TltsPostProcessorHandle;
+ public
+ property Handle: TltsPostProcessorHandle read fHandle;
+
+ procedure AddRange(const aUsage: TltsCharRangeUsage; const aStart, aStop: WideChar);
+ procedure AddChars(const aUsage: TltsCharRangeUsage; const aChars: PWideChar);
+ procedure ClearRanges;
+
+ constructor Create(const aHandle: TltsPostProcessorHandle);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsPostProcessorFillColor = class(TltsPostProcessor)
+ private
+ fColor: TltsColor4f;
+ fModes: TltsImageModes;
+ fChannels: TltsColorChannels;
+ public
+ property Color: TltsColor4f read fColor;
+ property Modes: TltsImageModes read fModes;
+ property Channels: TltsColorChannels read fChannels;
+
+ constructor Create(const aContext: TltsContext; const aColor: TltsColor4f; const aModes: TltsImageModes; const aChannels: TltsColorChannels);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsPostProcessorFillPattern = class(TltsPostProcessor)
+ private
+ fPattern: TltsImage;
+ fOwnsPattern: Boolean;
+ fPosition: TltsPosition;
+ fModes: TltsImageModes;
+ fChannels: TltsColorChannels;
+ public
+ property Pattern: TltsImage read fPattern;
+ property OwnsPattern: Boolean read fOwnsPattern;
+ property Position: TltsPosition read fPosition;
+ property Modes: TltsImageModes read fModes;
+ property Channels: TltsColorChannels read fChannels;
+
+ constructor Create(const aContext: TltsContext; const aPattern: TltsImage; const aOwnsPatter: Boolean; const aPosition: TltsPosition; const aModes: TltsImageModes; const aChannels: TltsColorChannels);
+ destructor Destroy; override;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsPostProcessorBorder = class(TltsPostProcessor)
+ private
+ fWidth: Single;
+ fStrength: Single;
+ fColor: TltsColor4f;
+ fKeepSize: Boolean;
+ public
+ property Width: Single read fWidth;
+ property Strength: Single read fStrength;
+ property Color: TltsColor4f read fColor;
+ property KeepSize: Boolean read fKeepSize;
+
+ constructor Create(const aContext: TltsContext; const aWidth, aStrength: Single; const aColor: TltsColor4f; const aKeepSize: Boolean);
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ TltsPostProcessorShadow = class(TltsPostProcessor)
+ private
+ fRadius: Single;
+ fStrength: Single;
+ fOffset: TltsPosition;
+ fColor: TltsColor4f;
+ public
+ property Radius: Single read fRadius;
+ property Strength: Single read fStrength;
+ property Offset: TltsPosition read fOffset;
+ property Color: TltsColor4f read fColor;
+
+ constructor Create(const aContext: TltsContext; const aRadius, aStrength: Single; const aOffset: TltsPosition; const aColor: TltsColor4f);
+ end;
+
+implementation
+
+{$IF DEFINED(WIN32) OR DEFINED(WIN64)}
+uses
+ windows;
+
+type
+ TLibHandle = HMODULE;
+
+const
+ InvalidLibHandle: TLibHandle = 0;
+
+function LibOpen(const aLibName: String; out aError: String): TLibHandle;
+begin
+ result := LoadLibraryA(PAnsiChar(AnsiString(aLibName)));
+ if (result = 0)
+ then aError := SysErrorMessage(GetLastError())
+ else aError := '';
+end;
+
+function GetAddr(const aLibHandle: TLibHandle; const aName: String): Pointer;
+begin
+ result := GetProcAddress(aLibHandle, PAnsiChar(AnsiString(aName)));
+end;
+
+procedure LibClose(const aLibHandle: TLibHandle);
+begin
+ FreeLibrary(aLibHandle);
+end;
+
+{$ELSEIF DEFINED(LINUX)}
+uses
+ dl;
+
+type
+ TLibHandle = Pointer;
+
+const
+ InvalidLibHandle: TLibHandle = nil;
+
+function LibOpen(const aLibName: String; out aError: String): TLibHandle;
+begin
+ dlerror();
+ result := dlopen(PChar(aLibName), RTLD_LAZY);
+ if (result = InvalidLibHandle)
+ then aError := dlerror()
+ else aError := '';
+end;
+
+function GetAddr(const aLibHandle: TLibHandle; const aName: String): Pointer;
+begin
+ result := dlsym(aLibHandle, PChar(aName));
+end;
+
+procedure LibClose(const aLibHandle: TLibHandle);
+begin
+ dlclose(aLibHandle);
+end;
+
+{$ELSE}
+ {$ERROR 'unknown operation system'}
+{$IFEND}
+
+var
+ libHandle: TLibHandle;
+ ltsInitializeIntern: TltsInitialize;
+ ltsFinalizeIntern: TltsFinalize;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Stream Callbacks//////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function ltsStreamReadCallback(const aArgs: Pointer; const aBuffer: Pointer; const aSize: Integer): Integer; stdcall;
+var
+ s: TStream;
+begin
+ result := 0;
+ if not Assigned(aArgs) then
+ exit;
+ s := TStream(aArgs);
+ result := s.Read(aBuffer^, aSize);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function ltsStreamSeekCallback(const aArgs: Pointer; const aOrigin: TltsStreamOrigin; const aPos: Integer): Integer; stdcall;
+var
+ s: TStream;
+begin
+ result := 0;
+ if not Assigned(aArgs) then
+ exit;
+ s := TStream(aArgs);
+ result := s.Seek(aPos, TSeekOrigin(aOrigin));
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Image Callbacks///////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+type
+ PImageLoadArgs = ^TImageLoadArgs;
+ TImageLoadArgs = packed record
+ callback: TltsImageLoadFunc;
+ image: TltsImage;
+ args: Pointer;
+ end;
+
+ PImageBlendArgs = ^TImageBlendArgs;
+ TImageBlendArgs = packed record
+ callback: TltsImageBlendFunc;
+ args: Pointer;
+ end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure ltsImageLoadCallback(const aHandle: TltsImageHandle; const X, Y: Integer; var aPixel: TltsColor4f; aArgs: Pointer); stdcall;
+var
+ p: PImageLoadArgs;
+begin
+ p := PImageLoadArgs(aArgs);
+ p^.callback(p^.image, X, Y, aPixel, p^.args);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function ltsImageBlendCallback(const aHandle: TltsImageHandle; const aSrc, aDst: TltsColor4f; aArgs: Pointer): TltsColor4f; stdcall;
+var
+ p: PImageBlendArgs;
+begin
+ p := PImageBlendArgs(aArgs);
+ result := p^.callback(aSrc, aDst, p^.args);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//General///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure ltsInitialize(const aLibName: String);
+
+ function LoadProc(const aName: String): Pointer;
+ begin
+ result := GetAddr(libHandle, aName);
+ if not Assigned(result) then
+ raise TltsException.CreateFmt('unable to load ''%s'' from ''%s''', [aName, aLibName]);
+ end;
+
+var
+ eMsg: String;
+ err: TltsErrorCode;
+begin
+ libHandle := LibOpen(aLibName, eMsg);
+ if (libHandle = InvalidLibHandle) then
+ raise TltsException.Create('unable to load library: ' + eMsg);
+
+ ltsContextCreate := TltsContextCreate( LoadProc('ltsContextCreate'));
+ ltsContextGetCodePage := TltsContextGetCodePage( LoadProc('ltsContextGetCodePage'));
+ ltsContextGetDefaultChar := TltsContextGetDefaultChar( LoadProc('ltsContextGetDefaultChar'));
+ ltsContextSetCodePage := TltsContextSetCodePage( LoadProc('ltsContextSetCodePage'));
+ ltsContextSetDefaultChar := TltsContextSetDefaultChar( LoadProc('ltsContextSetDefaultChar'));
+ ltsContextAnsiToWide := TltsContextAnsiToWide( LoadProc('ltsContextAnsiToWide'));
+ ltsContextDestroy := TltsContextDestroy( LoadProc('ltsContextDestroy'));
+
+ ltsRendererCreate := TltsRendererCreate( LoadProc('ltsRendererCreate'));
+ ltsRendererBeginBlock := TltsRendererBeginBlock( LoadProc('ltsRendererBeginBlock'));
+ ltsRendererEndBlock := TltsRendererEndBlock( LoadProc('ltsRendererEndBlock'));
+ ltsRendererAbortBlock := TltsRendererAbortBlock( LoadProc('ltsRendererAbortBlock'));
+ ltsRendererGetTextWidthA := TltsRendererGetTextWidthA( LoadProc('ltsRendererGetTextWidthA'));
+ ltsRendererGetTextWidthW := TltsRendererGetTextWidthW( LoadProc('ltsRendererGetTextWidthW'));
+ ltsRendererDestroy := TltsRendererDestroy( LoadProc('ltsRendererDestroy'));
+
+ ltsFontCreatorCreate := TltsFontCreatorCreate( LoadProc('ltsFontCreatorCreate'));
+ ltsFontCreatorGetFontByName := TltsFontCreatorGetFontByName( LoadProc('ltsFontCreatorGetFontByName'));
+ ltsFontCreatorGetFontByFile := TltsFontCreatorGetFontByFile( LoadProc('ltsFontCreatorGetFontByFile'));
+ ltsFontCreatorGetFontByStream := TltsFontCreatorGetFontByStream( LoadProc('ltsFontCreatorGetFontByStream'));
+ ltsFontCreatorDestroy := TltsFontCreatorDestroy( LoadProc('ltsFontCreatorDestroy'));
+ ltsFontGetPostProcessor := TltsFontGetPostProcessor( LoadProc('ltsFontGetPostProcessor'));
+ ltsFontGetTabWidth := TltsFontGetTabWidth( LoadProc('ltsFontGetTabWidth'));
+ ltsFontGetCharSpacing := TltsFontGetCharSpacing( LoadProc('ltsFontGetCharSpacing'));
+ ltsFontGetLineSpacing := TltsFontGetLineSpacing( LoadProc('ltsFontGetLineSpacing'));
+ ltsFontGetMetric := TltsFontGetMetric( LoadProc('ltsFontGetMetric'));
+ ltsFontGetFontname := TltsFontGetFontname( LoadProc('ltsFontGetFontname'));
+ ltsFontGetFacename := TltsFontGetFacename( LoadProc('ltsFontGetFacename'));
+ ltsFontGetStylename := TltsFontGetStylename( LoadProc('ltsFontGetStylename'));
+ ltsFontGetFullname := TltsFontGetFullname( LoadProc('ltsFontGetFullname'));
+ ltsFontGetCopyright := TltsFontGetCopyright( LoadProc('ltsFontGetCopyright'));
+ ltsFontSetPostProcessor := TltsFontSetPostProcessor( LoadProc('ltsFontSetPostProcessor'));
+ ltsFontSetTabWidth := TltsFontSetTabWidth( LoadProc('ltsFontSetTabWidth'));
+ ltsFontSetCharSpacing := TltsFontSetCharSpacing( LoadProc('ltsFontSetCharSpacing'));
+ ltsFontSetLineSpacing := TltsFontSetLineSpacing( LoadProc('ltsFontSetLineSpacing'));
+ ltsFontDestroy := TltsFontDestroy( LoadProc('ltsFontDestroy'));
+
+ ltsTextBlockGetRect := TltsTextBlockGetRect( LoadProc('ltsTextBlockGetRect'));
+ ltsTextBlockGetWidth := TltsTextBlockGetWidth( LoadProc('ltsTextBlockGetWidth'));
+ ltsTextBlockGetHeight := TltsTextBlockGetHeight( LoadProc('ltsTextBlockGetHeight'));
+ ltsTextBlockGetFlags := TltsTextBlockGetFlags( LoadProc('ltsTextBlockGetFlags'));
+ ltsTextBlockGetTop := TltsTextBlockGetTop( LoadProc('ltsTextBlockGetTop'));
+ ltsTextBlockGetLeft := TltsTextBlockGetLeft( LoadProc('ltsTextBlockGetLeft'));
+ ltsTextBlockGetVertAlign := TltsTextBlockGetVertAlign( LoadProc('ltsTextBlockGetVertAlign'));
+ ltsTextBlockGetHorzAlign := TltsTextBlockGetHorzAlign( LoadProc('ltsTextBlockGetHorzAlign'));
+ ltsTextBlockGetClipping := TltsTextBlockGetClipping( LoadProc('ltsTextBlockGetClipping'));
+ ltsTextBlockGetColor := TltsTextBlockGetColor( LoadProc('ltsTextBlockGetColor'));
+ ltsTextBlockGetFont := TltsTextBlockGetFont( LoadProc('ltsTextBlockGetFont'));
+ ltsTextBlockSetTop := TltsTextBlockSetTop( LoadProc('ltsTextBlockSetTop'));
+ ltsTextBlockSetLeft := TltsTextBlockSetLeft( LoadProc('ltsTextBlockSetLeft'));
+ ltsTextBlockSetVertAlign := TltsTextBlockSetVertAlign( LoadProc('ltsTextBlockSetVertAlign'));
+ ltsTextBlockSetHorzAlign := TltsTextBlockSetHorzAlign( LoadProc('ltsTextBlockSetHorzAlign'));
+ ltsTextBlockSetClipping := TltsTextBlockSetClipping( LoadProc('ltsTextBlockSetClipping'));
+ ltsTextBlockSetColor := TltsTextBlockSetColor( LoadProc('ltsTextBlockSetColor'));
+ ltsTextBlockSetFont := TltsTextBlockSetFont( LoadProc('ltsTextBlockSetFont'));
+ ltsTextBlockGetActualHeight := TltsTextBlockGetActualHeight( LoadProc('ltsTextBlockGetActualHeight'));
+ ltsTextBlockGetTextWidthA := TltsTextBlockGetTextWidthA( LoadProc('ltsTextBlockGetTextWidthA'));
+ ltsTextBlockGetTextWidthW := TltsTextBlockGetTextWidthW( LoadProc('ltsTextBlockGetTextWidthW'));
+ ltsTextBlockTextOutA := TltsTextBlockTextOutA( LoadProc('ltsTextBlockTextOutA'));
+ ltsTextBlockTextOutW := TltsTextBlockTextOutW( LoadProc('ltsTextBlockTextOutW'));
+ ltsTextBlockDestroy := TltsTextBlockDestroy( LoadProc('ltsTextBlockDestroy'));
+
+ ltsImageCreate := TltsImageCreate( LoadProc('ltsImageCreate'));
+ ltsImageIsEmpty := TltsImageIsEmpty( LoadProc('ltsImageIsEmpty'));
+ ltsImageGetWidth := TltsImageGetWidth( LoadProc('ltsImageGetWidth'));
+ ltsImageGetHeight := TltsImageGetHeight( LoadProc('ltsImageGetHeight'));
+ ltsImageGetLineSize := TltsImageGetLineSize( LoadProc('ltsImageGetLineSize'));
+ ltsImageGetDataSize := TltsImageGetDataSize( LoadProc('ltsImageGetDataSize'));
+ ltsImageGetFormat := TltsImageGetFormat( LoadProc('ltsImageGetFormat'));
+ ltsImageGetData := TltsImageGetData( LoadProc('ltsImageGetData'));
+ ltsImageGetScanline := TltsImageGetScanline( LoadProc('ltsImageGetScanline'));
+ ltsImageGetPixelAt := TltsImageGetPixelAt( LoadProc('lstImageGetPixelAt'));
+ ltsImageAssign := TltsImageAssign( LoadProc('ltsImageAssign'));
+ ltsImageCreateEmpty := TltsImageCreateEmpty( LoadProc('ltsImageCreateEmpty'));
+ ltsImageLoadFromFunc := TltsImageLoadFromFunc( LoadProc('ltsImageLoadFromFunc'));
+ ltsImageResize := TltsImageResize( LoadProc('ltsImageResize'));
+ ltsImageFillColor := TltsImageFillColor( LoadProc('ltsImageFillColor'));
+ ltsImageFillPattern := TltsImageFillPattern( LoadProc('ltsImageFillPattern'));
+ ltsImageBlend := TltsImageBlend( LoadProc('ltsImageBlend'));
+ ltsImageBlur := TltsImageBlur( LoadProc('ltsImageBlur'));
+ ltsImageDestroy := TltsImageDestroy( LoadProc('ltsImageDestroy'));
+
+ ltsPostProcessorAddRange := TltsPostProcessorAddRange( LoadProc('ltsPostProcessorAddRange'));
+ ltsPostProcessorAddChars := TltsPostProcessorAddChars( LoadProc('ltsPostProcessorAddChars'));
+ ltsPostProcessorClearRanges := TltsPostProcessorClearRanges( LoadProc('ltsPostProcessorClearRanges'));
+ ltsPostProcessorFillColorCreate := TltsPostProcessorFillColorCreate( LoadProc('ltsPostProcessorFillColorCreate'));
+ ltsPostProcessorFillPatterCreate := TltsPostProcessorFillPatterCreate( LoadProc('ltsPostProcessorFillPatterCreate'));
+ ltsPostProcessorBorderCreate := TltsPostProcessorBorderCreate( LoadProc('ltsPostProcessorBorderCreate'));
+ ltsPostProcessorShadowCreate := TltsPostProcessorShadowCreate( LoadProc('ltsPostProcessorShadowCreate'));
+ ltsPostProcessorDestroy := TltsPostProcessorDestroy( LoadProc('ltsPostProcessorShadowCreate'));
+
+ ltsInitializeIntern := TltsInitialize( LoadProc('ltsInitialize'));
+ ltsGetLastErrorCode := TltsGetLastErrorCode( LoadProc('ltsGetLastErrorCode'));
+ ltsGetLastErrorMsg := TltsGetLastErrorMsg( LoadProc('ltsGetLastErrorMsg'));
+ ltsFinalizeIntern := TltsFinalize( LoadProc('ltsFinalize'));
+
+ err := ltsInitializeIntern();
+ if (err <> ltsErrNone) then
+ raise TltsException.Create('error while initializing library: ' + ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure ltsFinalize;
+begin
+ if Assigned(ltsFinalizeIntern) then
+ ltsFinalizeIntern();
+
+ ltsContextCreate := nil;
+ ltsContextGetCodePage := nil;
+ ltsContextGetDefaultChar := nil;
+ ltsContextSetCodePage := nil;
+ ltsContextSetDefaultChar := nil;
+ ltsContextAnsiToWide := nil;
+ ltsContextDestroy := nil;
+
+ ltsRendererCreate := nil;
+ ltsRendererBeginBlock := nil;
+ ltsRendererEndBlock := nil;
+ ltsRendererAbortBlock := nil;
+ ltsRendererGetTextWidthA := nil;
+ ltsRendererGetTextWidthW := nil;
+ ltsRendererDestroy := nil;
+
+ ltsFontCreatorCreate := nil;
+ ltsFontCreatorGetFontByName := nil;
+ ltsFontCreatorGetFontByFile := nil;
+ ltsFontCreatorGetFontByStream := nil;
+ ltsFontCreatorDestroy := nil;
+ ltsFontGetPostProcessor := nil;
+ ltsFontGetTabWidth := nil;
+ ltsFontGetCharSpacing := nil;
+ ltsFontGetLineSpacing := nil;
+ ltsFontGetMetric := nil;
+ ltsFontGetFontname := nil;
+ ltsFontGetFacename := nil;
+ ltsFontGetStylename := nil;
+ ltsFontGetFullname := nil;
+ ltsFontGetCopyright := nil;
+ ltsFontSetPostProcessor := nil;
+ ltsFontSetTabWidth := nil;
+ ltsFontSetCharSpacing := nil;
+ ltsFontSetLineSpacing := nil;
+
+ ltsTextBlockGetRect := nil;
+ ltsTextBlockGetWidth := nil;
+ ltsTextBlockGetHeight := nil;
+ ltsTextBlockGetFlags := nil;
+ ltsTextBlockGetTop := nil;
+ ltsTextBlockGetLeft := nil;
+ ltsTextBlockGetVertAlign := nil;
+ ltsTextBlockGetHorzAlign := nil;
+ ltsTextBlockGetClipping := nil;
+ ltsTextBlockGetColor := nil;
+ ltsTextBlockGetFont := nil;
+ ltsTextBlockSetTop := nil;
+ ltsTextBlockSetLeft := nil;
+ ltsTextBlockSetVertAlign := nil;
+ ltsTextBlockSetHorzAlign := nil;
+ ltsTextBlockSetClipping := nil;
+ ltsTextBlockSetColor := nil;
+ ltsTextBlockSetFont := nil;
+ ltsTextBlockGetActualHeight := nil;
+ ltsTextBlockGetTextWidthA := nil;
+ ltsTextBlockGetTextWidthW := nil;
+ ltsTextBlockTextOutA := nil;
+ ltsTextBlockTextOutW := nil;
+
+ ltsImageCreate := nil;
+ ltsImageIsEmpty := nil;
+ ltsImageGetWidth := nil;
+ ltsImageGetHeight := nil;
+ ltsImageGetLineSize := nil;
+ ltsImageGetDataSize := nil;
+ ltsImageGetFormat := nil;
+ ltsImageGetData := nil;
+ ltsImageGetScanline := nil;
+ ltsImageGetPixelAt := nil;
+ ltsImageAssign := nil;
+ ltsImageCreateEmpty := nil;
+ ltsImageLoadFromFunc := nil;
+ ltsImageResize := nil;
+ ltsImageFillColor := nil;
+ ltsImageFillPattern := nil;
+ ltsImageBlend := nil;
+ ltsImageBlur := nil;
+ ltsImageDestroy := nil;
+
+ ltsPostProcessorAddRange := nil;
+ ltsPostProcessorAddChars := nil;
+ ltsPostProcessorClearRanges := nil;
+ ltsPostProcessorFillColorCreate := nil;
+ ltsPostProcessorFillPatterCreate := nil;
+ ltsPostProcessorBorderCreate := nil;
+ ltsPostProcessorShadowCreate := nil;
+
+ ltsInitializeIntern := nil;
+ ltsGetLastErrorCode := nil;
+ ltsGetLastErrorMsg := nil;
+ ltsFinalizeIntern := nil;
+
+ if (libHandle <> InvalidLibHandle) then begin
+ LibClose(libHandle);
+ libHandle := InvalidLibHandle;
+ end;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsException/////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsException.Create(const aMessage: String; const aErrorCode: TltsErrorCode);
+begin
+ inherited Create(aMessage);
+ fErrorCode := aErrorCode;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsContext///////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsContext.GetCodePage: TltsCodePage;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsContextGetCodePage(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsContext.GetDefaultChar: WideChar;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsContextGetDefaultChar(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsContext.SetCodePage(aValue: TltsCodePage);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsContextSetCodePage(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsContext.SetDefaultChar(aValue: WideChar);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsContextSetDefaultChar(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsContext.Create;
+begin
+ inherited Create;
+ fHandle := ltsContextCreate();
+ if not Assigned(fHandle) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsContext.Destroy;
+begin
+ if Assigned(fHandle) then begin
+ ltsContextDestroy(fHandle);
+ fHandle := nil;
+ end;
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsFont//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsFont.GetCharSpacing: Integer;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsFontGetCharSpacing(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsFont.GetLineSpacing: Single;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsFontGetLineSpacing(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsFont.GetTabWidth: Integer;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsFontGetTabWidth(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsFont.SetCharSpacing(aValue: Integer);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsFontSetCharSpacing(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsFont.SetLineSpacing(aValue: Single);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsFontSetLineSpacing(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsFont.SetTabWidth(aValue: Integer);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsFontSetTabWidth(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsFont.Create(const aHandle: TltsFontHandle);
+
+ procedure HandleErr(const aError: TltsErrorCode);
+ begin
+ if (aError <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), aError);
+ end;
+
+ procedure HandleName(const aValue: PAnsiChar; var aName: String);
+ begin
+ if not Assigned(aValue) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ aName := aValue;
+ end;
+
+begin
+ inherited Create;
+ fHandle := aHandle;
+
+ HandleErr (ltsFontGetMetric(fHandle, fMetric));
+ HandleName(ltsFontGetCopyright(fHandle), fNames.Copyright);
+ HandleName(ltsFontGetFacename(fHandle), fNames.Facename);
+ HandleName(ltsFontGetFontname(fHandle), fNames.Fontname);
+ HandleName(ltsFontGetFullname(fHandle), fNames.Fullname);
+ HandleName(ltsFontGetStylename(fHandle), fNames.Stylename);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsFont.Destroy;
+begin
+ if Assigned(fHandle) then begin
+ ltsFontDestroy(fHandle);
+ fHandle := nil;
+ end;
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsFontCreator///////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsFontCreator.GetFontByName(const aFontname: String; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont;
+var
+ h: TltsFontHandle;
+begin
+ h := ltsFontCreatorGetFontByName(fHandle, PAnsiChar(aFontname), aSize, aStyle, aAntiAliasing);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ result := TltsFont.Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsFontCreator.GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont;
+var
+ h: TltsFontHandle;
+begin
+ h := ltsFontCreatorGetFontByFile(fHandle, PAnsiChar(aFilename), aSize, aStyle, aAntiAliasing);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ result := TltsFont.Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsFontCreator.GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont;
+var
+ h: TltsFontHandle;
+ s: TltsStream;
+begin
+ s.args := Pointer(aStream);
+ s.read := @ltsStreamReadCallback;
+ s.seek := @ltsStreamSeekCallback;
+ h := ltsFontCreatorGetFontByStream(fHandle, @s, aSize, aStyle, aAntiAliasing);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ result := TltsFont.Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsFontCreator.Create(const aHandle: TltsFontCreatorHandle);
+begin
+ inherited Create;
+ fHandle := aHandle;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsFontCreator.Destroy;
+begin
+ if Assigned(fHandle) then begin
+ ltsFontCreatorDestroy(fHandle);
+ fHandle := nil;
+ end;
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsFontCreatorGDI////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsFontCreatorGDI.Create(const aContext: TltsContext);
+var
+ h: TltsFontCreatorHandle;
+begin
+ h := ltsFontCreatorCreate(aContext.Handle, ltsFontCreatorGDI);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsFontCreatorFreeType///////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsFontCreatorFreeType.Create(const aContext: TltsContext);
+var
+ h: TltsFontCreatorHandle;
+begin
+ h := ltsFontCreatorCreate(aContext.Handle, ltsFontCreatorFreeType);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsTextBlock/////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetClipping: TltsClipping;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetClipping(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetColor: TltsColor4f;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetColor(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetFlags: TltsBlockFlags;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetFlags(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetHeight: Integer;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetHeight(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetHorzAlign: TltsHorzAlignment;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetHorzAlign(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetLeft: Integer;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetLeft(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetRect: TltsRect;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetRect(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetTop: Integer;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetTop(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetVertAlign: TltsVertAlignment;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetVertAlign(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetWidth: Integer;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockGetWidth(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetClipping(aValue: TltsClipping);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockSetClipping(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetColor(aValue: TltsColor4f);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockSetColor(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetCurrentFont(aValue: TltsFont);
+var
+ err: TltsErrorCode;
+begin
+ fCurrentFont := aValue;
+ err := ltsTextBlockSetFont(fHandle, fCurrentFont.Handle);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetHorzAlign(aValue: TltsHorzAlignment);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockSetHorzAlign(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetLeft(aValue: Integer);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockSetLeft(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetTop(aValue: Integer);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockSetTop(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.SetVertAlign(aValue: TltsVertAlignment);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockSetVertAlign(fHandle, aValue);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetActualBlockHeight: Integer;
+begin
+ result := ltsTextBlockGetActualHeight(fHandle);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.ChangeFont(const aFont: TltsFont);
+begin
+ SetCurrentFont(aFont);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.ChangeColor(const aColor: TltsColor4f);
+begin
+ SetColor(aColor);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.TextOutA(const aText: PAnsiChar);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockTextOutA(fHandle, aText);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsTextBlock.TextOutW(const aText: PWideChar);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsTextBlockTextOutW(fHandle, aText);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetTextWidthA(const aText: PAnsiChar): Integer;
+begin
+ result := ltsTextBlockGetTextWidthA(fHandle, aText);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsTextBlock.GetTextWidthW(const aText: PWideChar): Integer;
+begin
+ result := ltsTextBlockGetTextWidthW(fHandle, aText);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsTextBlock.Create(const aHandle: TltsTextBlockHandle);
+begin
+ inherited Create;
+ fHandle := aHandle;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsTextBlock.Destroy;
+begin
+ if Assigned(fHandle) then begin
+ ltsTextBlockDestroy(fHandle);
+ fHandle := nil;
+ end;
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsRenderer//////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsRenderer.BeginBlock(const aTop, aLeft, aWidth, aHeight: Integer; const aFlags: TltsBlockFlags): TltsTextBlock;
+var
+ h: TltsTextBlockHandle;
+begin
+ h := ltsRendererBeginBlock(fHandle, aTop, aLeft, aWidth, aHeight, aFlags);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ result := TltsTextBlock.Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsRenderer.EndBlock(var aTextBlock: TltsTextBlock);
+var
+ err: TltsErrorCode;
+begin
+ try
+ err := ltsRendererEndBlock(fHandle, aTextBlock.Handle);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+ finally
+ FreeAndNil(aTextBlock);
+ end;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsRenderer.AbortBlock(var aTextBlock: TltsTextBlock);
+var
+ err: TltsErrorCode;
+begin
+ try
+ err := ltsRendererAbortBlock(fHandle, aTextBlock.Handle);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+ finally
+ FreeAndNil(aTextBlock);
+ end;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsRenderer.GetTextWidthA(const aFont: TltsFont; const aText: PAnsiChar): Integer;
+begin
+ result := ltsRendererGetTextWidthA(fHandle, aFont.Handle, aText);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsRenderer.GetTextWidthW(const aFont: TltsFont; const aText: PWideChar): Integer;
+begin
+ result := ltsRendererGetTextWidthW(fHandle, aFont.Handle, aText);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsRenderer.Create(const aHandle: TltsRendererHandle);
+begin
+ inherited Create;
+ fHandle := aHandle;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsRenderer.Destroy;
+begin
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsRendererOpenGL////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsRendererOpenGL.Create(const aContext: TltsContext; const aFormat: TltsFormat);
+var
+ h: TltsRendererHandle;
+begin
+ h := ltsRendererCreate(aContext.Handle, ltsRendererOpenGL, aFormat);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsRendererOpenGLES//////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsRendererOpenGLES.Create(const aContext: TltsContext; const aFormat: TltsFormat);
+var
+ h: TltsRendererHandle;
+begin
+ h := ltsRendererCreate(aContext.Handle, ltsRendererOpenGLES, aFormat);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsImage/////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetData: Pointer;
+begin
+ result := ltsImageGetData(fHandle);
+ if not Assigned(result) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetDataSize: Integer;
+begin
+ result := ltsImageGetDataSize(fHandle);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetFormat: TltsFormat;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageGetFormat(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetHeight: Integer;
+begin
+ result := ltsImageGetHeight(fHandle);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetIsEmpty: Boolean;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageIsEmpty(fHandle, result);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetLineSize: Integer;
+begin
+ result := ltsImageGetLineSize(fHandle);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetWidth: Integer;
+begin
+ result := ltsImageGetWidth(fHandle);
+ if (result < 0) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetScanline(const aIndex: Integer): Pointer;
+begin
+ result := ltsImageGetScanline(fHandle, aIndex);
+ if not Assigned(result) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TltsImage.GetPixelAt(const x, y: Integer; out aColor: TltsColor4f): Boolean;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageGetPixelAt(fHandle, x, y, aColor);
+ case err of
+ ltsErrNone: result := true;
+ ltsErrInvalidValue: result := false;
+ else
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+ end;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.Assign(const aImage: TltsImage);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageAssign(fHandle, aImage.Handle);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.CreateEmpty(const aFormat: TltsFormat; const aWidth, aHeight: Integer);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageCreateEmpty(fHandle, aFormat, aWidth, aHeight);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.LoadFromFunc(const aFunc: TltsImageLoadFunc; const aArgs: Pointer);
+var
+ err: TltsErrorCode;
+ ila: TImageLoadArgs;
+begin
+ ila.args := aArgs;
+ ila.callback := aFunc;
+ ila.image := self;
+ err := ltsImageLoadFromFunc(fHandle, @ltsImageLoadCallback, @ila);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.Resize(const aWidth, aHeight, X, Y: Integer);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageResize(fHandle, aWidth, aHeight, X, Y);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.FillColor(const aColor: TltsColor4f; const aMask: TltsColorChannels; const aModes: TltsImageModes);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageFillColor(fHandle, aColor, aMask, aModes);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.FillPatter(const aPattern: TltsImage; const X, Y: Integer; const aMask: TltsColorChannels; const aModes: TltsImageModes);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageFillPattern(fHandle, aPattern.Handle, X, Y, aMask, aModes);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.Blend(const aImage: TltsImage; const X, Y: Integer; const aFunc: TltsImageBlendFunc; aArgs: Pointer);
+var
+ err: TltsErrorCode;
+ iba: TImageBlendArgs;
+begin
+ iba.callback := aFunc;
+ iba.args := aArgs;
+ err := ltsImageLoadFromFunc(fHandle, @ltsImageLoadCallback, @iba);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsImage.Blur(const aHorzRad, aHorzStr, aVertRad, aVertStr: Single; const aMask: TltsColorChannels);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsImageBlur(fHandle, aHorzRad, aHorzStr, aVertRad, aVertStr, aMask);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsImage.Create(const aContext: TltsContext);
+begin
+ fHandle := ltsImageCreate(aContext.Handle);
+ if not Assigned(fHandle) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsImage.Destroy;
+begin
+ if Assigned(fHandle) then begin
+ ltsImageDestroy(fHandle);
+ fHandle := nil;
+ end;
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsPostProcessor/////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsPostProcessor.AddRange(const aUsage: TltsCharRangeUsage; const aStart, aStop: WideChar);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsPostProcessorAddRange(fHandle, aUsage, aStart, aStop);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsPostProcessor.AddChars(const aUsage: TltsCharRangeUsage; const aChars: PWideChar);
+var
+ err: TltsErrorCode;
+begin
+ err := ltsPostProcessorAddChars(fHandle, aUsage, aChars);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+procedure TltsPostProcessor.ClearRanges;
+var
+ err: TltsErrorCode;
+begin
+ err := ltsPostProcessorClearRanges(fHandle);
+ if (err <> ltsErrNone) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), err);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsPostProcessor.Create(const aHandle: TltsPostProcessorHandle);
+begin
+ inherited Create;
+ fHandle := aHandle;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsPostProcessor.Destroy;
+begin
+ if Assigned(fHandle) then begin
+ ltsPostProcessorDestroy(fHandle);
+ fHandle := nil;
+ end;
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsPostProcessorFillColor////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsPostProcessorFillColor.Create(const aContext: TltsContext; const aColor: TltsColor4f;
+ const aModes: TltsImageModes; const aChannels: TltsColorChannels);
+var
+ h: TltsPostProcessorHandle;
+begin
+ fColor := aColor;
+ fModes := aModes;
+ fChannels := aChannels;
+ h := ltsPostProcessorFillColorCreate(aContext.Handle, fColor, fModes, fChannels);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsPostProcessorFillPattern//////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsPostProcessorFillPattern.Create(const aContext: TltsContext; const aPattern: TltsImage; const aOwnsPatter: Boolean;
+ const aPosition: TltsPosition; const aModes: TltsImageModes; const aChannels: TltsColorChannels);
+var
+ h: TltsPostProcessorHandle;
+begin
+ fPattern := aPattern;
+ fOwnsPattern := aOwnsPatter;
+ fPosition := aPosition;
+ fModes := aModes;
+ fChannels := aChannels;
+ h := ltsPostProcessorFillPatterCreate(aContext.Handle, fPattern, fOwnsPattern, fPosition, fModes, fChannels);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+destructor TltsPostProcessorFillPattern.Destroy;
+begin
+ if Assigned(fPattern) and fOwnsPattern then
+ FreeAndNil(fPattern);
+ inherited Destroy;
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsPostProcessorBorder///////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsPostProcessorBorder.Create(const aContext: TltsContext; const aWidth, aStrength: Single;
+ const aColor: TltsColor4f; const aKeepSize: Boolean);
+var
+ h: TltsPostProcessorHandle;
+begin
+ fWidth := aWidth;
+ fStrength := aStrength;
+ fColor := aColor;
+ fKeepSize := aKeepSize;
+ h := ltsPostProcessorBorderCreate(aContext.Handle, fWidth, fStrength, fColor, fKeepSize);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TltsPostProcessorShadow///////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+constructor TltsPostProcessorShadow.Create(const aContext: TltsContext; const aRadius, aStrength: Single;
+ const aOffset: TltsPosition; const aColor: TltsColor4f);
+var
+ h: TltsPostProcessorHandle;
+begin
+ fRadius := aRadius;
+ fStrength := aStrength;
+ fOffset := aOffset;
+ fColor := aColor;
+ h := ltsPostProcessorShadowCreate(aContext.Handle, fRadius, fStrength, fOffset, fColor);
+ if not Assigned(h) then
+ raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode());
+ inherited Create(h);
+end;
+
+end.
+
diff --git a/libTextSuite.lpi b/libTextSuite.lpi
index 1607976..b26456e 100644
--- a/libTextSuite.lpi
+++ b/libTextSuite.lpi
@@ -20,8 +20,336 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -91,7 +419,7 @@
-
+
@@ -102,6 +430,10 @@
+
+
+
+
diff --git a/libTextSuite.lpr b/libTextSuite.lpr
index 77105e8..b6d8b2f 100644
--- a/libTextSuite.lpr
+++ b/libTextSuite.lpr
@@ -17,6 +17,9 @@ exports
ltsRendererCreate,
ltsRendererBeginBlock,
ltsRendererEndBlock,
+ ltsRendererAbortBlock,
+ ltsRendererGetTextWidthA,
+ ltsRendererGetTextWidthW,
ltsRendererDestroy,
ltsFontCreatorCreate,
@@ -39,6 +42,7 @@ exports
ltsFontSetTabWidth,
ltsFontSetCharSpacing,
ltsFontSetLineSpacing,
+ ltsFontDestroy,
ltsTextBlockGetRect,
ltsTextBlockGetWidth,
@@ -63,6 +67,7 @@ exports
ltsTextBlockGetTextWidthW,
ltsTextBlockTextOutA,
ltsTextBlockTextOutW,
+ ltsTextBlockDestroy,
ltsImageCreate,
ltsImageIsEmpty,
@@ -73,7 +78,7 @@ exports
ltsImageGetFormat,
ltsImageGetData,
ltsImageGetScanline,
- lstImageGetPixelAt,
+ ltsImageGetPixelAt,
ltsImageAssign,
ltsImageCreateEmpty,
ltsImageLoadFromFunc,
@@ -91,16 +96,6 @@ exports
ltsPostProcessorFillPatterCreate,
ltsPostProcessorBorderCreate,
ltsPostProcessorShadowCreate,
- ltsPostProcessorListCreate,
- ltsPostProcessorListGetCount,
- ltsPostProcessorListGetItem,
- ltsPostProcessorListGetOwnsObjects,
- ltsPostProcessorListSetOwnsObjects,
- ltsPostProcessorListAdd,
- ltsPostProcessorListDel,
- ltsPostProcessorListClear,
- ltsPostProcessorListRem,
- ltsPostProcessorListIndexOf,
ltsInitialize,
ltsGetLastErrorCode,
diff --git a/ultsFont.pas b/ultsFont.pas
index 5591de7..2936e28 100644
--- a/ultsFont.pas
+++ b/ultsFont.pas
@@ -26,6 +26,8 @@ function ltsFontSetTabWidth (const aHandle: TltsFontHandle; const aV
function ltsFontSetCharSpacing (const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
function ltsFontSetLineSpacing (const aHandle: TltsFontHandle; const aValue: Single): TltsErrorCode; stdcall;
+function ltsFontDestroy (const aHandle: TltsFontHandle): TltsErrorCode; stdcall;
+
implementation
uses
@@ -280,5 +282,25 @@ begin
end;
end;
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function ltsFontDestroy(const aHandle: TltsFontHandle): TltsErrorCode; stdcall;
+var
+ f: TtsFont;
+begin
+ try
+ result := ltsErrNone;
+ if CheckFontHandle(aHandle, f) then begin
+ DelReference(ltsObjTypeFont, f);
+ FreeAndNil(f);
+ end else
+ result := LastErrorCode;
+ except
+ on ex: Exception do begin
+ SetLastError(ex);
+ result := LastErrorCode;
+ end;
+ end;
+end;
+
end.
diff --git a/ultsImage.pas b/ultsImage.pas
index 4db6c5a..c1f2361 100644
--- a/ultsImage.pas
+++ b/ultsImage.pas
@@ -10,8 +10,8 @@ uses
ultsTypes;
type
- TltsImageFunc = procedure(const aHandle: TltsImageHandle; const X, Y: Integer; var aPixel: TtsColor4f; aArgs: Pointer); stdcall;
- TltsBlendColorFunc = function (const aHandle: TltsImageHandle; const aSrc, aDst: TtsColor4f; aArgs: Pointer): TtsColor4f; stdcall;
+ TltsImageLoadFunc = procedure(const aHandle: TltsImageHandle; const X, Y: Integer; var aPixel: TtsColor4f; aArgs: Pointer); stdcall;
+ TltsImageBlendFunc = function (const aHandle: TltsImageHandle; const aSrc, aDst: TtsColor4f; aArgs: Pointer): TtsColor4f; stdcall;
function ltsImageCreate (const aContext: TltsContextHandle): TltsImageHandle; stdcall;
function ltsImageIsEmpty (const aHandle: TltsImageHandle; var aValue: Boolean): TltsErrorCode; stdcall;
@@ -22,14 +22,14 @@ function ltsImageGetDataSize (const aHandle: TltsImageHandle):
function ltsImageGetFormat (const aHandle: TltsImageHandle; var aValue: TtsFormat): TltsErrorCode; stdcall;
function ltsImageGetData (const aHandle: TltsImageHandle): Pointer; stdcall;
function ltsImageGetScanline (const aHandle: TltsImageHandle; const aIndex: Integer): Pointer; stdcall;
-function lstImageGetPixelAt (const aHandle: TltsImageHandle; const aX, aY: Integer; var aColor: TtsColor4f): TltsErrorCode; stdcall;
+function ltsImageGetPixelAt (const aHandle: TltsImageHandle; const aX, aY: Integer; var aColor: TtsColor4f): TltsErrorCode; stdcall;
function ltsImageAssign (const aHandle, aSource: TltsImageHandle): TltsErrorCode; stdcall;
function ltsImageCreateEmpty (const aHandle: TltsImageHandle; const aFormat: TtsFormat; const aWidth, aHeight: Integer): TltsErrorCode; stdcall;
-function ltsImageLoadFromFunc (const aHandle: TltsImageHandle; const aCallback: TltsImageFunc; aArgs: Pointer): TltsErrorCode; stdcall;
+function ltsImageLoadFromFunc (const aHandle: TltsImageHandle; const aCallback: TltsImageLoadFunc; aArgs: Pointer): TltsErrorCode; stdcall;
function ltsImageResize (const aHandle: TltsImageHandle; const aWidth, aHeight, aX, aY: Integer): TltsErrorCode; stdcall;
function ltsImageFillColor (const aHandle: TltsImageHandle; const aColor: TtsColor4f; const aMask: TtsColorChannels; const aModes: TtsImageModes): TltsErrorCode; stdcall;
function ltsImageFillPattern (const aHandle, aPattern: TltsImageHandle; const aX, aY: Integer; const aMask: TtsColorChannels; const aModes: TtsImageModes): TltsErrorCode; stdcall;
-function ltsImageBlend (const aHandle, aSource: TltsImageHandle; const aX, aY: Integer; const aBlendFunc: TltsBlendColorFunc; aArgs: Pointer): TltsErrorCode; stdcall;
+function ltsImageBlend (const aHandle, aSource: TltsImageHandle; const aX, aY: Integer; const aBlendFunc: TltsImageBlendFunc; aArgs: Pointer): TltsErrorCode; stdcall;
function ltsImageBlur (const aHandle: TltsImageHandle; const aHorzRad, aHorzStr, aVertRad, aVertStr: Single; const aMask: TtsColorChannels): TltsErrorCode; stdcall;
function ltsImageDestroy (const aHandle: TltsImageHandle): TltsErrorCode; stdcall;
@@ -43,14 +43,14 @@ type
TLoadArgs = packed record
args: Pointer;
handle: TltsImageHandle;
- callback: TltsImageFunc
+ callback: TltsImageLoadFunc
end;
PBlendArgs = ^TBlendArgs;
TBlendArgs = packed record
args: Pointer;
handle: TltsImageHandle;
- callback: TltsBlendColorFunc;
+ callback: TltsImageBlendFunc;
end;
procedure ImageLoadCallback(const aImage: TtsImage; X, Y: Integer; var aPixel: TtsColor4f; aArgs: Pointer);
@@ -234,7 +234,7 @@ begin
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function lstImageGetPixelAt(const aHandle: TltsImageHandle; const aX, aY: Integer; var aColor: TtsColor4f): TltsErrorCode; stdcall;
+function ltsImageGetPixelAt(const aHandle: TltsImageHandle; const aX, aY: Integer; var aColor: TtsColor4f): TltsErrorCode; stdcall;
var
img: TtsImage;
begin
@@ -301,7 +301,7 @@ begin
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsImageLoadFromFunc(const aHandle: TltsImageHandle; const aCallback: TltsImageFunc; aArgs: Pointer): TltsErrorCode; stdcall;
+function ltsImageLoadFromFunc(const aHandle: TltsImageHandle; const aCallback: TltsImageLoadFunc; aArgs: Pointer): TltsErrorCode; stdcall;
var
img: TtsImage;
la: TLoadArgs;
@@ -385,7 +385,7 @@ begin
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsImageBlend(const aHandle, aSource: TltsImageHandle; const aX, aY: Integer; const aBlendFunc: TltsBlendColorFunc; aArgs: Pointer): TltsErrorCode; stdcall;
+function ltsImageBlend(const aHandle, aSource: TltsImageHandle; const aX, aY: Integer; const aBlendFunc: TltsImageBlendFunc; aArgs: Pointer): TltsErrorCode; stdcall;
var
img, src: TtsImage;
ba: TBlendArgs;
diff --git a/ultsPostProcessor.pas b/ultsPostProcessor.pas
index 0670c51..5f8ce95 100644
--- a/ultsPostProcessor.pas
+++ b/ultsPostProcessor.pas
@@ -20,17 +20,7 @@ function ltsPostProcessorBorderCreate (const aContext: TltsContextHandle;
const aColor: TtsColor4f; const aKeepSize: Boolean): TltsPostProcessorHandle; stdcall;
function ltsPostProcessorShadowCreate (const aContext: TltsContextHandle; const aRadius, aStrength: Single;
const aOffset: TtsPosition; const aColor: TtsColor4f): TltsPostProcessorHandle; stdcall;
-
-function ltsPostProcessorListCreate (const aContext: TltsContextHandle): TltsPostProcessorHandle; stdcall;
-function ltsPostProcessorListGetCount (const aHandle: TltsPostProcessorHandle): Integer; stdcall;
-function ltsPostProcessorListGetItem (const aHandle: TltsPostProcessorHandle; const aIndex: Integer): TltsPostProcessorHandle; stdcall;
-function ltsPostProcessorListGetOwnsObjects (const aHandle: TltsPostProcessorHandle; var aValue: Boolean): TltsErrorCode; stdcall;
-function ltsPostProcessorListSetOwnsObjects (const aHandle: TltsPostProcessorHandle; const aValue: Boolean): TltsErrorCode; stdcall;
-function ltsPostProcessorListAdd (const aHandle, aItem: TltsPostProcessorHandle): TltsErrorCode; stdcall;
-function ltsPostProcessorListDel (const aHandle: TltsPostProcessorHandle; const aIndex: Integer): TltsErrorCode; stdcall;
-function ltsPostProcessorListClear (const aHandle: TltsPostProcessorHandle): TltsErrorCode; stdcall;
-function ltsPostProcessorListRem (const aHandle, aItem: TltsPostProcessorHandle): Integer; stdcall;
-function ltsPostProcessorListIndexOf (const aHandle, aItem: TltsPostProcessorHandle): Integer; stdcall;
+function ltsPostProcessorDestroy (const aHandle: TltsPostProcessorHandle): TltsErrorCode; stdcall;
implementation
@@ -127,8 +117,6 @@ begin
if CheckContextHandle(aContext, c) and CheckImageHandle(aPattern, img) then begin
pp := TtsPostProcessorFillPattern.Create(c, img, aOwnsPatter, aPosition, aModes, aChannels);
AddReference(ltsObjTypePostProcessor, pp);
- if aOwnsPatter then
- DelReference(ltsObjTypeImage, img);
result := pp;
end;
except
@@ -182,132 +170,19 @@ begin
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListCreate(const aContext: TltsContextHandle): TltsPostProcessorHandle; stdcall;
+function ltsPostProcessorDestroy(const aHandle: TltsPostProcessorHandle): TltsErrorCode; stdcall;
var
- c: TtsContext;
pp: TtsPostProcessor;
-begin
- try
- result := nil;
- if CheckContextHandle(aContext, c) then begin
- pp := TtsPostProcessorList.Create(c, false);
- AddReference(ltsObjTypePostProcessor, pp);
- result := pp;
- end;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := nil;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListGetCount(const aHandle: TltsPostProcessorHandle): Integer; stdcall;
-var
- pp: TtsPostProcessorList;
-begin
- try
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp)
- then result := pp.Count
- else result := -1;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := -1;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListGetItem(const aHandle: TltsPostProcessorHandle; const aIndex: Integer): TltsPostProcessorHandle; stdcall;
-var
- pp: TtsPostProcessorList;
-begin
- try
- result := nil;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp) then begin
- if (aIndex < 0) or (aIndex >= pp.Count)
- then SetLastError(ltsErrInvalidValue, 'index is out of range')
- else result := pp.Items[aIndex];
- end else
- result := nil;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := nil;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListGetOwnsObjects(const aHandle: TltsPostProcessorHandle; var aValue: Boolean): TltsErrorCode; stdcall;
-var
- pp: TtsPostProcessorList;
-begin
- try
- result := ltsErrNone;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp)
- then aValue := pp.OwnsObjects
- else result := LastErrorCode;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := LastErrorCode;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListSetOwnsObjects(const aHandle: TltsPostProcessorHandle; const aValue: Boolean): TltsErrorCode; stdcall;
-var
- pp: TtsPostProcessorList;
-begin
- try
- result := ltsErrNone;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp)
- then pp.OwnsObjects := aValue
- else result := LastErrorCode;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := LastErrorCode;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListAdd(const aHandle, aItem: TltsPostProcessorHandle): TltsErrorCode; stdcall;
-var
- pp, itm: TtsPostProcessorList;
begin
try
result := ltsErrNone;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp) and
- CheckPostProcessorHandle(aItem, TtsPostProcessor, itm)
- then pp.Add(itm)
- else result := LastErrorCode;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := LastErrorCode;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListDel(const aHandle: TltsPostProcessorHandle; const aIndex: Integer): TltsErrorCode; stdcall;
-var
- pp: TtsPostProcessorList;
-begin
- try
- result := ltsErrNone;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp) then begin
- if (aIndex < 0) or (aIndex >= pp.Count) then begin
- SetLastError(ltsErrInvalidValue, 'index is out of range');
- result := LastErrorCode
- end
- else pp.Delete(aIndex);
+ if CheckPostProcessorHandle(aHandle, TtsPostProcessor, pp) then begin
+ if (pp is TtsPostProcessorFillPattern) then with (pp as TtsPostProcessorFillPattern) do begin
+ if OwnsPattern then
+ DelReference(ltsObjTypeImage, Pattern);
+ end;
+ DelReference(ltsObjTypePostProcessor, pp);
+ FreeAndNil(pp);
end else
result := LastErrorCode;
except
@@ -318,61 +193,5 @@ begin
end;
end;
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListClear(const aHandle: TltsPostProcessorHandle): TltsErrorCode; stdcall;
-var
- pp: TtsPostProcessorList;
-begin
- try
- result := ltsErrNone;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp)
- then pp.ClearRanges
- else result := LastErrorCode;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := LastErrorCode;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListRem(const aHandle, aItem: TltsPostProcessorHandle): Integer; stdcall;
-var
- pp, itm: TtsPostProcessorList;
-begin
- try
- result := -1;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp) and
- CheckPostProcessorHandle(aItem, TtsPostProcessor, itm)
- then result := pp.Remove(itm)
- else result := -1;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := -1;
- end;
- end;
-end;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function ltsPostProcessorListIndexOf(const aHandle, aItem: TltsPostProcessorHandle): Integer; stdcall;
-var
- pp, itm: TtsPostProcessorList;
-begin
- try
- result := -1;
- if CheckPostProcessorHandle(aHandle, TtsPostProcessorList, pp) and
- CheckPostProcessorHandle(aItem, TtsPostProcessor, itm)
- then result := pp.IndexOf(itm)
- else result := -1;
- except
- on ex: Exception do begin
- SetLastError(ex);
- result := -1;
- end;
- end;
-end;
-
end.
diff --git a/ultsTextBlock.pas b/ultsTextBlock.pas
index 91054b3..a97d709 100644
--- a/ultsTextBlock.pas
+++ b/ultsTextBlock.pas
@@ -37,6 +37,8 @@ function ltsTextBlockGetTextWidthW (const aHandle: TltsTextBlockHandle; const a
function ltsTextBlockTextOutA (const aHandle: TltsTextBlockHandle; const aText: PAnsiChar): TltsErrorCode; stdcall;
function ltsTextBlockTextOutW (const aHandle: TltsTextBlockHandle; const aText: PWideChar): TltsErrorCode; stdcall;
+function ltsTextBlockDestroy (const aHandle: TltsTextBlockHandle): TltsErrorCode; stdcall;
+
implementation
uses
@@ -456,5 +458,25 @@ begin
end;
end;
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function ltsTextBlockDestroy(const aHandle: TltsTextBlockHandle): TltsErrorCode; stdcall;
+var
+ b: TtsTextBlock;
+begin
+ try
+ result := ltsErrNone;
+ if CheckTextBlockHandle(aHandle, b) then begin
+ DelReference(ltsObjTypeTextBlock, b);
+ FreeAndNil(b);
+ end else
+ result := LastErrorCode;
+ except
+ on ex: Exception do begin
+ SetLastError(ex);
+ result := LastErrorCode;
+ end;
+ end;
+end;
+
end.