XeTeX

From ConTeXt wiki
Jump to: navigation, search

< Alternative TeX Processors | Fonts in XeTeX | Encodings and Regimes in XeTeX >

XeTeX is a new TeX engine by Jonathan Kew and SIL International, which combines eTeX with pervasive Unicode support and advanced font support (multiple language, special AAT and OpenType font features, trivial font installation). It does this by leveraging Apple Advanced Typography support on MacOSX, so it gains its strength in features by sacrificing TeX's usual cross-platformness, and some backwards compatibility.

Contents

XeTeX and ConTeXt

XeTeX is a potential replacement for pdfeTeX in the ConTeXt workflow. It does not support all of the fancy PDF features found with pdfeTeX, but it supports most core features (see Features and Issues on this page). Common consensus is that for text with non-heavy mathematics needs, XeTeX should be an interesting alternative.

Note that XeTeX uses mkii and LuaTeX uses mkiv ; in principle mkii is frozen so new features and improvements will only happen in mkiv.


Where to get XeTeX?

Note: An easy way to test OpenType fonts with Context/Xetex from scratch under Windows (XP): 1. Get Texlive 2007 2. Install the Context collection with the Texlive Manager (Xetex is included) 3. Create a little test file:

\enableregime[utf]
% not necessary since it is default regime, but can remind you that you must provide UTF-8–coded text
\definetypeface[myface][ss][Xsans][Arial]
% or any else font in your /windows/fonts folder; run "fc-list >namelist.txt" to get them all
\setupbodyfont[myface, 12pt]

\starttext
Hello World!
Привет!
\stoptext

4. Run "texexec --xtx test.tex"

Basic Installation

After XeTeX being installed and ConTeXt being updated, you should make a format with texexec:

texexec --make --xtx en

This will generate cont-en.fmt, which will be used when running XeTeX and ConTeXt.

(If you receive permissions errors, then you may need to precede the above command with sudo:)

sudo texexec --make --xtx en

If you have later problems, make sure that the cont-en.fmt file was placed in the correct directory for formats, typically /usr/local/teTeX/share/texmf.local/web2c/xetex/.

For For XeTeX 0.9(and after), create a folder xetex in the folder /usr/local/teTeX/share/texmf.local/web2c/, and put the created format cont-en.fmt in it.

Don't forget to texhash!

Running XeTeX

XeTeX is invoked with the --xtx switch in texexec. This loads the XeTeX-specific specials, typescripts and other commands, and actually runs ConTeXt within XeTeX. Technically, XeTeX is an eTeX-like processor, and outputs an .xdv file. After texexec's final XeTeX run, texexec runs xdv2pdf in order to create a PDF file.

texexec --xtx myfile.tex

For the normal ConTeXt file,

texexec --pdf myfile.tex

MacOSX: using TeXShop

The fairly most common editor under MacOSX for TeX-related applications is TeXShop, which is bundled in the MacTeX installation and typically does not require any specific setting to be used with ConTeXt. Using ConTeXt with XeTeX (typically referred as XeConTeXt) in TeXShop needs a little hack, as TeXShop has to include \texexec --xtx among its available typesetting engines. You need to create an ASCII file named XeConTeXt.engine and put it under ~Library/TeXShop/Engines/. The file must contain

#!/bin/tcsh
set path= ($path  /usr/texbin)
texexec --xtx  "$1"

TeXShop, once open again, will show a new available engine (the one you need) in the engine menu of the document window (named XeConTeXt, after the engine filename). The code in the engine file specifies a path where the shell should find texexec: /usr/texbin is the standard on MacTeX, but of course you have to check the path on your system. Important note: it has been reported that the XeConTeXt.engine file must contain a blank line (as in the example), otherwise the program will stall (dont't ask...).

Document Encoding

XeTeX is able to handle UTF-8 or UTF-16 documents natively, without any interference or configuration from ConTeXt. Actually, in XeTeX utf-8 already is the default and the only supported regime. ConTeX+XeTeX currently simply ignores the \enableregime command, assuming you are using utf-8 (addendum: not entirely true now; see http://archive.contextgarden.net/message/20071123.134401.73a53235.en.html ss.). For what is concerning encoding, the best practice is to encode the tex file with utf-8 (addendum bis: this remains true!).

A planned feature is that ConTeXt allows you to use the regime of your choice (this is possible because of ConTeXt's use of named glyphs), so documents in latin-1 or even MacRoman encoding could be supported, given the proper \enableregime command. For characters out of reach of the given regime, you can use accents (like \'e) and/or named glyphs (\eacute).

Although XeTeX would prefer that you key in documents in full Unicode, with things like and in the place of --- and , respectively. This is not always so feasible, so it provides a mechanism for inserting these "TeXish" ligatures. In a font specification, you need to insert mapping=tex-text as one of the font features. This is already done for all existing typescripts in type-xtx, but you should be aware of this concern if designing your own documents.

Features

From there, things proceed fairly normally. Fonts in XeTeX get their own page, as they introduce some new features. Here are some new features that might be of interest:

Unicode symbol sets 
While not exclusive to XeTeX, exactly, you get easy access to named Unicode Symbols. XeTeX-specific commands switch to Apple-supplied default fonts for these symbols.
Basic Bi-directional text 
ConTeXt support for this was ushered in with XeTeX, but is fundamentally an eTeX feature. There is tentative support for direction changing with \pardir TRT and TLT, emulating Omega/Aleph's commands. These should be seen as low-level commands, to be intgrated with language switching, for example. There is a bad feature interaction between this and specials (e.g., color) support.
Alternate script number conversions 
Hans introduced some clever machinery into the conversion macros, allowing one to efficiently define a conversion vector (\defineconversionvector) for script-specific numbers. Arabic and Persian are provided.
More Unicode 
In the process of preparing XeTeX support in ConTeXt, many more Unicode glyphs were named and introduced into ConTeXt, including some Greek, Cyrillic, and Vietnamese.
Typescripts 
There are a number of typescripts defined to get a XeTeX user started.

Issues

(as of 26 November 2004)

Grid typesetting 
many fonts on the Mac report larger vertical metrics than their font size. Because ConTeXt sets \lineskiplimit to zero, grid dimensions are limited by these intrinsic (and seemingly arbitrary) font characteristics. As a result, grid typesetting, with some fonts, won't work below approximately 1.25 times the font size. Hoefler Text seems to work on a 12/12 grid, however.
Object reuse 
Currently, the XeTeX specials are unable to use ConTeXt's object (or faked object) support. As a result, repeated external figures may be included into the PDF several times, resulting in an increase in file sizes. This has not been tested.
Bookmarks 
XeTeX uses dvipdfmx's specials for references, bookmarks, and the like. ConTeXt uses some of these specials "out of spec", and may result in some strangeness in certain documents.
PDF Literals 
Because XeTeX relies on Apple's APIs to create PDFs, it is unable to take advantage of certain specials and other types of features that use native (literal) PDF commands.
Hoefler Italic is too fancy 
Hoefler Italic has swashes enabled by default. This is actually a product of Apple's implementation of the font. If this is unsuitable for you, add the feature: Smart Swashes=!Line Final Swashes to the HoeflerItalic font synonym in type-xtx.

C O N T E X T G A R D E N

Personal tools
Namespaces
Variants
Actions
Help
External Help
Installation
Navigation
Toolbox