[Lazarus] TextHeight in Console App
hdpc at talktalk.net
Tue May 14 16:50:40 CEST 2013
On 14/05/2013 15:32, Graeme Geldenhuys wrote:
> On 2013-05-14 14:07, Edilson Vieira wrote:
>> The project is an Image Generation Program, a console program.
>> The error ocurr when I call the method TextHeight of the Canvas property of
> You do realize that if you pull in the 'Graphics' unit of LCL, you don't
> have a console app any more, but a GUI app.
> I don't really know what you app does, but I would instead use FPImage
> (from Free Pascal's FCL packages), and use freetype (also included with
> fcl-image code). This will mean your app is not LCL dependent, and a
> real console application.
Or create a Lazarus GUI app and implement Form1's OnCreate handler thus:
procedure TForm1.FormCreate(Sender: TObject);
var bmp: TBitmap;
bmp := TBitmap.Create;
bmp.Canvas.Font.Name := 'Tahoma';
bmp.Canvas.Font.Size := 20;
bmp.Canvas.Font.Style := [fsBold, fsItalic];
ShowMessageFmt('Text height is %d',[bmp.Canvas.TextHeight('T')]);
For a GUI app Lazarus sets up paths to LCL units such as Graphics (and
its dependent units) correctly, and includes several such commonly used
units in your uses clause automatically.
Console apps usually require you to manually include the units you use,
and specify their paths explicitly.
More information about the Lazarus