Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Drawing fonts on the client area

davidgraham
Beginner
925 Views
I am drawing text on the client area as a series of vectors. The vectors depend on the font. The text can be at any position, size and rotation.

I can draw text using a number of fonts, but I must have the definition of the font as vectors.

I now want to be able to draw text using any font - such as true type fonts. Is there any way to do this?

Thanks,

David?
0 Kudos
7 Replies
Jugoslav_Dujic
Valued Contributor II
925 Views
Font is a GDI object similar to a, say, brush or pen. Font is created
using CreateFont or CreateFontIndirect, which return a font handle.
Then, you select a font into DC with SelectObject and any subsequent
text-drawing operations will be performed using that font:

 
hArialH8=CreateFont(-iFontSize,0,0,0,FW_NORMAL,0,0,0,          & 
      DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,  & 
      DEFAULT_QUALITY,DEFAULT_PITCH,'Arial'C) 


creates a Arial 8 pt font (normal, horizontally drawn). First several
arguments determine bold, italic, underline and rotation attributes
(see SDK documentation). Now, if you need several fonts, you can
define an array of hFonts and select them into DC as needed (of
course, be careful to do DeleteObject with all when not needed
anymore). TextOut, DrawText, TabbedTextOut will all use the
font selected.

Regards

Jugoslav
0 Kudos
davidgraham
Beginner
925 Views
I have tried using CreateFont and it works well - but the 4th parameter - the orientation, doesn't seem to work as there is no change in the text display.

Thanks,

David
0 Kudos
Jugoslav_Dujic
Valued Contributor II
925 Views
You have to set both nEscapement (3rd) and nOrientation (4th) arguments
to the same value in order to get it. IIRC, Windows NT/2000 handles
those separately, while under Win98 they must be the same.

Jugoslav
0 Kudos
davidgraham
Beginner
925 Views
Is there a call to return the size of a text string in the currently selected font, i.e. the height and length, or the coordinates of the corners of the text rectangle?
0 Kudos
Jugoslav_Dujic
Valued Contributor II
925 Views
GetTextExtentPoint32.

David, I don't want to be offensive, but I think you'd be far more efficient
if you consult your manual from time to time. All the information I posted
here is clearly stated in Win32 SDK help. The one about orientation is
described under CreateFont reference, while you could find this one if
you click on "Group" button for a text-output function you're familiar with (say, TextOut). SDK/MSDN is organized in chapters, and every chapter ends with reference section, describing structures, messages and functions related with the topic. Isn't it easier to do some investigation with the information you have at hand than to post a question here and wait for someone to answer?

Jugoslav
0 Kudos
davidgraham
Beginner
925 Views
Jugoslav,
Sorry, with some these questions I looked in the help, didn't find the answer, posted a question, did some more investigation then found the answer.
As you say I will have to do more investigation in future before posting.
Regards,
David
0 Kudos
Intel_C_Intel
Employee
925 Views
Hi David,

I highly recommend "Programming Windows, The Definitive Guide to the Win32 API" by Charles Petzold. (the fifth edition of this windows programming classic)

Windows application programming in Fortran is just SDK programming, for which Petzold is the reference, from his first edition (Win 3.1) to his fifth. If you can manage the mental translation from C to Fortran there is no better reference.

hth,
John
0 Kudos
Reply