5

Here is a minimal working example:

\documentclass{article}
\usepackage{polyglossia,fontspec}
\setdefaultlanguage{english}
\setotherlanguage{latin}
\setmainfont{Source Sans Pro}
\newfontfamily\Smbd{Source Sans Pro Semibold}

\begin{document}

1. normal weight  \textit{italic} \textlatin{foreign} blah

2. \textbf{bold   \textit{italic} \textlatin{foreign} blah}

3. {\Smbd{semibold \textit{italic} \textlatin{foreign} blah}}

\end{document}

screenshot

On the line # 3, the word "foreign" is not typesetted with the semibold font. What should I change in the code to achieve this?

Note: I would like to use both the bold font and the semibold font in the document.

  • 3
    Polyglossia issues \rmfamily as part of \textlatin. Do you need both bold and semibold? – egreg Feb 28 '15 at 14:13
2

This question came up a few years later on a search, and it’s a good one, so it’s worth answering.

The polyglossia package allows you to define fonts for every language and script, such as \latinfont and \germanfont. If you don’t declare one for each language, polyglossia does not assume that whatever font you’ve currently selected can support every langiage, so it will restore the default font family.

Your options include:

Quick Fix

Set your font family inside your language block.

\begin{latin}
\sourcesanspro
Exempli gratia.
\end{latin}

You might find it convenient to define something like

\newcommand{\latinsf}[1]{\textlatin{\textsf{#1}}}

I use this below.

Add a Semibold Weight with fontspec

This is a more complicated solution, but it gets you NFSS-style \sbseries and \textsf{} commands that will work with multiple fonts. In this example, I’ll set up Latin Modern Roman as the main font, then a \sourcesanspro font family, and set it as the sans-serif font.

\documentclass[varwidth, preview]{standalone}
\usepackage{fontspec}
\usepackage{polyglossia}

\setmainfont[
  Scale = 1.0,
  Ligatures ={ Common, Discretionary, TeX},
  FontFace={sb}{n}{Font = {lmromandemi10-regular}, Extension = .otf },
  FontFace={sb}{it}{Font = {lmromandemi10-oblique}, Extension = .otf }
]{Latin Modern Roman}

\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}

\newfontfamily{\sourcesanspro}[
  Extension = .otf ,
  Ligatures = {Common, TeX},
  UprightFont = *-Regular ,
  BoldFont = *-Bold ,
  ItalicFont = *-RegularIt ,
  BoldItalicFont = *-BoldIt ,
  FontFace = {sb}{n}{*-Semibold},
  FontFace = {sb}{it}{*-SemiboldIt}
]{SourceSansPro}

\renewcommand{\sffamily}{\sourcesanspro}

% The commands to select semibold weight:
\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}

\setdefaultlanguage{english}
\setotherlanguage{latin}

\newcommand{\latinsf}[1]{\textlatin{\textsf{#1}}}

\begin{document}
\sffamily
1. normal weight  \textit{italic} \latinsf{foreign} blah

2. \textbf{bold   \textit{italic} \latinsf{foreign} blah}

3. \textsb{semibold \textit{italic} \latinsf{foreign} blah}

4. \textrm{\textsb{Roman Demibold \textit{oblique} \textlatin{foreign} blah}}

\end{document}

enter image description here

Use the sourcesanspro Package

Unfortunately, this seems to be broken as of August 2018. If it ever gets fixed, it will be your simplest option. The package includes a \sourcesansprolight font family whose regular weight is Source Sans Pro Light and whose bold weight is Source Sans Pro Semibold.

\documentclass[varwidth, preview]{standalone}
\usepackage[default, osf, opentype]{sourcesanspro}
\usepackage{polyglossia}

\setdefaultlanguage{english}
\setotherlanguage{latin}

\begin{document}

1. normal weight  \textit{italic} \textlatin{foreign} blah

2. \textbf{bold   \textit{italic} \textlatin{foreign} blah}

3. {\sourcesansprolight\textbf{semibold \textit{italic} \textlatin{\sourcesansprolight foreign} blah}}

\end{document}
1

I found a solution: instead of defining a new font family, I can change the main font:

\newcommand\Smbd[1]{\setmainfont{Source Sans Pro Semibold}#1\setmainfont{Source Sans Pro}}

This is a rather ugly trick, but it does the job.

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.