* Fixed memory leaks and severe bugs in font manager (caching didn't work

at all and could lead to memory corruption)
This commit is contained in:
sg 2003-12-14 22:02:58 +00:00
parent f8e49e98be
commit 9edd8f5b51
2 changed files with 11 additions and 4 deletions

View File

@ -416,7 +416,7 @@ function TFontManager.CreateSize (aSize, aResolution : integer) : PMgrSize;
begin begin
new (result); new (result);
result^.Size := aSize; result^.Size := aSize;
result^.Size := aResolution; result^.Resolution := aResolution;
result^.Glyphs := Tlist.Create; result^.Glyphs := Tlist.Create;
SetPixelSize (aSize,aResolution); SetPixelSize (aSize,aResolution);
CurFont.FSizes.Add (result); CurFont.FSizes.Add (result);
@ -497,14 +497,14 @@ var r : integer;
begin begin
With CurSize^ do With CurSize^ do
begin begin
r := FList.Count; r := Glyphs.Count;
repeat repeat
dec (r) dec (r)
until (r < 0) or (PMgrGlyph(Flist[r])^.character = c); until (r < 0) or (PMgrGlyph(Glyphs[r])^.character = c);
if r < 0 then if r < 0 then
result := CreateGlyph (c) result := CreateGlyph (c)
else else
result := PMgrGlyph(Flist[r]); result := PMgrGlyph(Glyphs[r]);
end; end;
end; end;

View File

@ -52,6 +52,7 @@ type
procedure GetFace; procedure GetFace;
public public
constructor create; override; constructor create; override;
destructor Destroy; override;
property FontIndex : integer read FIndex write SetIndex; property FontIndex : integer read FIndex write SetIndex;
property Resolution : longword read FResolution write FResolution; property Resolution : longword read FResolution write FResolution;
property AntiAliased : boolean read FAntiAliased write FAntiAliased; property AntiAliased : boolean read FAntiAliased write FAntiAliased;
@ -90,6 +91,12 @@ begin
FResolution := DefaultResolution; FResolution := DefaultResolution;
end; end;
destructor TFreeTypeFont.Destroy;
begin
ClearLastText;
inherited Destroy;
end;
procedure TFreeTypeFont.DoCopyProps (From:TFPCanvasHelper); procedure TFreeTypeFont.DoCopyProps (From:TFPCanvasHelper);
var f : TFreeTypeFont; var f : TFreeTypeFont;
begin begin