Determining the length of text

Discussion in 'ASP .Net' started by blue, Nov 20, 2003.

  1. blue

    blue Guest

    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
    blue, Nov 20, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    >
    >
    Kevin Spencer, Nov 20, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mitchua
    Replies:
    5
    Views:
    2,707
    Eric J. Roode
    Jul 17, 2003
  2. SamIAm
    Replies:
    0
    Views:
    391
    SamIAm
    Feb 9, 2004
  3. =?Utf-8?B?SG96aQ==?=
    Replies:
    1
    Views:
    6,928
    Ken Cox [Microsoft MVP]
    Jun 2, 2004
  4. Replies:
    2
    Views:
    297
    Michael Spencer
    Mar 14, 2005
  5. Simon Wigzell

    Determining string length in pixels

    Simon Wigzell, Aug 7, 2003, in forum: Javascript
    Replies:
    1
    Views:
    93
    Grant Wagner
    Aug 7, 2003
Loading...

Share This Page