473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Determining the length of text

I have a table that I want to have a set width and height. The table has a
title and the text may be larger than the width of the table. If the text
is too large to fit into the table, it either line breaks or stretches the
width of the table depending on how large a word is.

For example, "this is a really long title" would line break, and
"this_is_a_really_long_word", would stretch the width of the title

I need the tables to be an exact size because it's a flowchart program and I
have directional lines connecting the tables to where it thinks the table
coords should be. If the table size changes, the lines go right through the
table and it looks bad.

I've fixed this problem by using tooltips if the number of characters of the
title exceed a certain amount (say 13). The problem is, not all letters
take up the same amount of space. Also, I don't want to hard code a font
face or size in my code. This will be handled by the style sheet later on
and whatever the designer picks for the visual layout should work without
having to change the code.

I can do the lowest common denominator and make the text tooltip at 8
characters (and assume a certain font and size). This is a boundry case and
the typical cases with characters that don't take up so much space look bad
with only a few letters and then "..." at the end telling the user to mouse
over to see the whole line. The 'M' character takes up much more space than
"u" or "o" but I have to handle the case where everything might be
uppercase.

Finally, my question: is there a way to know the length of text? I think
I'll have to pick a font face and stick with it. If there's a way to
determine the length of text by the characters it contains, the font size
and the font face, I'll be able to make it look better.

thanks,

blue
Nov 18 '05 #1
1 1458
I really don't think so. The problem is that depending on the browser, the
text (not to mention the surrounding HTML objects) may be larger or smaller,
or even a different font.

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"blue" <bl**@arizona.edu> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
I have a table that I want to have a set width and height. The table has a title and the text may be larger than the width of the table. If the text
is too large to fit into the table, it either line breaks or stretches the
width of the table depending on how large a word is.

For example, "this is a really long title" would line break, and
"this_is_a_really_long_word", would stretch the width of the title

I need the tables to be an exact size because it's a flowchart program and I have directional lines connecting the tables to where it thinks the table
coords should be. If the table size changes, the lines go right through the table and it looks bad.

I've fixed this problem by using tooltips if the number of characters of the title exceed a certain amount (say 13). The problem is, not all letters
take up the same amount of space. Also, I don't want to hard code a font
face or size in my code. This will be handled by the style sheet later on
and whatever the designer picks for the visual layout should work without
having to change the code.

I can do the lowest common denominator and make the text tooltip at 8
characters (and assume a certain font and size). This is a boundry case and the typical cases with characters that don't take up so much space look bad with only a few letters and then "..." at the end telling the user to mouse over to see the whole line. The 'M' character takes up much more space than "u" or "o" but I have to handle the case where everything might be
uppercase.

Finally, my question: is there a way to know the length of text? I think
I'll have to pick a font face and stick with it. If there's a way to
determine the length of text by the characters it contains, the font size
and the font face, I'll be able to make it look better.

thanks,

blue

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Geert-Pieter Hof | last post by:
Hello, I use a ListView control (report view) to show the user a summary of error messages. The width of the column that holds the error messages is such that no horizontal scrollbar is needed....
1
by: Simon Wigzell | last post by:
I am adapting a javascript pulldown menu system to my dynamic website generator - the arrays that hold the menu items information are read from a database and will be different for different users...
2
by: William Payne | last post by:
Hello, I am making a very simple and crude Makefile generator, that currently supports three different options: --project-name=<name_of_project>...
9
by: Christopher Benson-Manica | last post by:
I have the following situation: Page A opens a window named 'foo'. Page A then reloads itself. Is there a way for the reloaded Page A to determine whether there is an open window named 'foo',...
4
by: Ricky W. Hunt | last post by:
Is there an easy, flexible way to determine which radiobutton is checked within a groupbox without having to code for each button explicitly? It seems there would be some kind of index you could...
3
by: Jozef | last post by:
Hello, I'd like to determine the size of a file via a URL. I'm not even sure how to do this on the local machine, let alone a URL. Any help would be greatly appreciated. Thanks!
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
5
by: Jeremy | last post by:
Does anyone have a clever algorithm for generating an outline of the current document from (client-side) javascript using DOM methods? For example, let's say I predictably have a document...
0
by: JamC | last post by:
Hi I have a poker program... My code for Pair, 2 pair etc work, except when I code for a straight hand When I separate the sort function like below I can get it... public void straight() ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.