Defining new font family with fontspec

With luatex/luaotfload you can (in texlive 2016 and up-to-date miktex) build a combo font. Imho there is no high-level interface yet, but beside this it works:

\documentclass[]{article}
\usepackage{fontspec}

\font \one = file:EBGaramond12-Italic.otf
\font \two = file:EBGaramond12-Regular.otf

\font \onetwo = "combo: 1 -> \fontid \one ;
                        2 -> \fontid \two , 0x41-0x5A;"


\begin{document}
\onetwo Some Text with Capital XYabcXY

\end{document}

enter image description here


Adapting the code by Andrey Vihrov to your needs and to the changed number of character classes, I can offer

\documentclass{article}

\usepackage{fontspec}

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass \uppercaseclass

\makeatletter
% Assign the new class to all Latin capital letters
\@tempcnta=`\A
\loop\unless\ifnum\@tempcnta>`\Z
  \XeTeXcharclass \@tempcnta \uppercaseclass
  \advance \@tempcnta by 1
\repeat
\makeatother

% Setup font change
\XeTeXinterchartoks 0 \uppercaseclass    = {\begingroup\upshape}
\XeTeXinterchartoks \uppercaseclass 0    = {\endgroup}
\XeTeXinterchartoks 4095 \uppercaseclass = {\begingroup\upshape}
\XeTeXinterchartoks \uppercaseclass 4095 = {\endgroup}

\begin{document}

\itshape
Once Upon a Time, there was a Beautiful Princess\ldots

\end{document}

enter image description here

Tags:

Xetex

Fontspec