mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 15:18:16 +02:00
LazUtils: Use exception class EFreeType instead of general Exception in EasyLazFreeType.
git-svn-id: trunk@61244 -
This commit is contained in:
parent
a0c1900d66
commit
31de6345cf
@ -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)+') <Stream>');
|
||||
raise EFreeType.Create('Cannot open font (TT_Error ' + intToStr(errorNum)+') <Stream>');
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user