• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How to precisely measure fonts?

kranky

Elite Member
We have to do an application that involves putting variable length text strings onto labels. We need to make sure the text isn't too long to fit on the label. In order to do this, we need to come up with a way (from a program) to calculate exactly how long a text string is in a particular font and size. We need to be very accurate - like within a centimeter.

One way would be to build a table that has the width of each character and then examine the text string to calculate the sum of the character widths. But we don't know how to determine accurately what the width of each character is. Does anyone know if Fontographer can do this? Other software?

We tried using the "Cadillac" of label software (Codesoft) instead of doing our own but it's so brain-dead it will not detect that the text is too long to fit on the specified label.
 
If you're writing your own code, the windows API function GetTextExtentPoint32 is accurate to either 1 device pixel or 1/1440 of an inch for whatever the current selected font is in the printer device context.

The table of character witdths idea won't work because of kerning in proportional fonts, but would work with a fixed-pitch font like courier.
 
Back
Top