Experiences Typesetting Opentype Math with Lualatex and Xelatex
Total Page:16
File Type:pdf, Size:1020Kb
Ulrik Vieth CONTEXT MEETING 2010 1 Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX Abstract When LuaTEX first provided support for OpenType math typesetting in version 0.40, high-level macro support for math typesetting was first developed for ConTEXt MkIV, while support for LuaLaTEX was initially limited to a very low-level or non-existent. In the meantime, this gap has been closed by recent developments on macro packages such as luaotfload, fontspec, and unicode-math, so LaTEX users are now provided with a unified high-level font selection interface for text and math fonts that can be used equally well with both LuaLaTEX and XeLaTEX. While a unified high-level interface greatly improves document interchange and eases transitions between systems, it does not guarantee that identical input will always produce identical output on different engines, as there are significant differences in the underlying implementations of math typesetting algorithms. While LuaTEX provides a full-featured implementation of OpenType math, XeTEX has taken a more limited approach based on a subset of OpenType parameters to provide the functionality of traditional TEX engines. Given the possibility of running exactly the same test files on both engines, it now becomes feasible to study those differences in detail and to compare the results. Hopefully, this will allow to draw conclusions how the quality of math typesetting is affected and could be improved by taking advantage of a more sophisticated, full-featured OpenType math implementation. LuaTEX math % !TeX program = lualatex \documentclass[fleqn]{article} 1 휕ƨ푬 1 휕풋 Δ푬 − = 훁휆 + 휇 , \usepackage{fontspec,unicode-math} ƨ ƨ Ʀ \setromanfont{Cambria} 푐 휕푡 휀Ʀ 휕푡 \setmathfont{Cambria Math} 1 휕ƨ푩 \begin{document} \input{luatex-fixes} Δ푩 − ƨ ƨ = −휇Ʀ rot 풋 . 푐 휕푡 \input{math-test} \end{document} XeTEX math % !TeX program = xelatex \documentclass[fleqn]{article} 1 1 휕 푬 1 휕풋 \usepackage{fontspec,unicode-math} Δ푬 − = 훁휆 + 휇 , 푐 휕푡 휀 휕푡 \setromanfont{Cambria} \setmathfont{Cambria Math} \begin{document} 1 휕푩 Δ푩 − = −휇 rot 풋 . \input{xetex-fixes} 푐 휕푡 \input{math-test} \end{document} Can you spot the difference? % !TeX program = pdflatex 1 \documentclass{article} 1 휕ƨ푬 1 휕풋 \usepackage{pdfpages} Δ푬 − ƨ ƨ = 훁휆 + 휇Ʀ , \begin{document} 푐 휕푡 휀Ʀ 휕푡 \includepdfmerge [nup=2x1,noautoscale=true,delta=-21cm 0] ƨ 1 휕 푩 {xelatex-test.pdf,1,lualatex-test.pdf,1} Δ푩 − = −휇 rot 풋 . 푐ƨ 휕푡ƨ Ʀ \end{document} 1 2 CONTEXT MEETING 2010 Ulrik Vieth Introduction On the other hand, mainstream font formats such as OpenType did not provide any support for the seman- In this paper, we will review the state of recent devel- tics of math typesetting. opments of new T X engines and corresponding macro E Ironically, the lack of a suitable math font technology packages to support math typesetting with Unicode and was only resolved when Microsoft started to develop OpenType math fonts, based on our experiences from support for MS Office 2007. Given their influence as a testing the T X Live 2010 pretest distribution [1]. E vendor controlling the OpenType font specification [6], In the first part, we will summarize the available they simply went ahead and created an extension of the choices of T X engines and macro packages, as well as E OpenType font format containing a MATH table [7] and the available choices of math fonts, which can be used commissioned the design of Cambria Math as a refer- for testing OpenType math typesetting. ence implementation of an OpenType math font [8, 9]. In the second part, we will report our experiences In addition, they also developed a simplified math input testing the various T X engines, macro packages and E language known as ‘linear math’ [10]. fonts, and we will report our findings which kind of While there are sometimes strong reservations about problems were encountered and how these problems accepting a vendor-defined file format, especially an were resolved or circumvented. unreleased one coming from Microsoft, developers of In the third part, we will analyze and compare the re- font tools such as FontForge [11] as well as developers sults of running identical documents through different of T X engines were willing to accept OpenType math T X engines using different implementations of math E E as a de facto standard, because it filled a need and also typesetting algorithms, and we will try to draw conclu- because it turned out to be well-designed. sions how the quality of math typesetting is affected Upon closer analysis, many concepts of OpenType and could be improved. math could be seen as obvious extensions or general- izations of traditional concepts of math typesetting in Reviewing the state of OpenType TEX [12]. Moreover, most OpenType math font parame- math support in T X Live 2010 ters could be identified to have a direct correspondence E to TEX math font parameters [13], which had also been In recent years, many developments related to new TEX carefully analyzed in previous studies [14, 15]. engines and corresponding macro packages and fonts have focused on providing support for Unicode and OpenType math support in TEX engines OpenType, not just for text typesetting, but also for When XeTEX first added OpenType math support in math typesetting (which is still important as one ofthe version 0.997 as of 2007 [16], it kept TEX’s traditional traditional strong-holds of TEX). math typesetting algorithms essentially unchanged and only used a small subset of OpenType font parameters Unicode and OpenType math technology to initialize the required TEX font parameters. While the pre-history of Unicode text support dates When LuaTEX also added OpenType math support back to the mid-1990s, most activities related to Unicode in version 0.40 as of 2009 [17, 18, 19], it introduced math support only became possible during the last few a number of extensions and generalizations to TEX’s years, after a suitable font technology was developed as math typesetting algorithms, aiming to provide a full- an extensions to the OpenType font format. featured implementation of OpenType math. When the efforts to bring math into Unicode were As of TEX Live 2010, both new TEX engines support- started in the late 1990s by a consortium of scientific ing Unicode and OpenType math typesetting have been publishers, the original focus was on identifying math added to the mainstream distributions and have become symbols and getting them accepted into Unicode [2, 3]. widely available for using and testing the new features. Once this was done, the focus shifted to developing a However, their acceptance also depends on providing reference font implementation, the so-called STIX fonts, adequate macro package and font support. to provide the necessary glyph shapes [4]. While the STIX project was spending nearly a decade OpenType math support in macro packages waiting for fonts to be designed, the lack of a suitable When XeTEX was first added to TEX distributions, it was font technology for math typesetting was overlooked easily accessible to LaTEX users with XeLaTEX. A high- for a long time. While traditional TEX font formats sup- level font selection interface for text fonts was devel- ported math typesetting in their own way, they suffered oped with the fontspec package [20, 21], which became from limitations and questionable design decisions [5]. widely used as a standard package for XeLaTEX. Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 3 When XeTEX added math support, a corresponding Except for Cambria Math, all of these fonts all are high-level font selection interface for math fonts was freely available, either from CTAN (if already released) also developed with the unicode-math package [22], but or from GitHub (if still under development). unlike fontspec it wasn’t released until recently. As of TEX Live 2010, Asana Math and XITS Math are When LuaTEX added math support, high-level macro both included in the distribution, but Cambria Math support was initially developed for ConTEXt MkIV [23], and Neo Euler have to be obtained separately and need while macro support for LuaLaTEX (or Plain LuaTEX) to be installed manually in your texmf-local tree. was initially limited to the luaotfload package [24], Once installed, each of the fonts can be used in the which provided only a low-level interface. same way, but the range of symbols and math alphabets As of TEX Live 2010, LaTEX macro package support available may differ significantly between fonts. for Unicode and OpenType math typesetting has been much improved, as both the fontspec and unicode- math packages have undergone a complete rewrite, Experiences testing OpenType adding support for LuaLaTEX (based on luaotfload) to math support in TEX Live 2010 the code originally developed for XeLaTEX. Testing the functionality and quality of OpenType math As a result, LaTEX users are now provided with a typesetting implies testing a complex system, consist- unified high-level font selection interface for text and ing of typesetting engines, macro packages and fonts math fonts [25] that can be used equally well with both (with embedded intelligence), which have to interact XeLaTEX and LuaLaTEX. properly to produce the desired results. Given this interface, selecting a different math font Given the inherent complexity, there are a large (such as Cambria Math) can be as easy as this: number of problems which can occur, and most likely \usepackage{fontspec,unicode-math} will occur, so we have to consider the possibilities of \setmainfont[<options>]{Cambria} \setmathfont[<options>]{Cambria Math} engine problems, macro problems, font problems and font loading issues. Using the options of \setmathfont, a number of details of math typesetting can be easily configured, includ- Problems with T X engines ing the behavior of math alphabets (such as upright vs.