# How to make the url package respect fontspec font options (stylisticset) with LuaLaTeX

I use the inconsolata zi4 font as the monospace font in my document but use the curved l as well as the straight quote thought the stylisticset option in fontspec. however, when using the url package and compiling using lualatex, these options are ignored and the glyphs used are the default ones:

\documentclass[varwidth]{standalone}
\usepackage{fontspec}
\setmonofont[StylisticSet={1,3}]{Inconsolata zi4}

\usepackage{url}

\begin{document}

\texttt{/usr/local/lib/2015'} % using mono font directly

\path{/usr/local/lib/2015'} % through the url package

\end{document}


The path one should look like the texttt one which obey the fontspec options. Anyone know how to fix this?

• I don't have the font but using another mono font in my computer (Courier New), the fonts are the same in both those lines. Maybe it's an issue with that font? – Alenanno Jun 16 '15 at 16:52
• it is possible. although courier does not have stylisticset options so not quite relevant in this case. The font comes directly in texlive. – ArTourter Jun 16 '15 at 17:01

My feeling is that luaotfload makes LuaTeX ignore the choice of stylistic sets when the font is used in math mode.

In order to prove my claim, I did

\mathcode=\numexpr"7000+\mathcode\relax


and tried $\mathtt{}$, which resulted in the curly backquote no matter what stylistic set in used in the definition of the mono font. Note that url typesets the URL using math mode.

As such, this seems a bug in luaotfload or in LuaTeX.

Workaround: typeset the quotes inside an \mbox.

\documentclass[border=3,varwidth]{standalone}
\usepackage{fontspec}
\setmonofont[StylisticSet={1,3}]{Inconsolatazi4}

\usepackage{url}

\makeatletter
\do\{\mbox{\UrlFont\char\}}%
\do\'{\mbox{\UrlFont\char\'}}%
\do\l{\mbox{\UrlFont\char\l}}%
}
\makeatother

\begin{document}

\texttt{/usr/local/lib/2015'} % using mono font directly

\path{/usr/local/lib/2015'} % through the url package

\setmonofont{Inconsolatazi4}

\texttt{/usr/local/lib/2015'} % using mono font directly

\path{/usr/local/lib/2015'} % through the url package

\end{document}


This will work also with XeLaTeX, although this engine doesn't need the hack, so the more complicated

\usepackage{ifluatex}
\makeatletter
\ifluatex
\do\{\mbox{\UrlFont\char\}}%
\do\'{\mbox{\UrlFont\char\'}}%
\do\l{\mbox{\UrlFont\char\l}}%
}
\fi
\makeatother


is not really necessary.

• You'll have to do the same for the 'l' as well, and any other stylistic variant. – Alan Munn Jun 19 '15 at 16:26
• @AlanMunn I didn't notice the ‘l’. I'll fix it. – egreg Jun 19 '15 at 16:28
• @egreg That indeed works. For completeness, one also should add \do\0{\mbox{\UrlFont\char\0}}% for the unslashed 0 with stylisticset 2 (I don't use that one but it is there). – ArTourter Jun 19 '15 at 17:31
• I will accept this answer as it solves my problem. But as you say, it is a bug somewhere in lualatex or luaotfload and it probably be a good thing to report it. I guess the lualatex-dev mailing list is the appropriate place to do so. – ArTourter Jun 19 '15 at 22:35