5

I am trying to sample the available fonts in "detail", and I wrote a small LaTeX document to have a visual comparison of fonts, with the main characteristics highlighted. I have a couple of problems with my approach and hence I am trying to see if the all-powerful tex.SE \deitys have a better idea.

Please consider the following not-so-much minimal AWE (almost working example):

\documentclass[margin=20pt,varwidth=100cm,]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{calc, positioning}
\usepackage{lmodern}
\usepackage{venturis}
\usepackage{librebaskerville}

\newlength\caph\newlength\desc\newlength\xlen\newlength\mlen%
\newcommand*{\prlen}[1]{%
   % round to 1 digit:
   \pgfmathparse{round(10*#1)/10.0}%
   \pgfmathresult
}
%
\newcommand{\showfont}[1]{%
\setlength{\caph}{\heightof{A}}%
\setlength{\desc}{\depthof{Q}}%
\setlength{\xlen}{1ex}%
\setlength{\mlen}{1em}%
\begin{tikzpicture}[
        every node/.style={inner sep=0pt},
    ]
    \path (0,0) node[anchor = south west] (A) {#1} ;
    \draw[red] (A.base west) -- (A.base east);
    \coordinate (Aex) at ($(A.base west)+(0,\xlen)$);
    \draw[blue] (Aex)  --  ($(A.base east)+(0,\xlen)$);
    \coordinate (Adesc) at ($(A.base west)-(0,\desc)$);
    \draw[blue] (Adesc) -- ($(A.base east)-(0,\desc)$);
    \coordinate (Acaph) at ($(A.base west)+(0,\caph)$);
    \draw[blue] (Acaph) -- ($(A.base east)+(0,\caph)$);
    \draw[green!60!black, thick] (Adesc) rectangle ++(\mlen, \mlen)
        coordinate (Amlen);
    %% 
    \small\ttfamily
    \node [left=1em of A.base west, anchor=east, ] {baseline}; 
    \node [left=1em of Aex, anchor=east, ] {1ex=\prlen{\xlen} pt}; 
    \node [left=1em of Adesc, anchor=east, ] {desc=\prlen{\desc} pt}; 
    \node [left=1em of Acaph, anchor=east, ] {caph=\prlen{\caph} pt}; 
    \node [above right =1em of Amlen, anchor=west, ] {1em=\prlen{\mlen} pt}; 
\end{tikzpicture}%
}

\begin{document}

\librebaskerville
\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\bigskip

\fontfamily{yvtj}\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\bigskip

\fontfamily{yvtd}\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\bigskip

\fontfamily{lmr}\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\end{document}

which gives:

font sample

My question is: I used to use the depth of the lowercase "p" to find the descendant, until I found a small-caps font as in the example, and I switched to the uppercase "Q". But I understand this will be font dependent.

Now, I know the there are \fontdimen for x-height and em: is there some way to find the design-size as descendant, cap-height of a font in a generic way?

I wouldn't mind to switch to xelatex or luatex if needed. And finding also the axis of the font wold be really nice...

  • 1
    No, there's nothing like a parameter that refers to “the maximum depth of descenders”. Also the x-height might not reflect the height of lowercase letters without an ascender; it usually does, but it's not mandatory. Depending on the font, the height of capital letters may not be the same as the height of ascenders in lowercase letters. – egreg Apr 10 '16 at 10:48
6

Instead of guessing the letters, I'd use the whole alphabet.

\documentclass[margin=20pt,varwidth=100cm,]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}
\usepackage{lmodern}
\usepackage{venturis}
\usepackage{librebaskerville}

\newlength\caph
\newlength\desc
\newlength\xlen
\newlength\mlen
\newcommand*{\prlen}[1]{%
   % round to 1 digit:
   \pgfmathparse{round(10*#1)/10.0}%
   \pgfmathresult
}

\newcommand{\Alphabet}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\newcommand{\alphabet}{abcdefghijklmnopqrstuvwxyz}

\newcommand{\showfont}[1]{%
  \settoheight{\caph}{\Alphabet}%
  \settodepth{\desc}{\Alphabet\alphabet}%
  \setlength{\xlen}{1ex}%
  \setlength{\mlen}{1em}%
  \begin{tikzpicture}[
        every node/.style={inner sep=0pt},
    ]
    \path (0,0) node[anchor = south west] (A) {#1} ;
    \draw[red] (A.base west) -- (A.base east);
    \coordinate (Aex) at ($(A.base west)+(0,\xlen)$);
    \draw[blue] (Aex)  --  ($(A.base east)+(0,\xlen)$);
    \coordinate (Adesc) at ($(A.base west)-(0,\desc)$);
    \draw[blue] (Adesc) -- ($(A.base east)-(0,\desc)$);
    \coordinate (Acaph) at ($(A.base west)+(0,\caph)$);
    \draw[blue] (Acaph) -- ($(A.base east)+(0,\caph)$);
    \draw[green!60!black, thick] (Adesc) rectangle ++(\mlen, \mlen)
        coordinate (Amlen);
    %% 
    \small\ttfamily
    \node [left=1em of A.base west, anchor=east, ] {baseline}; 
    \node [left=1em of Aex, anchor=east, ] {1ex=\prlen{\xlen} pt}; 
    \node [left=1em of Adesc, anchor=east, ] {desc=\prlen{\desc} pt}; 
    \node [left=1em of Acaph, anchor=east, ] {caph=\prlen{\caph} pt}; 
    \node [above right =1em of Amlen, anchor=west, ] {1em=\prlen{\mlen} pt}; 
  \end{tikzpicture}%
}

\begin{document}

\librebaskerville
\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\bigskip

\fontfamily{yvtj}\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\bigskip

\fontfamily{yvtd}\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\bigskip

\fontfamily{lmr}\fontsize{100pt}{120pt}\selectfont
\showfont{Quora Aegis 3.14159}

\end{document}

The x-height, available on a font basis as 1ex, need not reflect the height of lowercase letters without ascenders; it usually does, however. The height of capitals might not be the same as the ascenders of lowercase letters, so you may want to distinguish between the two, at least for the fonts with this property.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.