2

I'm trying to typeset a document using minted code listings that contain quite some amount of non-standard Unicode characters. I'd like to use Ubuntu Mono as a monospaced font. The following supresses unicode characters:

\documentclass{book}
\usepackage{minted}
\usepackage{fontspec}
\setmonofont{Ubuntu Mono}

\begin{document}

\begin{minted}{java}
Π ⦃a : D₀⦄
\end{minted}

\end{document}

Am i doing something wrong or is the font just not as complete as I'd like it to be?

  • Hi and welcome, you can use tools like fontforge to view the different letters of a font. If the respective code point is empty or crossed out, the font does not contain the glyph. – Johannes_B Mar 27 '15 at 15:41
  • The end of the log-file reveals some bad news Missing character: There is no ⦃ in font Ubuntu Mono/OT:script=latn;language=DF LT;! – Johannes_B Mar 27 '15 at 15:49
  • Thanks for your help! Do you know how to set a substitution font and what font would you use for that? – javra Mar 27 '15 at 15:55
  • To be quite honest, no idea what font may contain that glyph, especially in a monospace/ttype version. It seems a bot odd to me, that you have a mathematical formula in a code listing, or monospaced in general. Out of interest, is there a special reason? – Johannes_B Mar 27 '15 at 16:13
  • It's code for the theorem prover Lean. Is there a way to find out what substitution font my editors on Ubuntu use for this glyph? Because there, it looks pretty nice... – javra Mar 27 '15 at 16:21
4

You can take the missing characters from a font that has them:

\documentclass{book}

\usepackage{fontspec}
\usepackage{minted}
\usepackage{newunicodechar}

\setmonofont{Ubuntu Mono}
\newfontfamily{\freeserif}{FreeSerif}

\newunicodechar{⦃}{\makebox[.5em]{\freeserif⦃}}
\newunicodechar{⦄}{\makebox[.5em]{\freeserif⦄}}

\begin{document}

\begin{minted}{java}
Π ⦃a : D₀⦄
\end{minted}

\end{document}

enter image description here

The red boxes are a pygmentize problem.

The characters are also in DejaVu Sans; here's how they appear (with also a workaround for the red boxes):

\documentclass{book}

\usepackage{fontspec}
\usepackage{minted}
\usepackage{newunicodechar}

\AtBeginEnvironment{minted}{%
  \let\MINTEDPYGdefault\PYGdefault
  \renewcommand\PYGdefault[2]{%
    \ifstrequal{#1}{err}%
      {\MINTEDPYGdefault{n}{#2}}%
      {\MINTEDPYGdefault{#1}{#2}}%
  }%
}

\setmonofont{Ubuntu Mono}
\newfontfamily{\freeserif}{DejaVu Sans}

\newunicodechar{⦃}{\makebox[.5em]{\freeserif⦃}}
\newunicodechar{⦄}{\makebox[.5em]{\freeserif⦄}}

\begin{document}

\begin{minted}{java}
Π ⦃a : D₀⦄
XXXXXXXXXX
\end{minted}

\end{document}

enter image description here

  • That's exactly what I was looking for. I'll look for a non-serif replacement font though. – javra Mar 27 '15 at 17:41
  • @javra They are also in DejaVu Sans – egreg Mar 27 '15 at 18:14
2

It's easy to see what font your browser is using.

If I "inspect element" on your code above (as viewed in FF/Windows) it says Segoe UI Symbol

so

\documentclass{book}
\usepackage{minted}
\usepackage{fontspec}
\setmonofont{Segoe UI Symbol}

\begin{document}

\texttt{Π ⦃a : D₀⦄}

\begin{minted}{java}
Π ⦃a : D₀⦄
\end{minted}

\end{document}

produces

enter image description here

Showing the font works fine, the red boxes are because minted (or rather pygmentize) not unreasonably thinks the syntax is a Java error, but that's a style choice in the language settings not an error in the typesetting.

  • for what it's worth, on my Mac OS seems Firefox renders the funny braces with Apple Symbols. – user4686 Mar 27 '15 at 17:07
  • as noted by the red boxes, this isn't actually monospace though... – David Carlisle Mar 27 '15 at 17:11
  • indeed, same here on Mac OS with Apple Symbols. – user4686 Mar 27 '15 at 17:42

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.