mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 21:37:11 +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;
|
TFreeTypeGlyph = class;
|
||||||
TFreeTypeFont = class;
|
TFreeTypeFont = class;
|
||||||
|
|
||||||
|
EFreeType = class(Exception);
|
||||||
|
|
||||||
TFontCollectionItemDestroyProc = procedure() of object;
|
TFontCollectionItemDestroyProc = procedure() of object;
|
||||||
TFontCollectionItemDestroyListener = record
|
TFontCollectionItemDestroyListener = record
|
||||||
TargetObject: TObject;
|
TargetObject: TObject;
|
||||||
@ -483,7 +485,7 @@ begin
|
|||||||
FreeTypeCannotInitialize := not FreeTypeInitialized;
|
FreeTypeCannotInitialize := not FreeTypeInitialized;
|
||||||
end;
|
end;
|
||||||
if FreeTypeCannotInitialize then
|
if FreeTypeCannotInitialize then
|
||||||
raise Exception.Create('FreeType cannot be initialized');
|
raise EFreeType.Create('FreeType cannot be initialized');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFreeTypeRenderableFont }
|
{ TFreeTypeRenderableFont }
|
||||||
@ -759,7 +761,7 @@ end;
|
|||||||
constructor TFreeTypeGlyph.Create(AFont: TFreeTypeFont; AIndex: integer);
|
constructor TFreeTypeGlyph.Create(AFont: TFreeTypeFont; AIndex: integer);
|
||||||
begin
|
begin
|
||||||
if not AFont.CheckFace or (TT_New_Glyph(AFont.FFace, FGlyphData) <> TT_Err_Ok) then
|
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);
|
FLoaded := AFont.LoadGlyphInto(FGlyphData, AIndex);
|
||||||
FIndex := AIndex;
|
FIndex := AIndex;
|
||||||
end;
|
end;
|
||||||
@ -851,22 +853,22 @@ begin
|
|||||||
begin
|
begin
|
||||||
errorNum := TT_Open_Face(FStream,False,FFace);
|
errorNum := TT_Open_Face(FStream,False,FFace);
|
||||||
if errorNum <> TT_Err_Ok then
|
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
|
end else
|
||||||
begin
|
begin
|
||||||
if Pos(PathDelim, FName) <> 0 then
|
if Pos(PathDelim, FName) <> 0 then
|
||||||
begin
|
begin
|
||||||
errorNum := TT_Open_Face(FName,FFace);
|
errorNum := TT_Open_Face(FName,FFace);
|
||||||
if errorNum <> TT_Err_Ok then
|
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
|
end else
|
||||||
begin
|
begin
|
||||||
familyItem := Collection.Family[FName];
|
familyItem := Collection.Family[FName];
|
||||||
if familyItem = nil then
|
if familyItem = nil then
|
||||||
raise exception.Create('Font family not found ("'+FName+'")');
|
raise EFreeType.Create('Font family not found ("'+FName+'")');
|
||||||
fontItem := familyItem.GetFont(FStyleStr);
|
fontItem := familyItem.GetFont(FStyleStr);
|
||||||
if fontItem = nil then
|
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));
|
FFace := fontItem.QueryFace(FontCollectionItemDestroyListener(self,@OnDestroyFontItem));
|
||||||
FFaceItem := fontItem;
|
FFaceItem := fontItem;
|
||||||
end;
|
end;
|
||||||
@ -1181,7 +1183,7 @@ function TFreeTypeFont.LoadGlyphInto(_glyph: TT_Glyph; glyph_index: Word): boole
|
|||||||
var flags: integer;
|
var flags: integer;
|
||||||
begin
|
begin
|
||||||
if not CheckInstance then
|
if not CheckInstance then
|
||||||
raise Exception.Create('No font instance');
|
raise EFreeType.Create('No font instance');
|
||||||
flags := TT_Load_Scale_Glyph;
|
flags := TT_Load_Scale_Glyph;
|
||||||
if FHinted then flags := flags or TT_Load_Hint_Glyph;
|
if FHinted then flags := flags or TT_Load_Hint_Glyph;
|
||||||
result := (TT_Load_Glyph(FInstance, _glyph, glyph_index, flags) <> TT_Err_Ok);
|
result := (TT_Load_Glyph(FInstance, _glyph, glyph_index, flags) <> TT_Err_Ok);
|
||||||
@ -1210,7 +1212,7 @@ begin
|
|||||||
UpdateMetrics;
|
UpdateMetrics;
|
||||||
UpdateCharmap;
|
UpdateCharmap;
|
||||||
end else
|
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;
|
end;
|
||||||
|
|
||||||
procedure TFreeTypeFont.UpdateSizeInPoints;
|
procedure TFreeTypeFont.UpdateSizeInPoints;
|
||||||
@ -1224,7 +1226,7 @@ begin
|
|||||||
charsizex := round(FPointSize*64*FWidthFactor*3);
|
charsizex := round(FPointSize*64*FWidthFactor*3);
|
||||||
|
|
||||||
if TT_Set_Instance_CharSizes(FInstance,charsizex,round(FPointSize*64)) <> TT_Err_Ok then
|
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;
|
FGlyphTable.FreeAndClear;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user