diff --git a/components/lazutils/easylazfreetype.pas b/components/lazutils/easylazfreetype.pas index f1b625364a..6757e18d2c 100644 --- a/components/lazutils/easylazfreetype.pas +++ b/components/lazutils/easylazfreetype.pas @@ -58,6 +58,8 @@ type TFreeTypeGlyph = class; TFreeTypeFont = class; + EFreeType = class(Exception); + TFontCollectionItemDestroyProc = procedure() of object; TFontCollectionItemDestroyListener = record TargetObject: TObject; @@ -483,7 +485,7 @@ begin FreeTypeCannotInitialize := not FreeTypeInitialized; end; if FreeTypeCannotInitialize then - raise Exception.Create('FreeType cannot be initialized'); + raise EFreeType.Create('FreeType cannot be initialized'); end; { TFreeTypeRenderableFont } @@ -759,7 +761,7 @@ end; constructor TFreeTypeGlyph.Create(AFont: TFreeTypeFont; AIndex: integer); begin if not AFont.CheckFace or (TT_New_Glyph(AFont.FFace, FGlyphData) <> TT_Err_Ok) then - raise Exception.Create('Cannot create empty glyph'); + raise EFreeType.Create('Cannot create empty glyph'); FLoaded := AFont.LoadGlyphInto(FGlyphData, AIndex); FIndex := AIndex; end; @@ -851,22 +853,22 @@ begin begin errorNum := TT_Open_Face(FStream,False,FFace); if errorNum <> TT_Err_Ok then - raise exception.Create('Cannot open font (TT_Error ' + intToStr(errorNum)+') '); + raise EFreeType.Create('Cannot open font (TT_Error ' + intToStr(errorNum)+') '); end else begin if Pos(PathDelim, FName) <> 0 then begin errorNum := TT_Open_Face(FName,FFace); if errorNum <> TT_Err_Ok then - raise exception.Create('Cannot open font (TT_Error ' + intToStr(errorNum)+') "'+FName+'"'); + raise EFreeType.Create('Cannot open font (TT_Error ' + intToStr(errorNum)+') "'+FName+'"'); end else begin familyItem := Collection.Family[FName]; if familyItem = nil then - raise exception.Create('Font family not found ("'+FName+'")'); + raise EFreeType.Create('Font family not found ("'+FName+'")'); fontItem := familyItem.GetFont(FStyleStr); if fontItem = nil then - raise exception.Create('Font style not found ("'+FStyleStr+'")'); + raise EFreeType.Create('Font style not found ("'+FStyleStr+'")'); FFace := fontItem.QueryFace(FontCollectionItemDestroyListener(self,@OnDestroyFontItem)); FFaceItem := fontItem; end; @@ -1181,7 +1183,7 @@ function TFreeTypeFont.LoadGlyphInto(_glyph: TT_Glyph; glyph_index: Word): boole var flags: integer; begin if not CheckInstance then - raise Exception.Create('No font instance'); + raise EFreeType.Create('No font instance'); flags := TT_Load_Scale_Glyph; if FHinted then flags := flags or TT_Load_Hint_Glyph; result := (TT_Load_Glyph(FInstance, _glyph, glyph_index, flags) <> TT_Err_Ok); @@ -1210,7 +1212,7 @@ begin UpdateMetrics; UpdateCharmap; end else - raise exception.Create('Cannot create font instance (TT_Error ' + intToStr(errorNum)+')'); + raise EFreeType.Create('Cannot create font instance (TT_Error ' + intToStr(errorNum)+')'); end; procedure TFreeTypeFont.UpdateSizeInPoints; @@ -1224,7 +1226,7 @@ begin charsizex := round(FPointSize*64*FWidthFactor*3); if TT_Set_Instance_CharSizes(FInstance,charsizex,round(FPointSize*64)) <> TT_Err_Ok then - raise Exception.Create('Unable to set point size'); + raise EFreeType.Create('Unable to set point size'); FGlyphTable.FreeAndClear; end; end;