From 81e189737fdd98dff433cf2a2f8fa652801229b7 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Mon, 17 Apr 2017 14:52:38 +0200 Subject: [PATCH] * fixed some cross compiling bugs * improved error handling --- utsFontCreatorFreeType.pas | 2 ++ utsFreeType.pas | 33 +++++++++++++++++---------------- utsGDI.pas | 11 +++++++++-- utsPostProcessor.pas | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/utsFontCreatorFreeType.pas b/utsFontCreatorFreeType.pas index 3921138..fabeb06 100644 --- a/utsFontCreatorFreeType.pas +++ b/utsFontCreatorFreeType.pas @@ -347,6 +347,7 @@ var face: FT_Face; err: FT_Error; begin + FillByte(face{%H-}, SizeOf(face), 0); err := FT_New_Face(fHandle, PAnsiChar(aFilename), 0, @face); if (err <> 0) then raise EtsException.Create('unable to create free type face from file: ' + aFilename + ' error=' + IntToStr(err)); @@ -361,6 +362,7 @@ var ms: TMemoryStream; p: PBYte; begin + FillByte(face{%H-}, SizeOf(face), 0); if (aStream is TMemoryStream) then begin ms := (aStream as TMemoryStream); p := ms.Memory; diff --git a/utsFreeType.pas b/utsFreeType.pas index 1a0167f..3d6896d 100644 --- a/utsFreeType.pas +++ b/utsFreeType.pas @@ -7,30 +7,30 @@ unit utsFreeType; interface uses - Classes, SysUtils, syncobjs, {$IFDEF FPC}dynlibs,{$ELSE}windows,{$ENDIF} + Classes, SysUtils, syncobjs, ctypes, {$IFDEF FPC}dynlibs,{$ELSE}windows,{$ENDIF} utsUtils; type // Simple Types - FT_Error = Integer; + FT_Error = cint; FT_Library = Pointer; - FT_Short = SmallInt; - FT_Byte = Byte; + FT_Short = csshort; + FT_Byte = cuchar; FT_Char = AnsiChar; - FT_UShort = Word; - FT_Int = Integer; - FT_Int32 = Integer; - FT_UInt = Cardinal; - FT_Long = LongInt; - FT_ULong = Cardinal; - FT_Fixed = LongInt; - FT_Pos = LongInt; - FT_F26Dot6 = LongInt; + FT_UShort = cushort; + FT_Int = csint; + FT_Int32 = cint32; + FT_UInt = cuint; + FT_Long = cslong; + FT_ULong = culong; + FT_Fixed = cslong; + FT_Pos = cslong; + FT_F26Dot6 = cslong; FT_String = AnsiChar; // Enums - FT_Encoding = Integer; - FT_Glyph_Format = Integer; + FT_Encoding = csint; + FT_Glyph_Format = csint; // Pointer FT_Face = ^FT_FaceRec; @@ -684,6 +684,7 @@ begin result := ftLibrary; except FreeTypeInitialized := false; + raise; end; finally FreeTypeCritSec.Leave; @@ -695,7 +696,7 @@ begin FreeTypeCritSec.Enter; try dec(FreeTypeRefCount, 1); - if (FreeTypeRefCount > 0) then + if (FreeTypeRefCount > 0) or not FreeTypeInitialized then exit; FT_Done_FreeType(ftLibrary); diff --git a/utsGDI.pas b/utsGDI.pas index 11e7510..3c49946 100644 --- a/utsGDI.pas +++ b/utsGDI.pas @@ -288,8 +288,15 @@ begin gdiInitialized := true; except gdiInitialized := false; - FreeLibrary(gdiLibHandle); - FreeLibrary(kernel32LibHandle); + if (gdiLibHandle <> 0) then begin + FreeLibrary(gdiLibHandle); + gdiLibHandle := 0; + end; + if (kernel32LibHandle <> 0) then begin + FreeLibrary(kernel32LibHandle); + kernel32LibHandle := 0; + end; + raise; end; finally gdiCritSec.Leave; diff --git a/utsPostProcessor.pas b/utsPostProcessor.pas index 4c9359c..cebe33e 100644 --- a/utsPostProcessor.pas +++ b/utsPostProcessor.pas @@ -558,7 +558,7 @@ end; function TtsPostProcessorShadow.Execute(const aChar: TtsChar; const aImage: TtsImage): Boolean; var orig: TtsImage; - tmpX, tmpY, w, h: Integer; + tmpX, tmpY: Integer; m: TtsGlyphMetric; begin result := inherited Execute(aChar, aImage);