all groups > dotnet drawing api > november 2007 >
You're in the

dotnet drawing api

group:

Size on string with inline formatting



Size on string with inline formatting sparkesy
11/6/2007 10:41:03 AM
dotnet drawing api: Hi all,

MeasureString takes only a string as an argument with specified formatting
etc. Is it possible (or is anyone aware of any utils) that enable you to
measure the size of strings with inline formatting.

ie

"this is normal. <b>this is bold</b>. this is normal."

...........is different from

"this is normal. this is bold. this is normal."

(please imagine formatting and not mark up if this isn't displaying
correctly!)


I need to know the height of some text which has inline formatting - I know
the width it needs to fit into.

Obviosuly if some text is bold or italic, it will fill more horizontal space
and possbly increase the overall height given a fixed width.

Any ideas / pointers greatly apprecitated

Re: Size on string with inline formatting Bob Powell [MVP]
11/10/2007 1:47:53 PM
You'll have to use MeasureCharacterRanges and accumulate the sizes.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


[quoted text, click to view]
AddThis Social Bookmark Button