Drawing Vertical Text ?
Posted on 2002-03-27
Hi, I need to draw text vertically, ....(simple enuf)
But the font that needs to be drawn, needs to be selected by the user at runtime.
(* This is an extract of my code *)
GetObject(Canvas.Font.Handle, SizeOf(LogFont), @LogFont);
with LogFont do
lfEscapement:= 90 * 10; //this does the rotation
lfQuality := PROOF_QUALITY;
lfFaceName:= 'Comic Sans MS';
/* The problem is with the above line, as it needs to be set at runtime */
//Assign the new rotated font handle
NewFont := CreateFontIndirect(LogFont);
OldFont := SelectObject(Canvas.Handle,NewFont);
//restore old font and delete new handle
NewFont := SelectObject(Canvas.Handle,OldFont);
(********** END **************)
What I am doing instead of that line is
S:=Canvas.Font.Name; // string
// Assume Canvas.Font is some font set by the user at runtime...
For j := 1 to Length(S) do
lfFaceName[j-1]:= S[j]; // For this example assume the user has chosen Comic Sans MS...
Even though the above code is the equivalent to
lfFaceName[j-1]:= 'Comic Sans MS';
... I only get the correct font displayed if it is hardcoded..????