29.05.2014 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VI<br />

A fresh look at fonts<br />

readers<br />

Now that we have the le system, Lua script integration, input encoding and basic logging<br />

in place, we have arrived at fonts. Although today OpenType fonts are the fashion, we still<br />

need to deal with TEX's native font machinery. Although Latin Modern and the TEX Gyre<br />

collection will bring us many free OpenType fonts, we can be sure that for a long time<br />

Type1 variants will be used as well, and when one has lots <strong>of</strong> bought fonts, replacing them<br />

with OpenType updates is not always an option. And so, reimplementing the readers for<br />

TEX Font Metrics (tfm les) and Virtual Fonts (vf les), was the rst step.<br />

Because Aleph font handling was integrated already, Taco decided to combine the tfm<br />

and <strong>of</strong>m readers into a new one. <strong>The</strong> combined loader is written in C and produces tables<br />

that are accessible from within Lua. A problem is that once a font is used, one cannot<br />

simply change its metrics. So, we have to make sure that we apply changes before a font<br />

is actually used:<br />

\font\test=texnansi-lmr at 31.415 pt<br />

\test Yet another nice Kate Bush song: Pi<br />

In this example, any change to the fontmetrics has to be done before test is invoked.<br />

For this purpose the define_font callback is provided. Below you see an experimental<br />

overload:<br />

callback.register("define_font", function (name,area,size)<br />

return fonts.patches.process(font.read_tfm(name,size))<br />

end )<br />

<strong>The</strong> fonts.patched.process function (currently in ConTEXt MkIV) implements a mechanism<br />

for tweaking the font parameters in between. In order to get an idea <strong>of</strong> further<br />

features we played a bit with ligature replacement, character spacing, kern tweaking etc.<br />

Think <strong>of</strong> such a function (or a chain <strong>of</strong> functions) doing things similar to:<br />

callback.register("define_font", function (name,area,size)<br />

local tfmblob = font.read_tfm(name,size) -- build in loader<br />

tfmblob.characters[string.byte("f")].ligatures = nil<br />

return tfmblob -- datastructure that TeX will use internally<br />

end )<br />

Of course the above denition is not complete, if only because we need to handle chained<br />

ligatures as well ( followed by i).<br />

A fresh look at fonts 31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!