3

How can I increase the letterspacing (tracking) of monospace fonts in Xetex?

This doesn't seem to work:

\documentclass{minimal}
\setlength{\parindent}{0cm}
\usepackage{fontspec}

\begin{document}

\addfontfeature{LetterSpace=0}
HLHHLLH\\
\addfontfeature{LetterSpace=50.0}
HLHHLLH\\

\addfontfeature{LetterSpace=0}
\texttt{HLHHLLH}\\
\addfontfeature{LetterSpace=50.0}
\texttt{HLHHLLH}\\

\end{document}

Results in:

screenshot of rendering of non-tracking in fontspec monospace font

melissa_boiko
  • 227
  • 1
  • 7

1 Answers1

4

You should put the \addfontfeature inside the \texttt, and you must load the fonts with the fontspec commands:

\documentclass{article}
\setlength{\parindent}{0cm}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\setmonofont{Latin Modern Mono}
\begin{document}

\texttt{\addfontfeature{LetterSpace=50}HLHHLLH}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261