From a3fcd76e3c5afc823a9c7db326ec071fce7ea915 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Wed, 28 Oct 2015 19:19:29 +0100 Subject: [PATCH] * implemented example for FPC * fixed some memleaks and double freed objects * updated submodule: TextSuite --- .gitignore | 3 +- TextSuite | 2 +- header/examples/Prototype.ttf | Bin 0 -> 29592 bytes header/examples/fpc/example.lpi | 5 + header/examples/fpc/example.lpr | 15 +- header/examples/fpc/uMainForm.lfm | 5 +- header/examples/fpc/uMainForm.pas | 92 ++- header/ulibTextSuite.pas | 1204 ++++++++++++++++------------- libTextSuite.lpi | 2 + libTextSuite.lpr | 5 + ultsRenderer.pas | 24 +- ultsUtils.pas | 16 + 12 files changed, 804 insertions(+), 569 deletions(-) create mode 100644 header/examples/Prototype.ttf diff --git a/.gitignore b/.gitignore index b921ed9..8a030c4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ debug/ *.dbg *.dll *.zip - +*.heaptrc +*.heaptrace diff --git a/TextSuite b/TextSuite index a5f9cf1..9ad90b9 160000 --- a/TextSuite +++ b/TextSuite @@ -1 +1 @@ -Subproject commit a5f9cf19e54f765078e9490a6d678b5b3f87a3dc +Subproject commit 9ad90b9f7ca02386ea5ee359638c556ca9f457b4 diff --git a/header/examples/Prototype.ttf b/header/examples/Prototype.ttf new file mode 100644 index 0000000000000000000000000000000000000000..c70bf00f47201e79fdf14cb5483302fe6ff8ffaf GIT binary patch literal 29592 zcmcJ&2YejG`8Pf@d%JtL*Zb*Cx?a@V>2zwAWLcKG+zU3iVH+FVuuU!H#<(X%m=b7huW`|Hh zh?N{qBrTw1M=U?MI zxpK{>BmcfDZ~!680?6;BLzZt?TQMn|C*+{dQC|7#bq6k4^TbJS5wgaJI()un$&u?R zB_9y7mOmd|yJXGsLsG4;5VFog2wS#(-NsEfs7H+@z2G({qT7LT5nJ&`VkdS$2XO#8i4)L8T*V)Vo45fz0(yxD$3EgM zeoy?w2N)oJz%mj543aXy5D6Clhm?~L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-R@Mz=gLaf@MdsUcc$cO~WTMmLGK3>LnZaK6o9wZ;AFT-?XGdlrwzi z;m!4poqHyMH?0F^H#-gqa*SC z>6IBM;~?a+8l`Rk-x>$*Isi_+uUw+Iwj8-E5!Z*>^V2*JM_cRB)=uQ|^LLe~uGq%c ziR|O=8xS1>ZAzd}8PuaJSrAWa!|DzP;(%S?SRTZ>`tT->0Q}-X_yfwJkA|T~ zMxhBMp!K9+OXT}CRUsy(2KcN)-5NwsG()PlK>oHuQnq22z7Ev53vtxlkVT`>)_zEZ z0bpc2nE-x23FBZ2xb{?FaXL8jOsr0v4K6zu9CbhJj<*0K02@_dozG%mXessyS_W+K z9fDSogAp&ZTI>$Q>4NVL#Cz~CjFThKFPjmY%l8F3274Cq9gR-Fn%)!PxjPv<8l4KC z-&X8TbOt$-Y{O1Q*vtyCJHNu7NqkSFE6A1DS?IUe1L+1t+}(uz6Zj5Bzc1}zbf?&_ z=x)UR-iy7~{)Cz8L)cH~5%MT@PkREprs=y6Jp(P7?|}9)_D*^Yvx?WTo6^}Bo#!Lw z=R)j~bTM{hx&-?zU5g!y?t`ZPCU#+ZhrEk<$BSZrq+38gS7EOrGge2$u(o;(b~pNn ze1cugKE-ZkpJNxZo!GtXOYC~|0p&CBkFodJ<=DsR1!};Ym+#O-<@&XUtzON>&oW{M M&Gjpr8gqpFA28ft3IG5A literal 0 HcmV?d00001 diff --git a/header/examples/fpc/example.lpi b/header/examples/fpc/example.lpi index c714e12..e4e502e 100644 --- a/header/examples/fpc/example.lpi +++ b/header/examples/fpc/example.lpi @@ -65,6 +65,10 @@ + + + + @@ -75,6 +79,7 @@ + diff --git a/header/examples/fpc/example.lpr b/header/examples/fpc/example.lpr index f312b5c..7c35927 100644 --- a/header/examples/fpc/example.lpr +++ b/header/examples/fpc/example.lpr @@ -6,12 +6,23 @@ uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} - Interfaces, // this includes the LCL widgetset - Forms, uMainForm, ulibTextSuite; + Interfaces, SysUtils, Forms, uMainForm, ulibTextSuite; {$R *.res} +{$IFDEF DUMP_HEAPTRACE} +var + heaptrcFile: String; +{$ENDIF} + begin +{$IFDEF DUMP_HEAPTRACE} + heaptrcFile := ChangeFileExt(Application.ExeName, '.heaptrc'); + if (FileExists(heaptrcFile)) then + DeleteFile(heaptrcFile); + SetHeapTraceOutput(heaptrcFile); +{$ENDIF} + RequireDerivedFormResource := True; Application.Initialize; Application.CreateForm(TMainForm, MainForm); diff --git a/header/examples/fpc/uMainForm.lfm b/header/examples/fpc/uMainForm.lfm index bb5091c..f89464c 100644 --- a/header/examples/fpc/uMainForm.lfm +++ b/header/examples/fpc/uMainForm.lfm @@ -1,12 +1,13 @@ object MainForm: TMainForm Left = 485 - Height = 240 + Height = 500 Top = 255 - Width = 320 + Width = 640 Caption = 'libTextSuite' OnCreate = FormCreate OnDestroy = FormDestroy OnPaint = FormPaint OnResize = FormResize + Position = poScreenCenter LCLVersion = '1.3' end diff --git a/header/examples/fpc/uMainForm.pas b/header/examples/fpc/uMainForm.pas index 681c3b7..d5eb601 100644 --- a/header/examples/fpc/uMainForm.pas +++ b/header/examples/fpc/uMainForm.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, - uglcContext; + uglcContext, ulibTextSuite; type TMainForm = class(TForm) @@ -16,6 +16,11 @@ type procedure FormResize(Sender: TObject); private fContext: TglcContext; + fltsContext: TltsContext; + fltsRenderer: TltsRendererOpenGL; + fltsCreator: TltsFontCreatorGDI; + fltsFont: TltsFont; + fltsPostProcessorList: TltsPostProcessorList; procedure Render; end; @@ -29,13 +34,38 @@ implementation uses dglOpenGL; +const + {$IF DEFINED(WIN32)} + LibName = '..\..\..\libTextSuite-i386-win32.dll'; + {$ELSEIF DEFINED(WIN64)} + LibName = '..\..\..\libTextSuite-x86_64-win64.dll'; + {$ELSEIF DEFINED(LINUX) AND DEFINED(CPU32)} + LibName = '../../../libTextSuite-i386-linux.so'; + {$ELSEIF DEFINED(LINUX) AND DEFINED(CPU64)} + LibName = '../../../libTextSuite-x86_64-linux.so'; + {$ELSE} + {$ERROR 'unknown operation system'} + {$IFEND} + + TEST_TEXT = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'; + + PATTER_DATA: array[0..15] of Byte = ( + $FF, $BF, $7F, $BF, + $BF, $FF, $BF, $7F, + $7F, $BF, $FF, $BF, + $BF, $7F, $BF, $FF); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //MainForm////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TMainForm.FormCreate(Sender: TObject); var pf: TglcContextPixelFormatSettings; + pp: TltsPostProcessor; + img: TltsImage; begin + ltsInitialize(LibName); + pf := TglcContext.MakePF(); fContext := TglcContext.GetPlatformClass.Create(self, pf); fContext.BuildContext; @@ -43,12 +73,43 @@ begin glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); + glClearColor(1.0, 1.0, 1.0, 1.0); + + fltsContext := TltsContext.Create; + fltsRenderer := TltsRendererOpenGL.Create(fltsContext, ltsFormatRGBA8); + fltsCreator := TltsFontCreatorGDI.Create(fltsContext); + + fltsPostProcessorList := TltsPostProcessorList.Create(fltsContext, true); + + img := TltsImage.Create(fltsContext); + img.CreateEmpty(ltsFormatAlpha8, 4, 4); + Move(PATTER_DATA[0], img.Data^, 16); + pp := TltsPostProcessorFillPattern.Create(fltsContext, img, true, ltsPosition(0, 0), LTS_IMAGE_MODES_MODULATE_ALL, LTS_COLOR_CHANNELS_RGBA); + pp.AddChars(ltsUsageInclude, 'Lorem'); + fltsPostProcessorList.Add(pp); + + pp := TltsPostProcessorFillColor.Create(fltsContext, ltsColor4f(0, 0, 0.5, 1), LTS_IMAGE_MODES_REPLACE_ALL, LTS_COLOR_CHANNELS_RGB); + pp.AddChars(ltsUsageExclude, 'e'); + fltsPostProcessorList.Add(pp); + + pp := TltsPostProcessorBorder.Create(fltsContext, 3.0, 0.5, ltsColor4f(0.0, 0.5, 0.0, 1.0), true); + pp.AddChars(ltsUsageInclude, 'e'); + fltsPostProcessorList.Add(pp); + + fltsFont := fltsCreator.GetFontByFile(ExpandFileName('../Prototype.ttf'), 40, [], ltsAANormal); + fltsFont.PostProcessor := fltsPostProcessorList; end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TMainForm.FormDestroy(Sender: TObject); begin + FreeAndNil(fltsFont); + FreeAndNil(fltsPostProcessorList); + FreeAndNil(fltsCreator); + FreeAndNil(fltsRenderer); + FreeAndNil(fltsContext); FreeAndNil(fContext); + ltsFinalize; end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -72,22 +133,25 @@ end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TMainForm.Render; -const - X = 100; var - w, h: Integer; + block: TltsTextBlock; 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; + glLoadIdentity; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + block := fltsRenderer.BeginBlock(10, 10, ClientWidth-20, ClientHeight-20, [ltsBlockFlagWordWrap]); + try + block.HorzAlign := ltsHorzAlignJustify; + block.ChangeFont(fltsFont); + block.ChangeColor(ltsColor4f(1.0, 1.0, 1.0, 1.0)); + block.TextOutW(TEST_TEXT); + finally + fltsRenderer.EndBlock(block); + end; + fContext.SwapBuffers; end; diff --git a/header/ulibTextSuite.pas b/header/ulibTextSuite.pas index 601b931..9cf8c05 100644 --- a/header/ulibTextSuite.pas +++ b/header/ulibTextSuite.pas @@ -240,6 +240,33 @@ type StrikeoutSize: Integer; end; +const + LTS_IMAGE_MODES_REPLACE_ALL: TltsImageModes = ( + ltsModeReplace, + ltsModeReplace, + ltsModeReplace, + ltsModeReplace); + LTS_IMAGE_MODES_MODULATE_ALPHA: TltsImageModes = ( + ltsModeReplace, + ltsModeReplace, + ltsModeReplace, + ltsModeModulate); + LTS_IMAGE_MODES_MODULATE_ALL: TltsImageModes = ( + ltsModeModulate, + ltsModeModulate, + ltsModeModulate, + ltsModeModulate); + + LTS_COLOR_CHANNELS_RGB: TltsColorChannels = [ + ltsChannelRed, + ltsChannelGreen, + ltsChannelBlue]; + LTS_COLOR_CHANNELS_RGBA: TltsColorChannels = [ + ltsChannelRed, + ltsChannelGreen, + ltsChannelBlue, + ltsChannelAlpha]; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Library Functions///////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -518,6 +545,13 @@ var procedure ltsInitialize(const aLibName: String); procedure ltsFinalize; +function ltsColor4f(r, g, b, a: Single): TltsColor4f; +function ltsPosition(const x, y: Integer): TltsPosition; +function ltsRect(const l, t, r, b: Integer): TltsRect; overload; +function ltsRect(const aTopLeft, aBottomRight: TltsPosition): TltsRect; overload; +function ltsVector4f(X, Y, Z, W: Single): TltsVector4f; +function ltsMatrix4f(X, Y, Z, P: TltsVector4f): TltsMatrix4f; + type //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TltsException = class(Exception) @@ -545,12 +579,150 @@ type destructor Destroy; override; end; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TltsChar = class(TObject) + private + fHandle: TltsCharHandle; + function GetCharCode: WideChar; + function GetGlyphMetric: TltsGlyphMetric; + procedure SetGlyphMetric(aValue: TltsGlyphMetric); + public + property Handle: TltsCharHandle read fHandle; + property CharCode: WideChar read GetCharCode; + property GlyphMetric: TltsGlyphMetric read GetGlyphMetric write SetGlyphMetric; + + constructor CreateFromHandle(const aHandle: TltsCharHandle); + end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TltsPostProcessor = class(TObject) + private + fHandle: TltsPostProcessorHandle; + protected + procedure Execute(const aChar: TltsChar; const aImage: TltsImage); virtual; + 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; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TltsPostProcessorCustom = class(TltsPostProcessor) + protected + procedure Execute(const aChar: TltsChar; const aImage: TltsImage); override; + public + constructor Create(const aContext: TltsContext); + end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TltsPostProcessorList = class(TltsPostProcessorCustom) + private + fItems: TObjectList; + + function GetCount: Integer; + function GetItem(const aIndex: Integer): TltsPostProcessor; + function GetOwnsObjects: Boolean; + + procedure SetOwnsObjects(aValue: Boolean); + + protected + procedure Execute(const aChar: TltsChar; const aImage: TltsImage); override; + + public + property Count: Integer read GetCount; + property OwnsObjects: Boolean read GetOwnsObjects write SetOwnsObjects; + + property Items[const aIndex: Integer]: TltsPostProcessor read GetItem; + + procedure Add(const aPostProcessor: TltsPostProcessor); + procedure Delete(const aIndex: Integer); + procedure Clear; + + function Remove(const aPostProcessor: TltsPostProcessor): Integer; + function IndexOf(const aPostProcessor: TltsPostProcessor): Integer; + + constructor Create(const aContext: TltsContext; const aOwnsObjects: Boolean); + destructor Destroy; override; + end; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TltsFont = class(TObject) private - fHandle: TltsFontHandle; - fNames: TltsFontNames; - fMetric: TltsFontMetric; + fHandle: TltsFontHandle; + fNames: TltsFontNames; + fMetric: TltsFontMetric; + fPostProcessor: TltsPostProcessor; function GetCharSpacing: Integer; function GetLineSpacing: Single; @@ -558,11 +730,13 @@ type procedure SetCharSpacing(aValue: Integer); procedure SetLineSpacing(aValue: Single); + procedure SetPostProcessor(aValue: TltsPostProcessor); procedure SetTabWidth(aValue: Integer); public - property Handle: TltsFontHandle read fHandle; - property Names: TltsFontNames read fNames; - property Metric: TltsFontMetric read fMetric; + property Handle: TltsFontHandle read fHandle; + property Names: TltsFontNames read fNames; + property Metric: TltsFontMetric read fMetric; + property PostProcessor: TltsPostProcessor read fPostProcessor write SetPostProcessor; property TabWidth: Integer read GetTabWidth write SetTabWidth; property CharSpacing: Integer read GetCharSpacing write SetCharSpacing; @@ -692,26 +866,11 @@ type 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 aHandle: TltsImageHandle); + constructor CreateFromHandle(const aHandle: TltsImageHandle); constructor Create(const aContext: TltsContext); destructor Destroy; override; end; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TltsChar = class(TObject) - private - fHandle: TltsCharHandle; - function GetCharCode: WideChar; - function GetGlyphMetric: TltsGlyphMetric; - procedure SetGlyphMetric(aValue: TltsGlyphMetric); - public - property Handle: TltsCharHandle read fHandle; - property CharCode: WideChar read GetCharCode; - property GlyphMetric: TltsGlyphMetric read GetGlyphMetric write SetGlyphMetric; - - constructor Create(const aHandle: TltsCharHandle); - end; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TltsRenderer = class(TObject) private @@ -762,161 +921,42 @@ type constructor Create(const aContext: TltsContext; const aFormat: TltsFormat); end; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TltsPostProcessor = class(TObject) - private - fHandle: TltsPostProcessorHandle; - protected - procedure Execute(const aChar: TltsChar; const aImage: TltsImage); virtual; - public - property Handle: TltsPostProcessorHandle read fHandle; +implementation - procedure AddRange(const aUsage: TltsCharRangeUsage; const aStart, aStop: WideChar); - procedure AddChars(const aUsage: TltsCharRangeUsage; const aChars: PWideChar); - procedure ClearRanges; +{$IF DEFINED(WIN32) OR DEFINED(WIN64)} +uses + windows; - constructor Create(const aHandle: TltsPostProcessorHandle); - destructor Destroy; override; - end; +type + TLibHandle = HMODULE; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - 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; +const + InvalidLibHandle: TLibHandle = 0; - constructor Create(const aContext: TltsContext; const aColor: TltsColor4f; const aModes: TltsImageModes; const aChannels: TltsColorChannels); - end; +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; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - 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; +function GetAddr(const aLibHandle: TLibHandle; const aName: String): Pointer; +begin + result := GetProcAddress(aLibHandle, PAnsiChar(AnsiString(aName))); +end; - constructor Create(const aContext: TltsContext; const aPattern: TltsImage; const aOwnsPatter: Boolean; const aPosition: TltsPosition; const aModes: TltsImageModes; const aChannels: TltsColorChannels); - destructor Destroy; override; - end; +procedure LibClose(const aLibHandle: TLibHandle); +begin + FreeLibrary(aLibHandle); +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; +{$ELSEIF DEFINED(LINUX)} +uses + dl; - 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; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TltsPostProcessorCustom = class(TltsPostProcessor) - public - constructor Create(const aContext: TltsContext); - end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TltsPostProcessorList = class(TltsPostProcessorCustom) - private - fItems: TObjectList; - - function GetCount: Integer; - function GetItem(const aIndex: Integer): TltsPostProcessor; - function GetOwnsObjects: Boolean; - - procedure SetOwnsObjects(aValue: Boolean); - - protected - procedure Execute(const aChar: TltsChar; const aImage: TltsImage); override; - - public - property Count: Integer read GetCount; - property OwnsObjects: Boolean read GetOwnsObjects write SetOwnsObjects; - - property Items[const aIndex: Integer]: TltsPostProcessor read GetItem; - - procedure Add(const aPostProcessor: TltsPostProcessor); - procedure Delete(const aIndex: Integer); - procedure Clear; - - function Remove(const aPostProcessor: TltsPostProcessor): Integer; - function IndexOf(const aPostProcessor: TltsPostProcessor): Integer; - - constructor Create(const aContext: TltsContext; const aOwnsObjects: Boolean); - destructor Destroy; override; - 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; +type + TLibHandle = Pointer; const InvalidLibHandle: TLibHandle = nil; @@ -1102,7 +1142,7 @@ begin ltsImageGetFormat := TltsImageGetFormat( LoadProc('ltsImageGetFormat')); ltsImageGetData := TltsImageGetData( LoadProc('ltsImageGetData')); ltsImageGetScanline := TltsImageGetScanline( LoadProc('ltsImageGetScanline')); - ltsImageGetPixelAt := TltsImageGetPixelAt( LoadProc('lstImageGetPixelAt')); + ltsImageGetPixelAt := TltsImageGetPixelAt( LoadProc('ltsImageGetPixelAt')); ltsImageAssign := TltsImageAssign( LoadProc('ltsImageAssign')); ltsImageCreateEmpty := TltsImageCreateEmpty( LoadProc('ltsImageCreateEmpty')); ltsImageLoadFromFunc := TltsImageLoadFromFunc( LoadProc('ltsImageLoadFromFunc')); @@ -1122,7 +1162,7 @@ begin ltsPostProcessorBorderCreate := TltsPostProcessorBorderCreate( LoadProc('ltsPostProcessorBorderCreate')); ltsPostProcessorShadowCreate := TltsPostProcessorShadowCreate( LoadProc('ltsPostProcessorShadowCreate')); ltsPostProcessorCustomCreate := TltsPostProcessorCustomCreate( LoadProc('ltsPostProcessorCustomCreate')); - ltsPostProcessorDestroy := TltsPostProcessorDestroy( LoadProc('ltsPostProcessorShadowCreate')); + ltsPostProcessorDestroy := TltsPostProcessorDestroy( LoadProc('ltsPostProcessorDestroy')); ltsCharGetCharCode := TltsCharGetCharCode( LoadProc('ltsCharGetCharCode')); ltsCharGetGlyphMetric := TltsCharGetGlyphMetric( LoadProc('ltsCharGetGlyphMetric')); @@ -1243,6 +1283,58 @@ begin end; end; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//Utils///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function ltsColor4f(r, g, b, a: Single): TltsColor4f; +begin + result.r := r; + result.g := g; + result.b := b; + result.a := a; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function ltsPosition(const x, y: Integer): TltsPosition; +begin + result.x := x; + result.y := y; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function ltsRect(const l, t, r, b: Integer): TltsRect; +begin + result.Left := l; + result.Top := t; + result.Right := r; + result.Bottom := b; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function ltsRect(const aTopLeft, aBottomRight: TltsPosition): TltsRect; +begin + result.TopLeft := aTopLeft; + result.BottomRight := aBottomRight; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function ltsVector4f(X, Y, Z, W: Single): TltsVector4f; +begin + result[0] := X; + result[1] := Y; + result[2] := Z; + result[3] := W; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function ltsMatrix4f(X, Y, Z, P: TltsVector4f): TltsMatrix4f; +begin + result[0] := X; + result[1] := Y; + result[2] := Z; + result[3] := P; +end; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TltsException///////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1314,180 +1406,486 @@ begin end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsFont////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TltsChar////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsFont.GetCharSpacing: Integer; +function TltsChar.GetCharCode: WideChar; var err: TltsErrorCode; begin - err := ltsFontGetCharSpacing(fHandle, result); + err := ltsCharGetCharCode(fHandle, result); if (err <> ltsErrNone) then raise TltsException.Create(ltsGetLastErrorMsg(), err); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsFont.GetLineSpacing: Single; +function TltsChar.GetGlyphMetric: TltsGlyphMetric; var err: TltsErrorCode; begin - err := ltsFontGetLineSpacing(fHandle, result); + err := ltsCharGetGlyphMetric(fHandle, result); if (err <> ltsErrNone) then raise TltsException.Create(ltsGetLastErrorMsg(), err); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsFont.GetTabWidth: Integer; +procedure TltsChar.SetGlyphMetric(aValue: TltsGlyphMetric); var err: TltsErrorCode; begin - err := ltsFontGetTabWidth(fHandle, result); + err := ltsCharSetGlyphMetric(fHandle, aValue); if (err <> ltsErrNone) then raise TltsException.Create(ltsGetLastErrorMsg(), err); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsFont.SetCharSpacing(aValue: Integer); +constructor TltsChar.CreateFromHandle(const aHandle: TltsCharHandle); +begin + inherited Create; + fHandle := aHandle; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TltsPostProcessor///////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessor.Execute(const aChar: TltsChar; const aImage: TltsImage); var err: TltsErrorCode; begin - err := ltsFontSetCharSpacing(fHandle, aValue); + err := ltsPostProcessorExecute(fHandle, aChar.Handle, aImage.Handle); if (err <> ltsErrNone) then raise TltsException.Create(ltsGetLastErrorMsg(), err); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsFont.SetLineSpacing(aValue: Single); +procedure TltsPostProcessor.AddRange(const aUsage: TltsCharRangeUsage; const aStart, aStop: WideChar); var err: TltsErrorCode; begin - err := ltsFontSetLineSpacing(fHandle, aValue); + err := ltsPostProcessorAddRange(fHandle, aUsage, aStart, aStop); if (err <> ltsErrNone) then raise TltsException.Create(ltsGetLastErrorMsg(), err); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsFont.SetTabWidth(aValue: Integer); +procedure TltsPostProcessor.AddChars(const aUsage: TltsCharRangeUsage; const aChars: PWideChar); var err: TltsErrorCode; begin - err := ltsFontSetTabWidth(fHandle, aValue); + err := ltsPostProcessorAddChars(fHandle, aUsage, aChars); 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; +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; - - 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; +destructor TltsPostProcessor.Destroy; begin if Assigned(fHandle) then begin - ltsFontDestroy(fHandle); + ltsPostProcessorDestroy(fHandle); fHandle := nil; end; inherited Destroy; end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsFontCreator/////////////////////////////////////////////////////////////////////////////////////////////////////// +//TltsPostProcessorFillColor//////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsFontCreator.GetFontByName(const aFontname: String; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont; +constructor TltsPostProcessorFillColor.Create(const aContext: TltsContext; const aColor: TltsColor4f; + const aModes: TltsImageModes; const aChannels: TltsColorChannels); var - h: TltsFontHandle; + h: TltsPostProcessorHandle; begin - h := ltsFontCreatorGetFontByName(fHandle, PAnsiChar(aFontname), aSize, aStyle, aAntiAliasing); + fColor := aColor; + fModes := aModes; + fChannels := aChannels; + h := ltsPostProcessorFillColorCreate(aContext.Handle, fColor, fModes, fChannels); if not Assigned(h) then raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode()); - result := TltsFont.Create(h); + inherited 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; - +//TltsPostProcessorFillPattern////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsFontCreator.GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TltsFontStyles; const aAntiAliasing: TltsAntiAliasing): TltsFont; +constructor TltsPostProcessorFillPattern.Create(const aContext: TltsContext; const aPattern: TltsImage; const aOwnsPatter: Boolean; + const aPosition: TltsPosition; const aModes: TltsImageModes; const aChannels: TltsColorChannels); var - h: TltsFontHandle; - s: TltsStream; + h: TltsPostProcessorHandle; begin - s.args := Pointer(aStream); - s.read := @ltsStreamReadCallback; - s.seek := @ltsStreamSeekCallback; - h := ltsFontCreatorGetFontByStream(fHandle, @s, aSize, aStyle, aAntiAliasing); + fPattern := aPattern; + fOwnsPattern := aOwnsPatter; + fPosition := aPosition; + fModes := aModes; + fChannels := aChannels; + h := ltsPostProcessorFillPatterCreate(aContext.Handle, fPattern.Handle, fOwnsPattern, fPosition, fModes, fChannels); 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; + inherited Create(h); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -destructor TltsFontCreator.Destroy; +destructor TltsPostProcessorFillPattern.Destroy; begin - if Assigned(fHandle) then begin - ltsFontCreatorDestroy(fHandle); - fHandle := nil; - end; inherited Destroy; + if Assigned(fPattern) and fOwnsPattern then + FreeAndNil(fPattern); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsFontCreatorGDI//////////////////////////////////////////////////////////////////////////////////////////////////// +//TltsPostProcessorBorder/////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -constructor TltsFontCreatorGDI.Create(const aContext: TltsContext); +constructor TltsPostProcessorBorder.Create(const aContext: TltsContext; const aWidth, aStrength: Single; + const aColor: TltsColor4f; const aKeepSize: Boolean); var - h: TltsFontCreatorHandle; + h: TltsPostProcessorHandle; begin - h := ltsFontCreatorCreate(aContext.Handle, ltsFontCreatorGDI); + 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; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsFontCreatorFreeType/////////////////////////////////////////////////////////////////////////////////////////////// +//TltsPostProcessorShadow/////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -constructor TltsFontCreatorFreeType.Create(const aContext: TltsContext); +constructor TltsPostProcessorShadow.Create(const aContext: TltsContext; const aRadius, aStrength: Single; + const aOffset: TltsPosition; const aColor: TltsColor4f); var - h: TltsFontCreatorHandle; + 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; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TltsPostProcessorCustom/////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure ltsPostProcessorExecuteCallback(const aChar: TltsCharHandle; const aImage: TltsImageHandle; aArgs: Pointer); +var + chr: TltsChar; + img: TltsImage; +begin + chr := TltsChar.CreateFromHandle(aChar); + img := TltsImage.CreateFromHandle(aImage); + try + TltsPostProcessorCustom(aArgs).Execute(chr, img); + finally + FreeAndNil(img); + FreeAndNil(chr); + end; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessorCustom.Execute(const aChar: TltsChar; const aImage: TltsImage); +begin + // calling inherited will cause infinite loop !!! +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +constructor TltsPostProcessorCustom.Create(const aContext: TltsContext); +var + h: TltsPostProcessorHandle; + p: TltsPostProcessorCustomData; +begin + p.args := self; + p.execute := @ltsPostProcessorExecuteCallback; + h := ltsPostProcessorCustomCreate(aContext.Handle, @p); + if not Assigned(h) then + raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode()); + inherited Create(h); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TltsPostProcessorList///////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TltsPostProcessorList.GetCount: Integer; +begin + result := fItems.Count; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TltsPostProcessorList.GetItem(const aIndex: Integer): TltsPostProcessor; +begin + result := TltsPostProcessor(fItems[aIndex]); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TltsPostProcessorList.GetOwnsObjects: Boolean; +begin + result := fItems.OwnsObjects; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessorList.SetOwnsObjects(aValue: Boolean); +begin + fItems.OwnsObjects := aValue; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessorList.Execute(const aChar: TltsChar; const aImage: TltsImage); +var + i: Integer; +begin + inherited Execute(aChar, aImage); + for i := 0 to fItems.Count-1 do + TltsPostProcessor(fItems[i]).Execute(aChar, aImage); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessorList.Add(const aPostProcessor: TltsPostProcessor); +begin + fItems.Add(aPostProcessor); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessorList.Delete(const aIndex: Integer); +begin + fItems.Delete(aIndex); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TltsPostProcessorList.Clear; +begin + fItems.Clear; +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TltsPostProcessorList.Remove(const aPostProcessor: TltsPostProcessor): Integer; +begin + result := fItems.Remove(aPostProcessor); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TltsPostProcessorList.IndexOf(const aPostProcessor: TltsPostProcessor): Integer; +begin + result := fItems.IndexOf(aPostProcessor); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +constructor TltsPostProcessorList.Create(const aContext: TltsContext; const aOwnsObjects: Boolean); +begin + inherited Create(aContext); + fItems := TObjectList.Create(aOwnsObjects); +end; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +destructor TltsPostProcessorList.Destroy; +begin + FreeAndNil(fItems); + 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.SetPostProcessor(aValue: TltsPostProcessor); +var + err: TltsErrorCode; +begin + err := ltsFontSetPostProcessor(fHandle, aValue.Handle); + 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 @@ -1913,7 +2311,7 @@ begin end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -constructor TltsImage.Create(const aHandle: TltsImageHandle); +constructor TltsImage.CreateFromHandle(const aHandle: TltsImageHandle); begin inherited Create; fHandle := aHandle; @@ -1927,55 +2325,16 @@ 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) and fOwnsHandle then - ltsImageDestroy(fHandle); - fHandle := nil; - inherited Destroy; -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsChar////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsChar.GetCharCode: WideChar; -var - err: TltsErrorCode; -begin - err := ltsCharGetCharCode(fHandle, result); - if (err <> ltsErrNone) then - raise TltsException.Create(ltsGetLastErrorMsg(), err); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsChar.GetGlyphMetric: TltsGlyphMetric; -var - err: TltsErrorCode; -begin - err := ltsCharGetGlyphMetric(fHandle, result); - if (err <> ltsErrNone) then - raise TltsException.Create(ltsGetLastErrorMsg(), err); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsChar.SetGlyphMetric(aValue: TltsGlyphMetric); -var - err: TltsErrorCode; -begin - err := ltsCharSetGlyphMetric(fHandle, aValue); - if (err <> ltsErrNone) then - raise TltsException.Create(ltsGetLastErrorMsg(), err); + inherited Create; end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -constructor TltsChar.Create(const aHandle: TltsCharHandle); +destructor TltsImage.Destroy; begin - inherited Create; - fHandle := aHandle; + if Assigned(fHandle) and fOwnsHandle then + ltsImageDestroy(fHandle); + fHandle := nil; + inherited Destroy; end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2124,8 +2483,8 @@ var chr: TltsChar; img: TltsImage; begin - chr := TltsChar.Create(aChar); - img := TltsImage.Create(aImage); + chr := TltsChar.CreateFromHandle(aChar); + img := TltsImage.CreateFromHandle(aImage); try result := TltsRendererCustom(aArgs).CreateRenderRef(chr, img); finally @@ -2217,256 +2576,5 @@ begin inherited Create(h); end; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsPostProcessor///////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsPostProcessor.Execute(const aChar: TltsChar; const aImage: TltsImage); -var - err: TltsErrorCode; -begin - err := ltsPostProcessorExecute(fHandle, aChar.Handle, aImage.Handle); - if (err <> ltsErrNone) then - raise TltsException.Create(ltsGetLastErrorMsg(), err); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -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; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsPostProcessorCustom/////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure ltsPostProcessorExecuteCallback(const aChar: TltsCharHandle; const aImage: TltsImageHandle; aArgs: Pointer); -var - chr: TltsChar; - img: TltsImage; -begin - chr := TltsChar.Create(aChar); - img := TltsImage.Create(aImage); - try - TltsPostProcessorCustom(aArgs).Execute(chr, img); - finally - FreeAndNil(img); - FreeAndNil(chr); - end; -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -constructor TltsPostProcessorCustom.Create(const aContext: TltsContext); -var - h: TltsPostProcessorHandle; - p: TltsPostProcessorCustomData; -begin - p.args := self; - p.execute := @ltsPostProcessorExecuteCallback; - h := ltsPostProcessorCustomCreate(aContext.Handle, @p); - if not Assigned(h) then - raise TltsException.Create(ltsGetLastErrorMsg(), ltsGetLastErrorCode()); - inherited Create(h); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//TltsPostProcessorList///////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsPostProcessorList.GetCount: Integer; -begin - result := fItems.Count; -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsPostProcessorList.GetItem(const aIndex: Integer): TltsPostProcessor; -begin - result := TltsPostProcessor(fItems[aIndex]); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsPostProcessorList.GetOwnsObjects: Boolean; -begin - result := fItems.OwnsObjects; -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsPostProcessorList.SetOwnsObjects(aValue: Boolean); -begin - fItems.OwnsObjects := aValue; -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsPostProcessorList.Execute(const aChar: TltsChar; const aImage: TltsImage); -var - i: Integer; -begin - inherited Execute(aChar, aImage); - for i := 0 to fItems.Count-1 do - TltsPostProcessor(fItems[i]).Execute(aChar, aImage); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsPostProcessorList.Add(const aPostProcessor: TltsPostProcessor); -begin - fItems.Add(aPostProcessor); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsPostProcessorList.Delete(const aIndex: Integer); -begin - fItems.Delete(aIndex); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TltsPostProcessorList.Clear; -begin - fItems.Clear; -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsPostProcessorList.Remove(const aPostProcessor: TltsPostProcessor): Integer; -begin - result := fItems.Remove(aPostProcessor); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TltsPostProcessorList.IndexOf(const aPostProcessor: TltsPostProcessor): Integer; -begin - result := fItems.IndexOf(aPostProcessor); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -constructor TltsPostProcessorList.Create(const aContext: TltsContext; const aOwnsObjects: Boolean); -begin - inherited Create(aContext); - fItems := TObjectList.Create(aOwnsObjects); -end; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -destructor TltsPostProcessorList.Destroy; -begin - FreeAndNil(fItems); - inherited Destroy; -end; - end. diff --git a/libTextSuite.lpi b/libTextSuite.lpi index fa287e9..2763fbd 100644 --- a/libTextSuite.lpi +++ b/libTextSuite.lpi @@ -392,6 +392,7 @@ + @@ -447,6 +448,7 @@ + diff --git a/libTextSuite.lpr b/libTextSuite.lpr index 0e0fc54..84eaa7a 100644 --- a/libTextSuite.lpr +++ b/libTextSuite.lpr @@ -13,9 +13,11 @@ exports ltsContextGetDefaultChar, ltsContextSetCodePage, ltsContextSetDefaultChar, + ltsContextAnsiToWide, ltsContextDestroy, ltsRendererCreate, + ltsRendererCustomCreate, ltsRendererBeginBlock, ltsRendererEndBlock, ltsRendererAbortBlock, @@ -93,10 +95,13 @@ exports ltsPostProcessorAddRange, ltsPostProcessorAddChars, ltsPostProcessorClearRanges, + ltsPostProcessorExecute, ltsPostProcessorFillColorCreate, ltsPostProcessorFillPatterCreate, ltsPostProcessorBorderCreate, ltsPostProcessorShadowCreate, + ltsPostProcessorCustomCreate, + ltsPostProcessorDestroy, ltsCharGetCharCode, ltsCharGetGlyphMetric, diff --git a/ultsRenderer.pas b/ultsRenderer.pas index 08dea48..fff16f3 100644 --- a/ultsRenderer.pas +++ b/ultsRenderer.pas @@ -49,19 +49,21 @@ function ltsRendererDestroy (const aHandle: TltsRendererHandle): implementation uses - ultsUtils; + ultsUtils, dglOpenGL, dglOpenGLES; type //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TltsRendererOpenGL = class(TtsRendererOpenGL) public procedure DelSlave(const aSlave: TtsRefManager); override; + constructor Create(const aContext: TtsContext; const aFormat: TtsFormat); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TltsRendererOpenGLES = class(TtsRendererOpenGLES) public procedure DelSlave(const aSlave: TtsRefManager); override; + constructor Create(const aContext: TtsContext; const aFormat: TtsFormat); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -97,6 +99,15 @@ begin inherited DelSlave(aSlave); end; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +constructor TltsRendererOpenGL.Create(const aContext: TtsContext; const aFormat: TtsFormat); +begin + dglOpenGL.InitOpenGL; + dglOpenGL.ReadExtensions; + dglOpenGL.ReadImplementationProperties; + inherited Create(aContext, aFormat); +end; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TltsRendererOpenGLES////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -106,6 +117,17 @@ begin inherited DelSlave(aSlave); end; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +constructor TltsRendererOpenGLES.Create(const aContext: TtsContext; const aFormat: TtsFormat); +begin + dglOpenGLES.InitOpenGLES; + dglOpenGLES.ReadOpenGLCore; + dglOpenGLES.ReadExtensions; + dglOpenGLES.ReadCoreVersion; + dglOpenGLES.ReadImplementationProperties; + inherited Create(aContext, aFormat); +end; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TltsRendererCustom//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ultsUtils.pas b/ultsUtils.pas index 732916f..7d6e84f 100644 --- a/ultsUtils.pas +++ b/ultsUtils.pas @@ -54,6 +54,11 @@ var implementation +{$IFDEF DUMP_HEAPTRACE} +uses + heaptrc; +{$ENDIF} + type TtsContextHashSet = specialize TutlHashSet; TtsRendererHashSet = specialize TutlHashSet; @@ -278,7 +283,18 @@ end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure Initialize; +{$IFDEF DUMP_HEAPTRACE} +var + heaptrcFile: String; +{$ENDIF} begin +{$IFDEF DUMP_HEAPTRACE} + heaptrcFile := ChangeFileExt(ParamStr(0), '.libTextSuite.heaptrc'); + if (FileExists(heaptrcFile)) then + DeleteFile(heaptrcFile); + SetHeapTraceOutput(heaptrcFile); +{$ENDIF} + Contexts := TtsContextHashSet.Create(true); Renderers := TtsRendererHashSet.Create(false); TextBlocks := TtsTextBlockHashSet.Create(false);