5

I was having problems trying to combine a "traditional" font package (berasans) with fontspec (using TeX Gyre Pagella). Just using both correctly changed the text font to TeX Gyre Pagella, but text set with \sffamily used Latin Modern (Sans or Roman, depending on the order in which the packages were loaded) instead of Bera Sans.

Looking for a solution, I found this answer suggesting (albeit in a different context) that the font encoding had to be manually set. This left me with the following minimal example:

\documentclass{scrartcl}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage{berasans}
\let\sffamilyold\sffamily
\def\sffamily{\fontencoding{T1}\sffamilyold}

\begin{document}
TeX Gyre Pagella

\sffamily Bera Sans
\end{document}

which works, but I'm feeling slighly uneasy redefining \sffamily like that. Is there an easier/better solution for such a combination of Type 1 fonts and fontspec? Or even better, is there a good sans-serif OTF/TTF font to use with TeX Gyre Pagella?

6
  • 1
    According to tug.dk/FontCatalogue/berasans, “Bera Sans is a version of Bitstream Vera Sans slightly enhanced for use with TeX.” And the DejaVu family is based on Vera. DejaVu Sans should meet your needs.
    – Thérèse
    Sep 12, 2015 at 2:06
  • 1
    I don't see the method you are using suggested in the answer/comments to the question you linked to. And I am not sure that defining it with \def is a great idea. The original is defined as a robust command. You are certainly losing some of the protections built into that command because you've declared an encoding switch before those checks are completed.
    – cfr
    Sep 12, 2015 at 2:14
  • 2
    Don't change the encoding in \sffamily it will not go back when you change family back with \rmfamily also hyphenation of words within the changed encoding area is likely to be wrong. Sep 12, 2015 at 10:00
  • 2
    While you can use a type1 and T1-encoded font with xelatex I wouldn't recommend it. You will get problems with non-ascii-chars, and copy and paste could break. It is much better to look for a sensible open type version of the font you want to use. Sep 12, 2015 at 10:20
  • @DavidCarlisle Was right not to be at all sure about that....
    – cfr
    Sep 12, 2015 at 11:13

1 Answer 1

6

I suggest you use the opentype version, developed by Arkandis Digital Foundry under the name of Verana Sans, or even a font inspired by Bitstream Vera, Switzera. Here is a demo:

\documentclass{scrartcl}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage{berasans}
\let\sffamilyold\sffamily
\def\sffamily{\fontencoding{T1}\sffamilyold}
%\setsansfont{Verana Sans}
%\setsansfont{Switzera ADF}

\begin{document}
TeX Gyre Pagella

\sffamily Bera Sans

\fontspec{Verana Sans}Verana Sans. Baffling, isn’t it?

\fontspec{Switzera ADF}
Switzera ADF

\end{document} 

enter image description here

0

You must log in to answer this question.

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