Russ has asked for the wisdom of the Perl Monks concerning the following question:

This is a question from Categorized Q&A. I have re-titled it and submitted it here, hoping for some good responses to a common problem.
Please do not vote for this node, it will affect the wrong user. Thank You -- Q&AEditors

I have a datafeed that needs to truncate the input lines so that they don't break in a specific width table.

Other than dumping the font metrics to a table (the designers are using a single Web-ish true-type font), how can I determine the string width, accounting for paired kerning?

  • Comment on How can I force a table cell to be no bigger than a certain size?

Replies are listed 'Best First'.
Re: How can I force a table cell to be no bigger than a certain size?
by t0mas (Priest) on Jul 21, 2000 at 10:31 UTC
    A dirty suggestion:
    You can use GD::Image->stringTTF to get the bounds of a string printed on a GD Image. Maybe It will not be exact the same size on a browser page but it might work. I use it to scale the text on PNG buttons in some code I wrote and posted at ButtonFactory

    /brother t0mas
Re: How can I force a table cell to be no bigger than a certain size?
by merlyn (Sage) on Jul 21, 2000 at 17:20 UTC
    The moment you use "force" in the same sentence as "web", you're doomed.

    If you need a specific appearance, send image data or a PDF. The web is meant to be reformatted to the user's wishes, not yours.

    -- Randal L. Schwartz, Perl hacker