Working out size of strings made of varable width fonts.

I want to use this to put truncate stuff and put … If a text string in too long.

I can work out how to do this in thery, with an array of chars and relative widths (for a specific font, in my case Helvitica) but can find details fo the widths anywhare. Any ideas?

Yes: forget it.

The web is not print. You may specify 12pt Helvetica but what the
end user sees may be something else -- a different font, a different
size, different kerning, different line height, different word-spacing...

That's aside from the question of "too long" for what? To fit in a
container that's probably variable in size as well?

Seems unlikely to be time well spent :slight_smile:

There is a CSS property for overflow, which will take the letterforms and specific characters into account. See more here: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow

Walter

I want to use this to put truncate stuff and put ... If a text string in too long.

There is a CSS property for overflow, which will take the letterforms and specific characters into account. See more here: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow

Sorry for the premature Send, I really meant this: https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow

This does the same thing as overflow but for runs of text, and puts an ellipsis at the end as you describe.

Walter

/me realizes how long it's been since I did *any* UI/CSS work... :roll_eyes:

Thanks. Will have a look but it's CSS cards using UL tag and flux-box. If I had realised it would be a CSS question I would of posted elsewhere.