Rotating Text

Here is an example of text output that is rotated 45 degrees:

procedure TForm1.Button1Click(Sender: TObject) ;
var
  lf : TLogFont;
  tf : TFont;
begin
  with Form1.Canvas do begin
    Font.Name := ‘Arial’;
    Font.Size := 24;
    tf := TFont.Create;
    try
      tf.Assign(Font) ;
      GetObject(tf.Handle, sizeof(lf), @lf) ;
      lf.lfEscapement := 450;
      lf.lfOrientation := 450;
      tf.Handle := CreateFontIndirect(lf) ;
      Font.Assign(tf) ;
    finally
      tf.Free;
    end;
    TextOut(20, Height div 2, ‘Rotated Text!’) ;
  end;
end;

Leave a Reply

Your email address will not be published. Required fields are marked *