c++ - word wrapping block of text with variable font/formatting using winapi -


i need draw arbitrary string directly on screen (not inside rich text control) using mfc and/or windows api. characters within string can vary in font face or color, , can bold, italic, underlined, or combination of two. additionally, users can choose wrap text within bounds of choosing, option force fit adjusting font size.

i'm thinking of doing along lines of:

  1. parsing vector of substrings , formats
  2. using getcharabcwidthsfloat calculate widths of substrings
  3. manually calculating line breaks need fall
  4. repeating above iteratively smaller fonts if necessary make text fit
  5. drawing each of substrings individually drawtextw, determining locations using widths of preceding substrings , line break points

is there better approach? if not, there gotchas or tricks should aware of when implementing this?

(i'm aware of dt_calcrect | dt_wordbreak flags drawtext, don't think that'll work me because a) assumes consistent font/formatting across whole string , b) saw message board posts stating doesn't calculate widths of italic characters correctly. true?)

xaml friend. not natively supported without .net, there 3rd party libraries (e.g. xtreme toolkit pro). here's demonstration of xaml markup feature: http://www.codejock.com/download/win32/markupsample.zip

been using years. can't complain.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -