Friday, June 26, 2009

[adhajukl] Text width

Given a line of text in a variable-width font, calculate how wide it is in inches or pixels. Ligatures and kerning make the problem non-trivial. Also if the character format is permitted to change mid-line.

No doubt this has already been done; I am interested in a solution for LaTeX or Postscript.

2 comments :

qu1j0t3 said...

The [La]TeX solution is trivial, just fill one of the box variables with an \hbox{} then use the hbox width getter. This will use ligatures and pair kerning.

In PostScript you don't have access to ligature and kerning data directly, so the analogous () stringwidth ignores those factors.

Ken said...

What's the "hbox width getter"?