1. Home
  2. Computing & Technology
  3. Delphi Programming

Delphi Programming Tips 205 - 208
How to draw rotated text

By Zarko Gajic, About.com

Delphi programming tips in this group

~~~~~~~~~~~~~~~~~~~~~~~~~
{
How to draw rotated text
This example creates a rotated font and displays it on the form by assigning the handle of the rotated to the Form’s Canvas Font via the Font’s Handle property. Rotating fonts is a straightforward process, so long as the Windows Font Mapper can supply a rotated font based on the font you request. If you are using a TrueType font there is virtually no reason for failure.
}

var
   lf: LOGFONT; // Windows native font structure
begin
   Canvas.Brush.Style := bsClear; // set the brush style to transparent
   FillChar(Addr(lf), SizeOf(lf), Byte(0)) ;
   lf.lfHeight := 20;
   lf.lfEscapement := 10 * 45; // degrees to rotate
   lf.lfOrientation := 10 * 45;
   lf.lfCharSet := DEFAULT_CHARSET;
   StrCpy(lf.lfFaceName, 'Tahoma') ;

   Canvas.Font.Handle := CreateFontIndirect(Addr(lf)) ;

   Canvas.TextOut(10, 100, 'Rotated text') ; // output the rotated font
end;

~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to determine the path to the users Application Data
« Display standard Windows Properties dialog

To receive a Delphi tip in your e-mail box each week, sign up for the free About Delphi Programming newsletter!

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2003 Delphi Tips
  7. Delphi Programming Tips 205 - 208

©2009 About.com, a part of The New York Times Company.

All rights reserved.