Canvas TextHeight

Canvas TextHeight

Post by D Whale » Sat, 28 Jun 2003 00:20:25



How can I get the TextHeight when the text has multiple lines using CRLF.

I am currently using an autosize label to determine it, but there has to be
a better way.

 
 
 

Canvas TextHeight

Post by Team » Sat, 28 Jun 2003 01:25:41


On Thu, 26 Jun 2003 10:20:25 -0500, "D Whaley"


>How can I get the TextHeight when the text has multiple lines using CRLF.

Either multiply the height of a single line by the number of lines, or
use the DrawText function, passing the DT_CALCRECT flag.

---
Yorai Aminov (TeamB)
http://develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)

 
 
 

1. TextHeight problem with Canvas font

Hi all,

I don't understand what I do wrong. I want to write a text in the lower
right
corner of a bitmap. The space beween the text and the right bitmap edge and
the
bottom bitmap edge should be the same value which I define in offset.

But why does it not work for both sides ?

Any help welcome

Thomas
___________________________________________________________

procedure TForm1.Button1Click(Sender: TObject);
begin
  Test(2,'Hello');
end;

procedure TForm1.Test(Offset: Short; Text: String);
var Bmp: TBitmap;
    x,y: Integer;
begin
  Bmp := TBitmap.Create;
  Bmp.Width := 160;
  Bmp.Height := 160;
  Bmp.Canvas.Brush.Color := clWhite;
  Bmp.Canvas.Font.Name := 'Arial';
  Bmp.Canvas.Font.Size := 40;
  x := Bmp.Width - Abs(Bmp.Canvas.TextWidth(Text)) - Offset;
  y := Bmp.Height - Abs(Bmp.Canvas.TextHeight(Text)) - Offset;
  Bmp.Canvas.TextOut(x, y, Text);
  Image1.Picture.Bitmap.Assign(Bmp);
  Bmp.Free;
  Bmp := Nil;
end;

2. Imagine Info

3. textwidth/textheight macros

4. Retail vs. Debug vertex shader performance

5. Textheight

6. Visual Reality

7. TextHeight 2

8. Wireframe rendering (that's fast in software)?

9. TextHeight

10. CANVAS 3.5.4 CGM import- Powerpoint works, Canvas doesn't

11. Canvas 7 vs Canvas 6

12. - Canvas 5.0.1 updater (FAT) (0/13) Canvas 5.01 FAT update enclosed

13. Canvas 3.5.4/Canvas 5.0.1