2

I am using Bera Sans Mono as the monospaced font for typesetting code listings using the listings package. This is done for slides which are produced using beamer and XeLaTeX. My preamble includes the following (which used to work before a recent update to the MikTeX engine, the fontspec package, and the above-mentioned packages):

\usepackage{fontspec}
\setmonofont{Bera Sans Mono}[Scale=0.9] % for code listings beramono is used
\newfontfamily\quotefont{Linux Libertine O}[Ligatures=TeX] % selects Libertine for quotation marks

The output produced is: Garbled code listing

If I do not use \setmonofont and have the following preamble instead, the correct output is produced:

\usepackage{fontspec}
\usepackage[scaled]{beramono}
\usepackage[T1]{fontenc}
\newfontfamily\quotefont{Linux Libertine O}[Ligatures=TeX] % selects Libertine for quotation marks

Correct code listing

Why am I unable to use \setmonofont{Bera Sans Mono}[Scale=0.9] (which used to work before)?

Some additional points to note:

  1. XeLaTeX is able to find the font
  2. \setmonofont appears to work correctly with other fonts, just not Bera Sans Mono.
4
  • A minimal (non) working example?
    – egreg
    Commented Sep 2, 2015 at 12:35
  • Probably xetex and/or xdvipdfmx is finding a wrong font. This can happen if there are two versions of a font on a system. Add \XeTeXtracingfonts= 1 to your document, and then compile on the command line with xelatex --nopdf file and xdvipdfmx -vv file.xdv then the log and the terminal output will show the pathes of the fonts used. Commented Sep 2, 2015 at 13:30
  • I should have checked first. There is no opentype font "bera sans mono", it is a type1 font. You shouldn't load it with \setmonofont.Try \setmonofont{Bitstream Vera Sans Mono}[Scale=0.9]` instead. Commented Sep 2, 2015 at 13:54
  • @UlrikeFischer Thank you! Your suggestion to use the Bitstream font worked and helped to clear up some misunderstandings on my part. Do you want to post this as a formal answer?
    – Steve
    Commented Sep 3, 2015 at 7:59

1 Answer 1

4

There is no opentype font Bera Sans Mono, xelatex finds the normal type1 version and as it is not unicode encoded you get garbage.

To quote the CTAN info (http://www.ctan.org/pkg/bera)

The Bera fam­ily is a repack­ag­ing, for use with TEX, of the Bit­stream Vera fam­ily.

So with xelatex you should use

\setmonofont{Bitstream Vera Sans Mono}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .