Balakumar

Hi,

I want to draw multiple strings with different fonts on multiple lines without breaking the lines. The output should look like a continuous line with different fonts.

For ex:

I want to draw a text string such as the below one and my window is having a size such that the text is diaplayed as shown below.

"Only two things are infinite, the universe and

human stupidity, and I'm not sure about the former.

- Albert Einstein"

Now I want to display the above string as follows with new fonts so that the end user observes the message to be continuous.

"Only two things are infinite, the universe and

human stupidity, and I'm not sure about the former.

- Albert Einstein"

Currently I have splitted the whole string into a number of substrings depending upon the required number of fonts. Then I use DrawText() to draw the strings. After drawing a string I am using GetTextExtentPoint32() to find out the SIZE of the drawn text to decide my indent for drawing the next string. While I try to do so, I get an output as below. After this the remaining text is also drawn in a jumbled fashion.

"Only two things are infinite, the universe and

human stupidity,

Please someone help me in drawing the text with different fonts on multiple lines using VC++, Windows programming.

Thanks,

Bala




Re: Visual C++ General Drawing text with different fonts on multiple lines without breaking the lines

Ramkrishna Pawar

You must use one DrawText (or similar) call per font and other specifics, in my knowledge, there is no API which will allow you to draw complete multi font sentence in one call.

Why do you want to do this in one call anyway






Re: Visual C++ General Drawing text with different fonts on multiple lines without breaking the lines

Simple Samples

I suggest looking closely at the documentation, especially the formatting flags. A likely better solution however is to use a different function for writing the text. Look at the TextOut function. I think it has other options for alignment that might help.