summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-12 15:20:13 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-12 15:20:13 +0200
commit44a2f50f35b357af485d12b55da38e1f1a4bbe9e (patch)
treecc5138c9b42b623d569fe3c02d1a12f78f1b224c /components
parenta74522ef1fe79c116226aa1fe6d0df014559ece3 (diff)
downloadfpGUI-44a2f50f35b357af485d12b55da38e1f1a4bbe9e.tar.xz
Fixed a few memory leaks. Many still remain in this unit.
Diffstat (limited to 'components')
-rwxr-xr-xcomponents/richtext/CanvasFontManager.pas40
1 files changed, 15 insertions, 25 deletions
diff --git a/components/richtext/CanvasFontManager.pas b/components/richtext/CanvasFontManager.pas
index e3248d0a..bd8e2cb9 100755
--- a/components/richtext/CanvasFontManager.pas
+++ b/components/richtext/CanvasFontManager.pas
@@ -43,7 +43,7 @@ Type
TPCharWidthArray = ^TCharWidthArray;
// Used internally for storing full info on font
- TLogicalFont= Class( TfpgComponent )
+ TLogicalFont = class(TComponent)
public
FaceName: String; // user-selected name
UseFaceName: String; // after substitutions.
@@ -653,6 +653,7 @@ destructor TCanvasFontManager.Destroy;
var
i: integer;
Font: TLogicalFont;
+ face: TFontFace;
begin
// select default font so none of our logical fonts are in use
FCanvas.Font := fpgApplication.DefaultFont;
@@ -661,11 +662,19 @@ begin
for i := 0 to FLogicalFonts.Count - 1 do
begin
Font := TLogicalFont(FLogicalFonts[ i ]);
- //if not GpiDeleteSetID( FCanvas.Handle, Font.ID ) then
- // rc := WinGetLastError( AppHandle );
Font.Free;
end;
+ FLogicalFonts.Clear;
FLogicalFonts.Free;
+
+ // TCanvasFontManager asked for FontFaces to be created, so lets take responsibility to destroy it.
+ for i := 0 to FontFaces.Count-1 do
+ begin
+ face := TFontFace(Fontfaces[i]);
+ face.Free;
+ end;
+ FontFaces.Clear;
+ FontFaces.Free;
inherited Destroy;
end;
@@ -903,16 +912,10 @@ end;
procedure TCanvasFontManager.SelectFont( Font: TLogicalFont;
Scale: longint );
var
- aHDC: integer;
- //xRes: LongInt;
- //yRes: LongInt;
- //aSizeF: SIZEF;
f: TfpgFont;
s: string;
begin
-writeln('TCanvasFontManager.SelectFont >>>>>>>>>');
// Select the logical font
- //GpiSetCharSet( FCanvas.Handle, Font.ID );
if Font.FontType = ftOutline then
begin
s := Font.FaceName + '-' + IntToStr(Font.PointSize);
@@ -922,24 +925,9 @@ writeln('TCanvasFontManager.SelectFont >>>>>>>>>');
s := s + ':italic';
if faUnderScore in Font.Attributes then
s := s + ':underline';
+
f := fpgGetFont(s);
- writeln(' fontdesc=', s);
FCanvas.Font := f;
- // // For outline fonts, also set character Box
- // aHDC := GpiQueryDevice( FCanvas.Handle );
- // DevQueryCaps( aHDC,
- // CAPS_HORIZONTAL_FONT_RES,
- // 1,
- // xRes );
- // DevQueryCaps( aHDC,
- // CAPS_VERTICAL_FONT_RES,
- // 1,
- // yRes );
- //
- // aSizeF.CX := 65536 * xRes* Font.PointSize Div 72 * Scale;
- // aSizeF.CY := 65536 * yRes* Font.PointSize Div 72 * Scale;
- //
- // GpiSetCharBox( FCanvas.Handle, aSizeF );
end;
end;
@@ -1023,6 +1011,7 @@ begin
SelectFont( Font, 1 );
FCurrentFontSpec := FontSpec;
+ FCurrentFont.Free;
FCurrentFont := Font;
end;
@@ -1136,4 +1125,5 @@ begin
Point.x := Point.X + Canvas.Font.TextWidth(t);
end;
+
end.