Any automated system to compute the linear length of a letter(s) in a word or phrase?

I may be way out of league asking this question but is there a way to get the linear length of a letter or words. That is, if you were to take the word “super” and measured the outside border of the letters you’d get a measurement. Is there something out there that would tell me this measurement if I give the font and the font size? I’m a rookie here so be gentle. thanks in advance.

Answer

This is trivial to do using TeX/LaTeX (though you’ll want to use a newer version such as xetex or luatex so as to be able to easily access OpenType and TrueType fonts):

\documentclass{standalone}
\usepackage{fontspec}
\setmainfont{Myriad Pro Black Condensed}% <<-- change to desired font
\usepackage[nomessages]{fp}
\makeatletter
\newcommand{\printer}[3][in]{%
\FPeval\temp{round(\expandafter\strip@pt\csname#2\endcsname/72.27:#3)}%
\temp#1}
\makeatother
\begin{document}
\newlength{\samplewidth}
\settowidth{\samplewidth}{Test} % <<-- change to the text which you wish to measure
\printer{samplewidth}{4}
\end{document}

which will output: 0.2060in

OpenType features are supported:

\settowidth{\samplewidth}{Test 0123456789}
\printer{samplewidth}{4}\par
\addfontfeature{Numbers={Proportional,Lining}}
\settowidth{\samplewidth}{Test 0123456789}
\printer{samplewidth}{4}

which outputs:

0.8425in

0.7911in

Attribution
Source : Link , Question Author : mrbungle , Answer Author : WillAdams

Leave a Comment