Set rotated text

Posted in Fonts

Use TLOGFONT structure for creating new font. For rotating text you must change lfEscapement and lfOrientation fields of this structure.

procedure TForm1.Button1Click(Sender: TObject);
var
  MyLogFont: TLogFont;
  MyFont: HFont;
begin
  FillChar(MyLogFont, Sizeof(MyLogFont), 0);
  with MyLogFont do
  begin
    lfHeight:=0;
    lfWidth:=0;
    lfEscapement:=StrToInt(Edit1.Text);
    lfOrientation:=StrToInt(Edit1.Text);
    lfWeight:=FW_NORMAL;
    lfItalic:=1;
    lfUnderline:=1;
    lfStrikeOut:=0;
    lfCharSet:=DEFAULT_CHARSET;
    lfOutPrecision:=OUT_DEFAULT_PRECIS;
    lfClipPrecision:=CLIP_DEFAULT_PRECIS;
    lfQuality:=DEFAULT_QUALITY;
    lfPitchAndFamily:=1;
  end;
  MyFont:=CreateFontIndirect(MyLogFont);
  Form1.Canvas.Font.Handle:=MyFont;
  Form1.Canvas.TextOut(100, 100, 'Hello');
end;