[XeTeX] Switching to another font but keeping the context

Ulrike Fischer news3 at nililand.de
Sat May 23 16:53:38 CEST 2009


Am Sat, 23 May 2009 16:51:12 +0200 schrieb nico:

> Hi,
> 
> I'd like to be able to change on the fly the fonts to use *and* that the  
> current family/style/schape used still apply. Calling \setmainfont,  
> \setsansfont, etc. would be OK except that it comes back to normal font  
> (sffamily, bold or italic vanishes).
> 
> An example of the current behaviour:
> 
> \setmainfont{DejaVu Serif}
> \setsansfont{DejaVu Sans}
> \setmonofont{DejaVu Sans Mono}
> 
> {\it{\sffamily
> 
> A sans-serif italic text
> 
> \setmainfont{URW Palladio L}
> \setsansfont{FreeSans}

DejaVu Serif and DejaVu Sans are "families". Switching to palladio
means switching to another family. You can set up a fourth family
(beside the default main, sans and mono families) with
\newfontfamily. 

\documentclass{article}
\usepackage{fontspec}
\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}

\newfontfamily\specialfamily{Arial}

\begin{document}
\itshape abc \specialfamily abc \rmfamily abc 

\end{document}




-- 
Ulrike Fischer 



More information about the XeTeX mailing list