Solved

Drawing Vertical Text ?

Posted on 2002-03-27
2
436 Views
Last Modified: 2010-05-18
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
 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.....???
0
Comment
Question by:CyberKnight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
Fraction earned 10 total points
ID: 6899084
You have probably tested, but doesn't it work with:
StrCopy(lfFaceName, PChar(s));
0
 

Author Comment

by:CyberKnight
ID: 6899277
Wow, Yes, it does work, that was something I didnt test with....(duh !)

Thank you... Great !!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Working with hours 3 85
tidtcpserver connection lost handle 2 119
firemonkey Android Listview Sort items 7 96
Connect to SQL 2008 r2 server over the Internet 4 74
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question