13

Once in a while, you may want to (1) adjust or create a kerning pair (or, better yet, kerning class) in a font, or (2) adjust a particular glyph's sidebearings.

examples of scenario (1) would include a font that's lacking a certain kerning pair/class, such as when more ›exotic‹ variants of a glyph were overlooked by the designer: W + a is kerned, but W + á isn't. Or: adjusting punctuation spacing for a certain linguistic context, such as the famously loose puncutation spacing common in French. Scenario (2) would apply, for example, when a particular glyph is too close to (or two far away from) all its possible neighbors, whatever these may be. Such as the slash in an otherwise well-made font I recently licensed.

Obviously, you may edit the font file itself, but this may not be desirable for several reasons, and it may not be permitted by the font's EULA either. I'd like to arrive at a little survey that addresses questions like:
* what »non-invasive« methods are available for these purposes?
* what engines are they compatible with?
* what are pros and cons?

The two options that I can think of I've already posted as answers. Feel free to edit, as there might be more to be said about them.

10

OpenType feature files

We can create an OpenType feature file and use pos command for quite complex spacing and positioning modifications (including vertical ones). Kerning adjustments can be done traditionally (i.e. in pairs), or, more conveniently, using classes in which a number of variants of a glyph (a, ä, â...) get treated the same. The most basic example is probably something like this:

\documentclass{scrartcl}
\usepackage{fontspec}
\usepackage{filecontents}

\begin{filecontents*}{test.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;
feature test {
    pos T -200 a;
} test;
\end{filecontents*}

\setmainfont[FeatureFile=test.fea]{TeX Gyre Schola}

\begin{document}
Ta\par
\addfontfeatures{RawFeature=+test}
Ta
\end{document} 

Can be used for all the scenarios above; rather straightforward but pretty versatile syntax.

Cons: engines. LuaLaTeX only (IIRC). Maybe some other cons (to be expanded)

6

microtype's \SetExtraKerning

There is, of course, microtype and its \SetExtraKerning command. It might be argued that it's named a bit misleadingly, as its purpose is adjusting the left and right sidebearings of specific glyphs. This makes it an option in scenario (2), but it can't be used to fix (or add) a kerning pair or class. Contrary to what the manual suggests, it's also of limited use in the French punctutation case. If we followed the manual to create looser spacing between an exclamation mark and the word preceding it, we'd say:

\SetExtraKerning
   [unit = space]%
   {encoding = *}%
   {! = {500,}}

to increase the !'s left sidebearing by 500 units, leaving the right one untouched. (We can't change the right one, as what would effectively double the spacing in sequences like !, or or !!!)

This produces the desired ›French‹ effect, but, naturally, that effect isn't restricted to a context like [word] + !:

enter image description here

So what this method is good for is scenario (2) rather than (1).

Engines? Restricted to pdfTeX as of today.

5

Probably an edge case in terms of non-invasiveness is modifying the TeX font metrics with the help of the kerntest package, which provides some helpful methods to visually assess the appropriate kerning amounts. The package will create a metrics file (mtx) that can be fed to fontinst, thus allowing to change the metrics without touching the font itself. The downside is that this process is quite cumbersome and requires some knowledge of fontinst, since the modified metrics have to be installed as a new font (and anybody who got to know tex in the pre-xetex era will shudder at hearing the words "TeX", "fonts" and "install" within one sentence). Since this method works on Type1 fonts, it can be used with any engine, but of course not for OpenType fonts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.