Browse Source

--- Merging r14950 into '.':
U packages/fcl-image/src/fpfont.inc
--- Merging r14976 into '.':
G packages/fcl-image/src/fpfont.inc

# revisions: 14950,14976
------------------------------------------------------------------------
r14950 | marco | 2010-02-27 20:14:28 +0100 (Sat, 27 Feb 2010) | 3 lines
Changed paths:
M /trunk/packages/fcl-image/src/fpfont.inc

* fix for mantis #13171, a default for gettextheight so that it doesn't
totally fall apart if no canvas is assigned.

------------------------------------------------------------------------
------------------------------------------------------------------------
r14976 | marco | 2010-03-05 22:03:49 +0100 (Fri, 05 Mar 2010) | 2 lines
Changed paths:
M /trunk/packages/fcl-image/src/fpfont.inc

* another fix for mantis 13171, font.gettextwidth default value

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@14980 -

marco 15 years ago
parent
commit
01f250bda0
1 changed files with 8 additions and 2 deletions
  1. 8 2
      packages/fcl-image/src/fpfont.inc

+ 8 - 2
packages/fcl-image/src/fpfont.inc

@@ -54,7 +54,10 @@ begin
   if inheritsFrom (TFPCustomDrawFont) then
     result := TFPCustomDrawFont(self).DoGetTextHeight (text)
   else
-    result := FCanvas.GetTextHeight (text);
+   if assigned(FCanvas) then
+     result := FCanvas.GetTextHeight (text)
+   else 
+     result :=16; // *some* default better than none.
 end;
 
 function TFPCustomFont.GetTextWidth (text:string) : integer;
@@ -62,6 +65,9 @@ begin
   if inheritsFrom (TFPCustomDrawFont) then
     result := TFPCustomDrawFont(self).DoGetTextWidth (text)
   else
-    result := FCanvas.GetTextWidth (text);
+   if assigned(FCanvas) then
+     result := FCanvas.GetTextWidth (text)
+   else 
+     result :=16; // *some* default better than none.
 end;