HighTechTalks DotNet Forums  

Size on string with inline formatting

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Size on string with inline formatting in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
sparkesy
 
Posts: n/a

Default Size on string with inline formatting - 11-06-2007 , 12:41 PM






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

Sparkesy.

Reply With Quote
  #2  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Size on string with inline formatting - 11-10-2007 , 06:47 AM






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.


"sparkesy" <sparkesy (AT) discussions (DOT) microsoft.com> wrote

Quote:
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

Sparkesy.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.