2

How do I use light, normal, semibold, and bold font types in one document using sourcesanspro font? If I specify the default options, I can get normal and bold, but not light or semibold. If I use the light option, I can get light and semibold, but not normal or bold.

A MWE is below.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{fontspec}
\usepackage[default% with default, I can get normal and bold, but not light and semibold
%, light% If I add this line, I can get light and semibold, but not normal and bold
]{sourcesanspro}

\begin{document}

How do I get all these types of text in one document on demand?

\begin{itemize}
    \item light %how?
    \item \textmd{normal}
    \item semibold %how?
    \item \textbf{bold}
\end{itemize}

\end{document}

2

The sourcesanspro package (see documentation) also provides commands to select a certain set of fonts for convenience:

  • \sourcesanspro for the regular and bold weigths
  • \sourcesansprolight for light and semibold
  • \sourcesansproextreme for extra light and black

The following also produces what you want:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{fontspec}
\usepackage[default]{sourcesanspro}

\begin{document}

How do I get all these types of text in one document on demand?

\begin{itemize}
    \item \textmd{\sourcesansproextreme extra light}
    \item \textmd{\sourcesansprolight   light}
    \item \textmd{\sourcesanspro        normal}
    \item \textbf{\sourcesansprolight   semibold}
    \item \textbf{\sourcesanspro        bold}
    \item \textbf{\sourcesansproextreme black}
\end{itemize}

\end{document}

The \sourcesanspro isn't really necessary, of course.

code rendering

| improve this answer | |
1

Thanks to Therese, I found my answer here. As a novice, I didn't realize that \usepackage{sourcesanspro} downloads the fonts to they are callable as shown in the working code below. I also had to remove the options I had defined when calling \usepackage. The working code is below:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{fontspec}
\usepackage[%default% including default overrides the \setmainfont below.
%, light% 
]{sourcesanspro}

% Found answer in https://tex.stackexchange.com/questions/264265/defining-subfamilies-for-a-font/264275#264275

\setmainfont{SourceSansPro}[ %list of fonts included in sourcesanspro package are listed here: http://mirrors.ctan.org/fonts/sourcesanspro/doc/sourcesanspro.tex
  Extension=.otf,
  UprightFont=*-Regular,
  ItalicFont=*-RegularIt,
  BoldFont=*-Bold,
  BoldItalicFont=*-BoldIt,
  FontFace={xl}{n}{*-ExtraLight},
  FontFace={xl}{it}{*-ExtraLightIt},
  FontFace={l}{n}{*-Light},
  FontFace={l}{it}{*-LightIt},
  FontFace={mb}{n}{*-Semibold},
  FontFace={mb}{it}{*-SemiboldIt},
  FontFace={k}{n}{*-Black},
  FontFace={k}{it}{*-BlackIt},
]

\newcommand{\test}[2]{%
  #1: {\fontseries{#2}\selectfont This is upright. \itshape This is italic}\par
}

\begin{document}

I can now get all these types of text in one document on demand.
\vspace{\baselineskip}


\test{ExtraLight}{xl}
\test{Light}{l}
\test{Regular}{m}
\test{Medium}{mb}
\test{Bold}{bx}
\test{Black}{k}

\end{document}

The result:

XeLaTeX compile

| improve this answer | |
  • I have submitted an issue to implement FontFace in the sourcesanspro package. Though the names will probably match the Type1 fonts. – Silke Apr 15 at 13:30
  • Thanks! Your answer was more concise than mine, so I've marked it as the answer. – jkmey Apr 16 at 14:48

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.