CyberKnight
asked on
Drawing Vertical Text ?
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.Hand le, SizeOf(LogFont), @LogFont);
with LogFont do
begin
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 */
end;
//Assign the new rotated font handle
NewFont := CreateFontIndirect(LogFont );
OldFont := SelectObject(Canvas.Handle ,NewFont);
ACanvas.TextOut(0,0, 'Testing...');
//restore old font and delete new handle
NewFont := SelectObject(Canvas.Handle ,OldFont);
DeleteObject(NewFont);
(********** 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...
FillChar(lfFaceName,32,#0) ;
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..????
Help.....???
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.Hand
with LogFont do
begin
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 */
end;
//Assign the new rotated font handle
NewFont := CreateFontIndirect(LogFont
OldFont := SelectObject(Canvas.Handle
ACanvas.TextOut(0,0, 'Testing...');
//restore old font and delete new handle
NewFont := SelectObject(Canvas.Handle
DeleteObject(NewFont);
(********** 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...
FillChar(lfFaceName,32,#0)
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..????
Help.....???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you... Great !!!