Hallo,
folgendende Funktionen verwende ich für das Thema
Delphi-Quellcode:
function GetFontHeight( Font : TFont ) : Integer;
var
Canvas : TCanvas;
begin
Canvas := TCanvas.Create;
Try
Canvas.Handle := GetDC( 0 );
Try
Canvas.Font := Font;
Result := Canvas.TextHeight( 'Yy' );
Finally
ReleaseDC( 0, Canvas.Handle );
end;
Finally
Canvas.Free;
end;
end;
function GetTextwidth(const T : String; Font : TFont ) : Integer;
var
Canvas : TCanvas;
begin
Canvas := TCanvas.Create;
Try
Canvas.Handle := GetDC( 0 );
Try
Canvas.Font := Font;
Result := Canvas.TextWidth(T);
Finally
ReleaseDC( 0, Canvas.Handle );
end;
Finally
Canvas.Free;
end;
end;