7

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}

output

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
  • 3
    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
6
+50

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
\g@addto@macro\UrlSpecials{%
  \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}

enter image description here

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

\usepackage{ifluatex}
\makeatletter
\ifluatex
  \g@addto@macro\UrlSpecials{%
    \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
  • 1
    @AlanMunn I didn't notice the ‘l’. I'll fix it. – egreg Jun 19 '15 at 16:28
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.