The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE
The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE
ound to fonts (instead of being common to fonts that traditional TEX shares in memory). The character related tables can be lled with Lua and this is what MkIV now does. As a result much TEX code could go away. We still use shape related vectors to set up the values, but we also use information stored in our main character database. A likely area of change is math and not only as a result of the TEX gyre math project which will result in a bunch of Unicode compliant math fonts. Currently in MkIV the initialization already partly takes place using the character database, and so again we will end up with less TEX code. A side effect of removing encoding constraints (i.e. moving to Unicode) is that things get faster. Later this year math will be opened up. One of the biggest impacts of opening up is the arrival of attributes. In traditional TEX only glyph nodes have an attribute, namely the font id. Now all nodes can have attributes, many of them. We use them to implement a variety of features that already were present in MkII, but used marks instead: color (of course including color spaces and transparency), inter-character spacing, character case manipulation, language dependent pre and post character spacing (for instance after colons in French), special font rendering such as outlines, and much more. An experimental application is a more advanced glue/ penalty model with look-back and look-ahead as well as relative weights. This is inspired by the one good thing that xml formatting objects provide: a spacing and pagebreak model. It does not take much imagination to see that features demanding processing of node lists come with a price: many of the callbacks that LuaTEX provides are indeed used and as a result quite some time is spent in Lua. You can add to that the time needed for handling font features, which also boils down to processing node lists. The second half of 2007 Taco and I spent much time on benchmarking and by now the interface between TEX and Lua (passing information and manipulating nodes) has been optimized quite well. Of course there's always a price for exibility and LuaTEX will never be as fast as pdfTEX, but then, pdfTEX does not deal with OpenType and such. We can safely conclude that the impact of LuaTEX on ConTEXt is huge and that fundamental changes take place in all key components: les, fonts, languages, graphics, MetaPost xml, verbatim and color to start with, but more will follow. Of course there are also less prominent areas where we use Lua based approaches: handling url's, conversions, alternative math input to mention a few. Sometime in 2009 we expect to start working on more fundamental typesetting related issues. roadmap On the LuaTEX website www.luatex.org you can nd a roadmap. This roadmap is just an indication of what happened and will happen and it will be updated when we feel the need. Here is a summary. 176 The luacation of TEX and ConTEXt
• merging engines Merge some of the Aleph codebase into pdfTEX (which already has ε-TEX) so that LuaTEX in dvi mode behaves like Aleph, and in pdf mode like pdfTEX. There will be Lua callbacks for le searching. This stage is mostly nished. • OpenType fonts Provide pdf output for Aleph bidirectional functionality and add support for Open- Type fonts. Allow Lua scripts to control all aspects of font loading, font denition and manipulation. Most of this is nished. • tokenizing and node lists Use Lua callbacks for various internals, complete access to tokenizer and provide access to node lists at moments that make sense. This stage is completed. • paragraph building Provide control over various aspects of paragraph building (hyphenation, kerning, ligature building), dynamic loading loading of hyphenation patterns. Apart from some small details these objectives are met. • MetaPost (mplib) Incorporate a MetaPost library and investigate options for runtime font generation and manipulation. This activity is on schedule and integration will take place before summer 2008. • image handling Image identication and loading in Lua including scaling and object management. This is nicely on schedule, the rst version of the image library showed up in the 0.22 beta and some more features are planned. • special features Cleaning up of hz optimization and protruding and getting rid of remaining global font properties. This includes some cleanup of the backend. Most of this stage is nished. • page building Control over page building and access to internals that matter. Access to inserts. This is on the agenda for late 2008. The luacation of TEX and ConTEXt 177
- Page 128 and 129: for k, v in pairs(_G) do print(k, v
- Page 130 and 131: } [4] = 200 I mistakingly assumed t
- Page 132 and 133: 130 Optimization
- Page 134 and 135: xetex metapost We can also
- Page 136 and 137: \startluacode xml.sprint(xml.first(
- Page 138 and 139: a[position()=5] maybe a[first()] ma
- Page 140 and 141: Now we have: okay okay okay Repla
- Page 142 and 143: \startxmlsetups xml:mysetups \xmlse
- Page 144 and 145: c1d1 c2d2 d3 d4 d5 Here com
- Page 146 and 147: c2 d3 b/c[1] c1 c2 a/c[1] d3 a/c[-1
- Page 148 and 149: The code in traditional TEX that de
- Page 150 and 151: and this is where MkIV hooks in ist
- Page 152 and 153: con-text == [c][o](pre=n-,post=,rep
- Page 154 and 155: luastate_bytes min:37009927, max:87
- Page 156 and 157: dyn_used min:478158, max:554800, pa
- Page 158 and 159: str_ptr min:2131299, max:2136226, p
- Page 160 and 161: if_stack min:0, max:13, pages:326 k
- Page 162 and 163: pdf_refximage min:0, max:7, pages:3
- Page 164 and 165: 162 Collecting garbage
- Page 166 and 167: \definefontfeature[coward] [kern=ye
- Page 168 and 169: We do our tests of a variant of Con
- Page 170 and 171: --make or --ini --run or --fmt= --l
- Page 172 and 173: mtxrun --script font --list --patte
- Page 174 and 175: Opening up TEX started with rewriti
- Page 176 and 177: One can question if a properly work
- Page 180 and 181: • TEX primitives Access to and co
- Page 182 and 183: • Open an instance using mplib.ne
- Page 184 and 185: is dened in the les whose names sta
- Page 186 and 187: }, }, ["pen"]={ { ["left_x"]=2.4548
- Page 188 and 189: local tx, ty = p.x_coord, p.y_coord
- Page 190 and 191: \startreusableMPgraphic{test} fill
- Page 192 and 193: vardef textext(expr str) = image (
- Page 194 and 195: local factor = 65536*(7200/7227) fu
- Page 196 and 197: end return t This is a typical exam
- Page 198 and 199: The user interface is downward comp
- Page 200 and 201: key concept. There are few accessib
- Page 202 and 203: \directlua 0 { for i=1,10 do tex.pr
- Page 204 and 205: } end And still it's not okay, sinc
- Page 206 and 207: eason why such code normally is not
- Page 208 and 209: Of course we can discuss until eter
- Page 210 and 211: some text some more When using Co
- Page 212 and 213: and the document itself is processe
- Page 214 and 215: setups and functions are assigned n
- Page 216: using some kind of api and history
- Page 226 and 227: In LuaTEX with ConTEXt MkIV support
ound to fonts (instead <strong>of</strong> being common to fonts that traditional TEX shares in memory).<br />
<strong>The</strong> character related tables can be lled with Lua and this is what MkIV now does. As<br />
a result much TEX code could go away. We still use shape related vectors to set up the<br />
values, but we also use information stored in our main character database.<br />
A likely area <strong>of</strong> change is math and not only as a result <strong>of</strong> the TEX gyre math project which<br />
will result in a bunch <strong>of</strong> Unicode compliant math fonts. Currently in MkIV the initialization<br />
already partly takes place using the character database, and so again we will end up<br />
with less TEX code. A side effect <strong>of</strong> removing encoding constraints (i.e. moving to Unicode)<br />
is that things get faster. Later this year math will be opened up.<br />
One <strong>of</strong> the biggest impacts <strong>of</strong> opening up is the arrival <strong>of</strong> attributes. In traditional TEX only<br />
glyph nodes have an attribute, namely the font id. Now all nodes can have attributes,<br />
many <strong>of</strong> them. We use them to implement a variety <strong>of</strong> features that already were present<br />
in MkII, but used marks instead: color (<strong>of</strong> course including color spaces and transparency),<br />
inter-character spacing, character case manipulation, language dependent pre<br />
and post character spacing (for instance after colons in French), special font rendering<br />
such as outlines, and much more. An experimental application is a more advanced glue/<br />
penalty model with look-back and look-ahead as well as relative weights. This is inspired<br />
by the one good thing that xml formatting objects provide: a spacing and pagebreak<br />
model.<br />
It does not take much imagination to see that features demanding processing <strong>of</strong> node lists<br />
come with a price: many <strong>of</strong> the callbacks that LuaTEX provides are indeed used and as a<br />
result quite some time is spent in Lua. You can add to that the time needed for handling<br />
font features, which also boils down to processing node lists. <strong>The</strong> second half <strong>of</strong> 2007<br />
Taco and I spent much time on benchmarking and by now the interface between TEX and<br />
Lua (passing information and manipulating nodes) has been optimized quite well. Of<br />
course there's always a price for exibility and LuaTEX will never be as fast as pdfTEX, but<br />
then, pdfTEX does not deal with OpenType and such.<br />
We can safely conclude that the impact <strong>of</strong> LuaTEX on ConTEXt is huge and that fundamental<br />
changes take place in all key components: les, fonts, languages, graphics, MetaPost<br />
xml, verbatim and color to start with, but more will follow. Of course there are also less<br />
prominent areas where we use Lua based approaches: handling url's, conversions, alternative<br />
math input to mention a few. Sometime in 2009 we expect to start working on<br />
more fundamental typesetting related issues.<br />
roadmap<br />
On the LuaTEX website www.luatex.org you can nd a roadmap. This roadmap is just<br />
an indication <strong>of</strong> what happened and will happen and it will be updated when we feel the<br />
need. Here is a summary.<br />
176 <strong>The</strong> luacation <strong>of</strong> TEX and ConTEXt