• Advertisement
Sign in to follow this  

Two colors in one text - function DrawText

This topic is 2351 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.

Is there any way to one used function DrawText and draw text in two colors?

For example:

font->DrawText(sprite ,L"He is |color-red| fast.",-1,&RCT,DT_NOCLIP, D3DCOLOR_ARGB(0,0,0,255));

Appears:

He is [color="#FF0000"]fast.

Thank, regards.

Share this post


Link to post
Share on other sites
Advertisement
Short answer is no, not with the default ID3DX10Font interface.

What you could do however is write a separate function that takes (for example) an ID3DX10Font interface and a string as parameters. Then within the function you could parse the provided string and create an array or vector of sub-strings, and a corresponding D3DXCOLOR to go with each substring. Then once that is done you could call mFont->DrawText() on all of the sub-strings using it's corresponding color.

This may not be the best way to go about doing something like this, but it would probably work for your problem

Share this post


Link to post
Share on other sites
I would just implement bitmap fonts to get complete control. When the method read a reserved character, the following 32 bits will contain the new RGBA color.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement