Browse Source

fpcanvas: Adds TextExtent

git-svn-id: trunk@19767 -
sekelsenmat 13 years ago
parent
commit
6e481b3a73
2 changed files with 7 additions and 1 deletions
  1. 5 0
      packages/fcl-image/src/fpcanvas.inc
  2. 2 1
      packages/fcl-image/src/fpcanvas.pp

+ 5 - 0
packages/fcl-image/src/fpcanvas.inc

@@ -331,6 +331,11 @@ begin
   Result := TextWidth(Text);
 end;
 
+function TFPCustomCanvas.TextExtent(const Text: string): TSize;
+begin
+  GetTextSize(Text, Result.cx, Result.cy);
+end;
+
 function TFPCustomCanvas.TextHeight(const Text: string): Integer;
 begin
   if Font is TFPCustomDrawFont then

+ 2 - 1
packages/fcl-image/src/fpcanvas.pp

@@ -17,7 +17,7 @@ unit FPCanvas;
 
 interface
 
-uses Math, sysutils, classes, FPImage;
+uses Math, sysutils, classes, FPImage, Types;
 
 const
   PatternBitCount = sizeof(longword) * 8;
@@ -296,6 +296,7 @@ type
     procedure GetTextSize (text:string; var w,h:integer);
     function GetTextHeight (text:string) : integer;
     function GetTextWidth (text:string) : integer;
+    function TextExtent(const Text: string): TSize; virtual;
     function TextHeight(const Text: string): Integer; virtual;
     function TextWidth(const Text: string): Integer; virtual;
     // using pen and brush