How many chars can be displayed in a label?

  • Thread starter Thread starter True.Kilted.Scot
  • Start date Start date
T

True.Kilted.Scot

Folks,

I have a window in my database which contains 5 labels. These labels
are used for displaying altering text, with a font of Tahoma and a Font
Size of 10.77

For example...the first label might display "Starting........."
initially, and then this may change to "Running...". Once the
"Running..." process has completed, the text may change to "Stage One
Done...", with the second label changing to "Starting........." and so
on.

My question is this:

If each label has the same dimensions, namely:

Width = 7cm
Height = 0.5cm

and any label can display BOLD text as well as NORMAL, is there any way
I can calculate the number of characters that will be displayed within
the 7cm width of the label. For example, the text "The quick brown fox
jumped over the lazy dog" is too big for the box, just cutting of a
portion of the "g". If I change the text to BOLD, it now cuts off
everything after the "z" of lazy.


So, using the font name, the font size and the width of the label, can
I caluclate a rough approximation of the number of characters that can
be displayed in it?

Rgds

Duncs
 
It's not simple. Take a look at www.lebans.com and I think you'll find
something that lets you calculate the length of a string of text; you could
work backwards from there.
 
I have a window in my database which contains 5 labels. These labels
are used for displaying altering text, with a font of Tahoma and a Font
Size of 10.77

For example...the first label might display "Starting........."
initially, and then this may change to "Running...". Once the
"Running..." process has completed, the text may change to "Stage One
Done...", with the second label changing to "Starting........." and so
on.

My question is this:

If each label has the same dimensions, namely:

Width = 7cm
Height = 0.5cm

and any label can display BOLD text as well as NORMAL, is there any way
I can calculate the number of characters that will be displayed within
the 7cm width of the label. For example, the text "The quick brown fox
jumped over the lazy dog" is too big for the box, just cutting of a
portion of the "g". If I change the text to BOLD, it now cuts off
everything after the "z" of lazy.

So, using the font name, the font size and the width of the label, can
I caluclate a rough approximation of the number of characters that can
be displayed in it?


There's may be a combination of API calls that could be used
to figure the number of characters, but I have no idea what
they might be. I have never been concerned with the number
of characters because I have always wanted to determine the
width of the entire string.

If you can live with determining if the string will fit or
not or even how wide the text box needs to be to contain the
entire string, then download the TextHeightWidth db at
www.lebans.com
 

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

Back
Top