gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.73k stars 125 forks source link

Minted ignores fontfamily setting #365

Closed stephenlevitt closed 1 year ago

stephenlevitt commented 1 year ago

Tested platforms: Windows 10, MiKTeX 23.1 Versions:

I am trying to use Inconsolata for minted listings only - not the entire LaTeX document. As far as I can tell, the font is installed correctly because it is found when specifying it for normal text. However, when explicitly set as the font for a minted listing it cannot be found. See the MWE below and specifically the last line. I am not sure why this does not work.

\documentclass{article}

\usepackage{fontspec}
\usepackage[outputdir=./out]{minted}

\newfontfamily{\inconsolata}{InconsolataLGCMarkup}[Extension=.otf, ItalicFont =*-Italic, BoldFont=*-Bold, Scale=MatchLowercase]

\begin{document}

This is the main document font: 0 1 2

{\inconsolata This is the main document font typeset using Inconsolata: 0 1 2}

\mint[fontfamily=tt]{text}| This is a minted listing with the default typewriter font: 0 1 2 |
\mint[fontfamily=helvetica]{text}| This is a minted listing with Helvetica: 0 1 2 |
\mint[fontfamily=inconsolata]{text}| This is a minted listing should be typeset with Inconsolata: 0 1 2 |

\end{document}

Output: 2023-04-21 12_45_08-code-font-mwe pdf — Mozilla Firefox

gpoore commented 1 year ago

minted uses fancyvrb to typeset the code. The fontspec manual gives an example using fancyvrb, and in the \newfontfamily definition uses the equivalent of NFSSFamily=inconsolata. I'd suggest starting there.

stephenlevitt commented 1 year ago

Thanks! The following change produces the correct results: \newfontfamily{\inconsolata}{InconsolataLGCMarkup}[NFSSFamily=inconsolata, Extension=.otf, ItalicFont =*-Italic, BoldFont=*-Bold, Scale=MatchLowercase]

goyalyashpal commented 1 year ago

The fontspec manual gives an example using fancyvrb, and in the \newfontfamily definition uses the equivalent of NFSSFamily=inconsolata. I'd suggest starting there.

can you share the links :smiley:

is it this one:

stephenlevitt commented 1 year ago

Yes, that's it.