fonts add tag
samcarter
With all the drawing tools in the TeX ecosystem, it is tempting  to use them to draw new symbols. While there are several approaches to make them scale well with the surrounding text, choosing a stroke width, which will blend in, is much trickier.

For a math font, I'd use the thickness of the fraction bar as an approximation. But for text fonts, the only approach I can think of is to test for the current font and then look up some value in a manually curated look-up table. Here a quick sketch for just 3 different fonts:


```
\documentclass{article}

\usepackage{tgbonum}
\usepackage{tikz}

\newlength{\Iheight}
\newlength{\stroke}

\ExplSyntaxOn
\makeatletter
\newcommand{\quack}{%
  \setlength{\Iheight}{\fontcharht\font`I}%
  \str_case_e:nnF { \f@family }{
      {qbk} { \dim_set:Nn \stroke { 0.12\Iheight } }
      {bch} { \dim_set:Nn \stroke { 0.1\Iheight } }
      % ....
    }{
      \dim_set:Nn \stroke { 0.06\Iheight }
    }
  \begin{tikzpicture}[baseline]
    \draw[line~width=\stroke] (0,0) -- (\Iheight,\Iheight)
     (0,\Iheight) -- (\Iheight,0);
  \end{tikzpicture}~
}
\makeatother
\ExplSyntaxOff

\begin{document}

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{bch}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{cmr}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\end{document}
```

![Screenshot 2025-08-14 at 23.19.33.png](/image?hash=338e099bebfaad437603b932eed2f888359e7fce5841d18227be0ee403b3457e)

Given the number of fonts, families etc. this will get out of hand very quickly. Is there any other property I could use as an approximation? It wouldn't have to be perfect or work in all cases, but just to reduce the number of cases I would have to deal with manually?
Top Answer
Skillmon
I had a brilliant idea, really brilliant idea. I thought, the hyphen's height should correlate with the font weight. And for the first two fonts that's indeed the case, but not for CMR, which doesn't set a tight bounding box above the hyphen.

Next idea: The dot, provided it got a tight bounding box, should correlate with the weight. At least the three fonts you showcase in your questions in fact do have tight boxes.

Well, turns out that at least for the fonts you showcased plus the medium weight serif font of `kpfonts` the estimate works quite well when one checks how much bigger than 1pt the height of the dot is.

The first code block here has the heights calculated from the values you used (so should come pretty close to your `0.12\Iheight` and `0.1\Iheight` in the end).

```
\documentclass{article}

\usepackage{tgbonum}
\usepackage{tikz}

\newlength{\Iheight}
\newlength{\dotheight}
\newlength{\stroke}

\ExplSyntaxOn
\makeatletter
\newcommand{\quack}{%
  \setlength{\Iheight}{\fontcharht\font`I}%
  \dim_set:Nn \dotheight { \fontcharht\font`\. - 1pt }%
  \str_case_e:nnF { \f@family }{
      {qbk} { \dim_set:Nn \stroke { 5.71\dotheight } }
      {bch} { \dim_set:Nn \stroke { 5.4\dotheight } }
      % ....
    }{
      \dim_set:Nn \stroke
        {
          \bool_lazy_or:nnTF
            % if the size is smaller than 1pt the formula wouldn't work well
            { \dim_compare_p:nNn \dotheight < \c_zero_dim }
            % some arbitrary guess whether the bounding box is unreasonably big
            { \dim_compare_p:nNn \dotheight > { \f@size pt / 8 } }
            { 0.06 \Iheight }
            { 5.7 \dotheight }
        }
    }
  \begin{tikzpicture}[baseline]
    \draw[line~width=\stroke] (0,0) -- (\Iheight,\Iheight)
     (0,\Iheight) -- (\Iheight,0);
  \end{tikzpicture}~
}
\makeatother
\ExplSyntaxOff

\begin{document}

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{bch}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{cmr}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{jkp}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\end{document}
```

![foo.png](/image?hash=94a395c2d3b06b7ae34cbc7872d3ef68daa442643b1fe439eeb11455083c234e)

This here simply uses the factor 6 for all fonts (the difference to your hand selected values isn't that big actually):

```
\documentclass{article}

\usepackage{tgbonum}
\usepackage{tikz}

\newlength{\Iheight}
\newlength{\dotheight}
\newlength{\stroke}

\ExplSyntaxOn
\makeatletter
\newcommand{\quack}{%
  \setlength{\Iheight}{\fontcharht\font`I}%
  \dim_set:Nn \dotheight { \fontcharht\font`\. - 1pt }%
  \dim_set:Nn \stroke
    {
      \bool_lazy_or:nnTF
        % if the size is smaller than 1pt the formula wouldn't work well
        { \dim_compare_p:nNn \dotheight < \c_zero_dim }
        % some arbitrary guess whether the bounding box is unreasonably big
        { \dim_compare_p:nNn \dotheight > { \f@size pt / 8 } }
        { 0.06 \Iheight }
        { 6 \dotheight }
    }
  \begin{tikzpicture}[baseline]
    \draw[line~width=\stroke] (0,0) -- (\Iheight,\Iheight)
     (0,\Iheight) -- (\Iheight,0);
  \end{tikzpicture}~
}
\makeatother
\ExplSyntaxOff

\begin{document}

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{bch}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{cmr}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\bigskip

\fontfamily{jkp}\selectfont

Nam dui ligula Nam dui ligula

Nam dui ligula \quack Nam dui ligula

Nam dui ligula Nam dui ligula

\end{document}
```

![foo.png](/image?hash=723712957280ef72e6e0f69f2503e8056cc495ff793dcc3bc9df7053df9b0c71)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.