Preparing a book where I use JetBrains Mono (Github Repo) (JBM) for code I noticed that in all the listings the * characters where rendered far to deep (on the baseline) and quite big. Also the *** ligature came out as three (fallen) * glyphs.
At this point JBM was declared as a new family:
\newfontfamily\JBMmdfamily{JetBrains Mono}[
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic
]
After fiddling around a bit I found that adding {*}{*}1 {***}{{***}}3
entries to a literate
key in \lstset{}
seemed to work. So I exchanged those characters by themselves which is funny but it works. Sort of. Looking closer I noticed that in the output spaces after those characters disappeared. Adding the keepspaces setting remedied that, so:
\lstset{
keepspaces = true,
% showspaces = false,
literate = {*}{*}1 {***}{{***}}3
}
(showspaces = true
a lets other funny things happen but that is out of scope here.)
Later I noticed that just using
\setmonofont{JetBrains Mono}[…]
instead of
\newfontfamily\JBMmdfamily{JetBrains Mono}[…]
with the same body solved all those issues, no other \foo needed. I just don’t understand how that works. Someone care to explain?
My new problem now is, I need \texttt
(etc.) to switch to the text typewriter type.
Here’s sort of a MWE:
%!TEX TS-program = lualatex
\documentclass{article}
\usepackage{fontspec,listings}
\setmonofont{JetBrains Mono}[
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]
\newfontfamily\JBMmdfamily{JetBrains Mono}[
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]
\parskip=3mm
\parindent=0pt
\begin{document}
\subsection*{Both bindings seem to function:}
ttfamily: {\ttfamily x*y * z + a *** b }
JBMmdfamily: {\JBMmdfamily x*y * z + a *** b }
\subsection*{listings needs either \textbackslash{}ttfamily:}
lstlisting/ttfamily: \lstinline[basicstyle = \ttfamily]! x*y * z + a *** b !
lstlisting/JBMmdfamily: \lstinline[basicstyle = \JBMmdfamily]! x*y * z + a *** b !
\begin{lstlisting}[basicstyle = \ttfamily]
\ttfamily: x*y * z + a *** b
\end{lstlisting}
\begin{lstlisting}[basicstyle = \JBMmdfamily]
\JBMmdfamily: x*y * z + a *** b
\end{lstlisting}
\subsection*{… or keepspace \& literate:}
\lstset{
keepspaces = true,
% showspaces = true,
literate = {*}{*}1 {***}{{***}}3
}
lstlisting/ttfamily: \lstinline[basicstyle = \ttfamily]! x*y * z + a *** b !
lstlisting/JBMmdfamily: \lstinline[basicstyle = \JBMmdfamily]! x*y * z + a *** b !
\begin{lstlisting}[basicstyle = \ttfamily]
\ttfamily: x*y * z + a *** b
\end{lstlisting}
\begin{lstlisting}[basicstyle = \JBMmdfamily]
\JBMmdfamily: x*y * z + a *** b
\end{lstlisting}
\end{document}
Any ideas? Thanks for all nudges and pointers …
Just corrected the source and added a picture of my result. There were a few errors, sorry for that.