[XeTeX] Separate fonts for Latin and Greek with fontspec?

Michiel Kamermans pomax at nihongoresources.com
Fri Sep 17 10:51:28 CEST 2010


David,

> OK - major progress in that I have it all working for the single 
> character α! But do I /really/ have to go through all 50 odd 
> characters an assign them to my \greekclass individually? Or is there 
> some sort of automation mechanism?

There are ways to automate the process, but I pretty much already wrote 
those, so I might as well put up the package I have sitting here... it's 
currently on 
projects.nihongoresources.com/downloadables/ucharclasses.tgz 
<http://projects.nihongoresources.com/downloadables/ucharclasses.tgz>. 
The package supports setting fonts for Unicode "blocks" as well as 
informal groups, so you will probably want to simply bind your fonts of 
choice to informal "Latin" and "Cyrillic" groups:

\documentclass{article}
\usepackage{fontspec}
\newfontfamily{\latin}{Times New Roman}
\newfontfamily{\cyrillic}{FreeSerif}
\setmainfont{Times New Roman}
\usepackage{ucharclasses}
\setTransitionsForLatin{\latin}{}
\setTransitionsForCJK{\cyrillic}{}
\begin{document}
This is some Engish text, Αυτό είναι ένα κείμενο στην ελληνική γλώσσα 
and then back to English without any explicit font markup.
\end{document}

The package may throw a warning about the fact that the 
"newXeTeXintercharclass" is already defined - I wrote it when that 
function was just landing in XeTeX, so the 
\RequirePackage{newxetexintercharclass} line in the ucharclasses.sty 
file can at this point safely be removed, and newxetexintercharclass.sty 
deleted.

I'll try to clean up the code at least so that it's 
current-XeTeX-compatible and put it on CTAN, then see if I can ditch the 
forloop package in favour of TeX looping, to speed things up a little 
bit. Although likely not by much - until XeTeX supports binding token 
sets to a class, rather than individual tokens, and does so using 
ranges, it's simply going to bind the entire Unicode range. Package 
loading options should help, so that if specific blocks/groups are 
specified, only those are loaded and the rest of Unicode is left 
untouched, but that'll come later.

- Mike "Pomax" Kamermans
nihongoresources.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/xetex/attachments/20100917/ed9ab0c9/attachment.html>


More information about the XeTeX mailing list