# An example of changing kerning of a font in LuaLaTeX

LuaLaTeX, through the luaotfload package, is able to dynamically add and modify features and properties of a font. This is performed by using the FeatureFile option in fontspec when loading a font; e.g.,

\setmainfont[FeatureFile=times-nr.fea]{Times New Roman}

where times-nr.fea is given as a listing in the fontspec manual (see §11). The syntax of these feature files is given by Adobe. Unfortunately, I haven't had the chance to look into this myself and I'm not sure what's possible nor how to do it.

I'd like to add some more examples to the fontspec manual, especially for adjusting the side-bearings around single glyphs and adjusting the kerning between adjacent glyphs and so on. The ability to define custom kerning for your fonts would truly make LuaLaTeX a world-class typesetting engine—no other TeX program is able to do this sort of thing so easily.

I'd like to perform an experiment: the source for fontspec is on GitHub. I'll offer a bounty on this question for the best patch to the fontspec manual adding more documentation for the FeatureFile option, specifically for sidebearing and/or kerning but hopefully for anything else that you also might happen to see that's fun.

So, can anyone help?

P.S. If you're stuck on the fact that to compile fontspec.pdf requires a whole bunch of pre-built PDFs for the examples, you can grab them from CTAN.

-
Of course, I can't start a bounty for a couple of days so hang tight until then :) – Will Robertson Sep 30 '10 at 8:02
I like the idea of bounties for improving documentation! – TH. Sep 30 '10 at 8:04
More documentation, and incentives for more documentation are a good thing (of course). However I don't think stackexchange is the right format for asking for this kind of thing. From the faq "this is a place for questions that can be answered", not for "the best patch to the fontspec manual". Therefore, I vote to close this non-question. – Lev Bishop Oct 1 '10 at 0:43
The biggest problem is that bounties have a time limit and writing documentation can take longer than that...also, you don't want to risk having two people working on something big at the same time without collaborating. How about offering the bounty for someone who commits to writing the documentation and explains why they can do it best! (then the question changes to "who is willing to do it?") – Yossi Farjoun Oct 4 '10 at 14:43
This is only an experiment, so it might not work. But in counterpoint, this really isn't a big feature that I'm asking for documentation on. I'm not saying "write 10 pages of docs"; all I want is an example! If anyone was actually interested they wouldn't need the entire nine days to carefully craft their prose, and the chances of two people overlapping—well, clearly that's not a problem right now and it's also a risk when answering every question on this site. – Will Robertson Oct 4 '10 at 22:07

I did not want to interfere with this experiment, but since nobody posted an answer so far, I just pushed an update to the feature file section of the documentation on github. It is not the most clear way to document it, but I tried my best (as far as my English permits :) )

-
BTW, the floats especially in that part are a bit ugly with the example 2 pages away from the actual section because of other floats, I hope someone knows how to really force LaTeX to keep the float in the current page ([h], [!h] and [H] with float package, all made no to very little difference). – Khaled Hosny Oct 8 '10 at 17:14

Adjusting the kerning of the glyph pair fh in TeX Gyre Bonum would require something like the this ...

bonum.fea

languagesystem DFLT dflt;
languagesystem latn dflt;
feature kern {
pos \f \h 125;
} kern;

test.tex

\documentclass{article}
\usepackage{fontspec}
\setmainfont[FeatureFile=bonum.fea]{TeX Gyre Bonum}
\begin{document}
fh
\end{document}

There is a problem with the babel package, though ...

test2.tex

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{fontspec}
\setmainfont[FeatureFile=bonum.fea]{TeX Gyre Bonum}
\begin{document}
fh aufhalten
\end{document}

As you can see, the adjusted kerning only applies to the first instance of the glyph pair. When the glyph pair occurs inside a word, the adjusted kerning is not applied. When babel is not loaded, everything is fine.

-
I get the same result with and without babel (a lot of space between the fh). Also I really can't see how babel should be able to interfer. Are you sure that you always deleted the temp-texgyrebonum-regular-bonum.lua file when you change your fea-file? – Ulrike Fischer Feb 8 '11 at 10:44
BTW, is there some kind of a public repository for OTF feature files? I plan on adjusting the kerning of TeX Gyre Bonum (at least for the purposes of my own book project), so if anyone was interested they could profit from my custom feature file (provided my adjustments will be typographically accurate, of course). – user3432 Feb 8 '11 at 10:58
The problem is not babel but the german hyphenation patterns. You get the same result (problem) if you load them simply with \makeatletter\bbl@patterns{ngerman}. And it disappear as soon as there is no longer a breakpoint between fh (e.g. try axfhlten). I suggest that you ask on the luatex list if this is a bug or unavoidable. – Ulrike Fischer Feb 8 '11 at 13:06
Thanks for the clarification! I will do that. – user3432 Feb 8 '11 at 13:36