# Using Open Sans in XeLaTeX with fontspec error

I am trying to use Open Sans with pandoc but always get the Following error when I try to generate the PDF using XeLaTeX:

xdvipdfmx:fatal: This font using the "seac" command for accented characters...

Output file removed.


I have installed Open Sans directly from Google Fonts.

YAML Meta:

---
papersize: b5
geometry:
- top=0.8in
- right=1.4in
- bottom=0.8in
- left=1.4in
linestretch: 1.5
fontsize: 12pt
mainfont: Open Sans
---


\usepackage[dvipsnames]{xcolor}
\usepackage{hyperref}
\definecolor{red}{HTML}{B53441}
\hypersetup{
urlcolor=red
}


The command I use to generate the File via pandoc:

pandoc -o test.pdf -H headers.tex yaml.txt Book.md --toc --toc-depth=2 --css epub.css --epub-cover-image=Cover.jpg --pdf-engine ~/bin/xelatex


If I remove the mainfont line from the yaml meta and add the latex font headers instead I get a different error:

Error producing PDF.
! Dimension too large.


These are the headers which cause the error:

\usepackage[default,scale=0.95]{opensans}
\usepackage[T1]{fontenc}


I am not very familiar with LaTeX so this error might be caused because I am using a definition intented for pdflatex with xelatex

Don't use

\usepackage[default,scale=0.95]{opensans}
\usepackage[T1]{fontenc}


with xelatex. This commands are only for pdflatex. Do something like this instead:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Open Sans}
\begin{document}
blub
\end{document}

• I get the same error as when I define it with the mainfont yaml directive xdvipdfmx:fatal: This font using the "seac" command for accented characters... – Snowball Sep 21 '18 at 11:02
• You are above writing that you are using \usepackage[T1]{fontenc} and the opensans package. Don't do this! – Ulrike Fischer Sep 21 '18 at 11:04
• As I wrote, I have tried three different ways. First the pdflatex way \usepackage[T1]{fontenc}. Than I removed that and used your approach which causes the above error. And last but not least I completely removed any latex code and just wrote mainfont: Open Sans within the yaml config which causes the same error as using your code. The reason for this is that pandoc internally transcribes mainfont: Open Sans into \usepackage{fontspec} \setmainfont{Open Sans} thus its causing the same error no matter which of the both methods I use – Snowball Sep 21 '18 at 11:32
• Ah. Well your description is rather confusing. The error means that xelatex is finding and using a type1 font. Try \setmainfont{OpenSans-Regular.ttf} to force the use of the ttf (assuming that you have the font as ttf). – Ulrike Fischer Sep 21 '18 at 11:38