# Call a (luatex-)combo font through NFSS

After some struggles I found a way to call a combo-font (which combines glyphs from two fonts) so that I can get various font sizes.

Has anyone an idea how one could inject this code (or other code with a similar behaviour) in a \DeclareFontShape so that the font could be called through NFSS?

\documentclass[parskip=half-]{scrartcl}
\usepackage{fontspec,xfp}

\newcommand\requestmycombofont[1]{%
\ifcsname mycombofont.#1\endcsname
\else
\font \one = {file:lmmono10-regular.otf}  at \fpeval{#1*10}pt
\font \two = {file:lmsans10-regular.otf}  at \fpeval{#1*15}pt
\expandafter\font \csname mycombofont.#1\endcsname
= "combo: 1 -> \fontid \one            ;
2 -> \fontid \two , 0x41-0x5A;"%
\fi
\csname mycombofont.#1\endcsname
}

\DeclareFontFamily{TU}{xxx}{}

%\DeclareFontShape{TU}{xxx}{m}{n}{<-> how to call the combo font here ??????? }{}
% simply defining \csname TU/xxx/m/n\endcsname is not enough ...

\begin{document}
\section{Direct call}
{
\requestmycombofont{1.1}%
Some Text with Capital Words

\requestmycombofont{1.3}%
Some Text with Capital Words

\requestmycombofont{0.5}%
Some Text with Capital Words

}

\section{Call through nfss?}
\normalsize
\fontfamily{xxx}\selectfont
% should do \makeatletter \requestmycombofont{\fpeval{\f@size/10}}
Some Text with Capital Words

\large
% should do \requestmycombofont{\fpeval{\f@size/10}}
Some Text with Capital Words
\end{document}


David Carlisle gave me the tipp to use a size-function to inject the necessary code in \DeclareFontShape and so I wrote a small, (very experimental) package combofont: http://www.ctan.org/pkg/combofont

With it the font can be declared like this:

\RequirePackage{luatex85}
\documentclass[parskip=half-]{scrartcl}
\usepackage{combofont}

\setupcombofont{combotest-regular}
{
{file:lmmono10-regular.otf:\combodefaultfeat} at #1pt,
{file:lmsans10-regular.otf} at \fpeval{#1/10*15}pt
}
{
{} ,
0x41-0x5A*0x21*0x3F
}

\DeclareFontFamily{TU}{combotest}{}
\DeclareFontShape{TU} {combotest}{m}{n}{<->combo*combotest-regular}{}
\begin{document}

\fontfamily{combotest}\selectfont
A Text with Some Capitals!

\large
A Text with Some Capitals!

\scriptsize
A Text with Some Capitals!

\end{document}


• OK, but what is it good for? And could you comment you code a little bit more? May 28, 2017 at 19:09
• @KeksDose: You can fill "holes" (missing glyphs) in existing font and so use these glyphs without have to switch the font. See e.g. tex.stackexchange.com/questions/369194/…. For more comments check the documentation of the package. May 29, 2017 at 10:09
• Thank you! I'll read that. Using e.g. the "§" from a different font would be very interesting. And my apologies for the somewhat harsh question, wasn't meant that way! May 29, 2017 at 10:12