Limit the number of characters given a "Box" size

M

Mark

Hi, I am trying to work out a way where I can accurately predict the number
of character which will "fit" into a box size.

Say I have a virtual area of 500px by 200px I need to find out how many size
8 font characters will fit into this box.

I know that I could take the average and say that the average size 8 font is
12 pixels x 12 pixels so techinically, I should be able to fit in 694
characters into the area.

(500 x 200)/144 = 694 characters

However, what given that some characters can be bigger than others (W is
wider than the letter l for example) this kills my averages I cannot get any
real accuracy and it is causing major headaches.

Any ideas more than welcome!
Thanks
M
 
P

Peter Rilling

Well, in general you can try the MeasureString method. But I am not sure
how this will be beneficial in a web environment since the server has no
control over the appearance on the browser. Any measurements will be
calculated on the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top