[Lazarus] TextHeight in Console App

Edilson Vieira vieira.edilson at gmail.com
Tue May 14 15:07:44 CEST 2013


Hi folks!

This is my second post. If this is not the correct list please let me know.

I am trying to compile a Delphi project with Lazarus.

The project is an Image Generation Program, a console program.

The error ocurr when I call the method TextHeight of the Canvas property of
TBitmap.

The error message is (my translation):

 'Project TextHeight raised exception "External SIGSEGV" in file
'.\include\lclintf.inc' at line 184.'

Could someone help me?

Thanks in advance,

Edilson.

Here is a sample code that reproduces the error:

program TextHeightTest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, SysUtils, CustApp, Graphics
  { you can add units after this };

type

  { TTextHeight }

  TTextHeight = class(TCustomApplication)
  protected
    procedure DoRun; override;
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    procedure WriteHelp; virtual;
  end;

{ TTextHeight }

procedure TTextHeight.DoRun;
var
  ErrorMsg, x: String;
  bmp: TBitmap;
begin
  // quick check parameters
  ErrorMsg:=CheckOptions('h','help');
  if ErrorMsg<>'' then begin
    ShowException(Exception.Create(ErrorMsg));
    Terminate;
    Exit;
  end;

  // parse parameters
  if HasOption('h','help') then begin
    WriteHelp;
    Terminate;
    Exit;
  end;

  { add your program here }

  // Criando a imagem...
  bmp := TBitmap.Create;
  bmp.Canvas.Font.Name := 'Tahoma';
  bmp.Canvas.Font.Size := 20;
  bmp.Canvas.Font.Color := clBlue;
  bmp.Canvas.Font.Style := [fsBold, fsItalic];
  writeln('Textheight:');
  readln(x);
  writeln(IntToStr(bmp.Canvas.TextHeight('T')));
  readln(x);

  // stop program loop
  Terminate;
end;

constructor TTextHeight.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  StopOnException:=True;
end;

destructor TTextHeight.Destroy;
begin
  inherited Destroy;
end;

procedure TTextHeight.WriteHelp;
begin
  { add your help code here }
  writeln('Usage: ',ExeName,' -h');
end;

var
  Application: TTextHeight;
begin
  Application:=TTextHeight.Create(nil);
  Application.Title:='Text Height';
  Application.Run;
  Application.Free;
end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130514/8db6107e/attachment-0002.html>


More information about the Lazarus mailing list