| @@ -347,6 +347,7 @@ var | |||||
| face: FT_Face; | face: FT_Face; | ||||
| err: FT_Error; | err: FT_Error; | ||||
| begin | begin | ||||
| FillByte(face{%H-}, SizeOf(face), 0); | |||||
| err := FT_New_Face(fHandle, PAnsiChar(aFilename), 0, @face); | err := FT_New_Face(fHandle, PAnsiChar(aFilename), 0, @face); | ||||
| if (err <> 0) then | if (err <> 0) then | ||||
| raise EtsException.Create('unable to create free type face from file: ' + aFilename + ' error=' + IntToStr(err)); | raise EtsException.Create('unable to create free type face from file: ' + aFilename + ' error=' + IntToStr(err)); | ||||
| @@ -361,6 +362,7 @@ var | |||||
| ms: TMemoryStream; | ms: TMemoryStream; | ||||
| p: PBYte; | p: PBYte; | ||||
| begin | begin | ||||
| FillByte(face{%H-}, SizeOf(face), 0); | |||||
| if (aStream is TMemoryStream) then begin | if (aStream is TMemoryStream) then begin | ||||
| ms := (aStream as TMemoryStream); | ms := (aStream as TMemoryStream); | ||||
| p := ms.Memory; | p := ms.Memory; | ||||
| @@ -7,30 +7,30 @@ unit utsFreeType; | |||||
| interface | interface | ||||
| uses | uses | ||||
| Classes, SysUtils, syncobjs, {$IFDEF FPC}dynlibs,{$ELSE}windows,{$ENDIF} | |||||
| Classes, SysUtils, syncobjs, ctypes, {$IFDEF FPC}dynlibs,{$ELSE}windows,{$ENDIF} | |||||
| utsUtils; | utsUtils; | ||||
| type | type | ||||
| // Simple Types | // Simple Types | ||||
| FT_Error = Integer; | |||||
| FT_Error = cint; | |||||
| FT_Library = Pointer; | FT_Library = Pointer; | ||||
| FT_Short = SmallInt; | |||||
| FT_Byte = Byte; | |||||
| FT_Short = csshort; | |||||
| FT_Byte = cuchar; | |||||
| FT_Char = AnsiChar; | 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; | FT_String = AnsiChar; | ||||
| // Enums | // Enums | ||||
| FT_Encoding = Integer; | |||||
| FT_Glyph_Format = Integer; | |||||
| FT_Encoding = csint; | |||||
| FT_Glyph_Format = csint; | |||||
| // Pointer | // Pointer | ||||
| FT_Face = ^FT_FaceRec; | FT_Face = ^FT_FaceRec; | ||||
| @@ -684,6 +684,7 @@ begin | |||||
| result := ftLibrary; | result := ftLibrary; | ||||
| except | except | ||||
| FreeTypeInitialized := false; | FreeTypeInitialized := false; | ||||
| raise; | |||||
| end; | end; | ||||
| finally | finally | ||||
| FreeTypeCritSec.Leave; | FreeTypeCritSec.Leave; | ||||
| @@ -695,7 +696,7 @@ begin | |||||
| FreeTypeCritSec.Enter; | FreeTypeCritSec.Enter; | ||||
| try | try | ||||
| dec(FreeTypeRefCount, 1); | dec(FreeTypeRefCount, 1); | ||||
| if (FreeTypeRefCount > 0) then | |||||
| if (FreeTypeRefCount > 0) or not FreeTypeInitialized then | |||||
| exit; | exit; | ||||
| FT_Done_FreeType(ftLibrary); | FT_Done_FreeType(ftLibrary); | ||||
| @@ -288,8 +288,15 @@ begin | |||||
| gdiInitialized := true; | gdiInitialized := true; | ||||
| except | except | ||||
| gdiInitialized := false; | 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; | end; | ||||
| finally | finally | ||||
| gdiCritSec.Leave; | gdiCritSec.Leave; | ||||
| @@ -558,7 +558,7 @@ end; | |||||
| function TtsPostProcessorShadow.Execute(const aChar: TtsChar; const aImage: TtsImage): Boolean; | function TtsPostProcessorShadow.Execute(const aChar: TtsChar; const aImage: TtsImage): Boolean; | ||||
| var | var | ||||
| orig: TtsImage; | orig: TtsImage; | ||||
| tmpX, tmpY, w, h: Integer; | |||||
| tmpX, tmpY: Integer; | |||||
| m: TtsGlyphMetric; | m: TtsGlyphMetric; | ||||
| begin | begin | ||||
| result := inherited Execute(aChar, aImage); | result := inherited Execute(aChar, aImage); | ||||