12

Bringhurst urges us in Chapter 10 of The Elements of Typographic Style: Version 4.0 to fix the font files if needed. See below a summary of the chapter using the section titles.

Bringhurst suggests to modify the font file so the fixes are done forever. But I think that for some fixes we can use feature files in LuaTeX. This can make easier to transfer projects from computers with fonts installed system-wide.

I ask for help to identify what can be corrected using feature files and show an example file. (Would it be better to make this question a comunity wiki?)

List of possible issues to be fixed

  1. Letterform

    Sometimes the glyphs are completely wrong. Usually due to missing glyphs taken from other fonts. In this case the only possibility is to use a font editor. Not possible with feature files.

  2. Hinting

    Hinting is not an easy process and sometimes is wrong or missing Altogether. In this case the only possibility is to use a font editor. Not possible with feature files.

  3. Vertical position

    Some characters' vertical position (specially +, -, dashes, ...) could be improved. Is it posible to fix it with feature files?

  4. Sidebering

    This is the blank space at the right and left of the outline of the glyph insie the box. Bringhurst says that he has to fix these values usually to fix the space between letters and puntuation symbols (He describes his style in this regards as a halfway between british and french typographic traditions). Can/Should it be done with feature files? (The microtype package can do the french typeseting style. Does it use kerning correction for that?)

  5. Character substitution

    Some characters could be in an inappropriate encoding position. I guess this can be fix with a GSUB rule.

  6. Kerning

    What to say about bad kerning, that the audience of this forum doesn't already know! This is an easy one; I can even answer myself :-)

Summary of Chapter 10

10 Grooming the font

10.1 Legal considerations

10.1 Check the license before tuning a digital font

10.2 Ethical & aesthetic considerations

!0.2.1 If ain't broken...

10.2.2 If the font is out of tune, fix it once and for all

10.2.3 Respect the font first of all, the letterform second, the type designer third, the foundry fourth

10.2.4 Keep on fixing

10.3 Honing the character set

10.3.1 If there are defective glyphs, meal them

10.3.2 If text figures, ligatures or other glyphs you need on a regular basis don't reside on the base font, install them there

10.3.3 if glyphs you need are missing altogether, make them

10.3.4 Check and correct the sidebering

10.3.5 Refine the kerning table

10.3.6 Check the kerning of the word space

10.4 Hinting

10.4.1 If the font looks poor at low resolutions, check the hinting

10.5 Naming convention

  • 1
    Oh, whoa, whoa there cowboy! If you try and put yourself on the level of "fixing" the font designs of people like Robert Slimbach or Howard Kettler or Hermann Zapf (or any number of font designers), then you've got another thing coming. Seems rather irresponsible of Bringhurst to go and suggest such a thing. – morbusg Nov 6 '13 at 20:21
  • @morbusg Is not my will to compare my self with people like Simbach, Kettler, Zapf or any other type designer. The problem is that sometimes their designs are not properly translate to digital fonts. And, therefore, some text have some default values that are not up to the designs beauty. This can be seen specially in kerning values. – TeXtnik Nov 7 '13 at 7:43
  • 1
    @morbusg "[...] we always adjust spacing around slashes [...]"; quote of Boguslaw Jackowsky (in a private email) refering to the Palatino-like font families. – TeXtnik Nov 7 '13 at 7:46
  • 1
    @Ingo I can not belive that you are an "unknowing" :-) I just check your nice webpage – TeXtnik Nov 7 '13 at 9:49
  • 2
    @morbusg: As utilities (compared to works of art), the users of typefaces are the ultimate test. If they think the typeface is broken, then it is broken (for them) no matter who designed it, and it should be their right to fix it as they see fit. – Khaled Hosny Nov 7 '13 at 10:42
19

A little guide to feature files

With feature files you can define two types of operation in lookups: substitute (sub) glyphs by others and position (pos) glyphs. What is impossible, is to modify the letterforms or add missing glyphs. Also, wrong encoding can’t be corrected by feature files. The only thing one can do in this case is to a glyph by another from the font so at least the visual appearance is as expected.

Simple lookups

The simplest positioning is kerning:

lookup mykern {
  pos A V -70; # 'pos' is short for the keyword 'position'
  pos T e -100;
} mykern;

Substitution is possible as 1:1, n:1 (ligature), 1:n

lookup mysmallcaps {
  sub u by v.sc;  # have a v shaped smallcap glyph instead of a u-shaped one; with copy/paste this gets copied as "v"!
} mysmallcaps;

lookup myligatures {
  sub a e by ae; # 'sub' is short for the keyword 'substitute'
} myligatures;

lookup unligate {
  sub f_f_l by f f l;
} unligate;

Contextual lookups

More complex lookups can define in which context an operation takes place:

lookup myordinals {
  sub one s' by s.sups;
  sub s.sups t' by t.sups;
} myordinals;

lookup kernwithdiacritics {
  pos T' 50 e acutecomb;  # this is accumulative to a previous kern of T e
} kernwithdiacritics;

With the keyword ignore one can exclude contexts from the substitution. The following will substitute e with a final form if it’s not followed by one of the letters A-Z or a-z:

lookup finals {
  ignore sub e' [A-Z a-z]; # the content inside the brackets is a "glyph class"
  sub e' by e.fina;
} finals;

Advanced positioning

The two kinds of position parameters in the kern lookups are short formats. The full format is <xplacement yplacement xadvance yadvance>. So, for example adjust the vertical position of a superscript glyph with:

lookup mysuperscript {
 pos e.sups <0 50 0 0>;  # e.sups is positioned 50 design-units higher
} mysuperscript;

To illustrate let’s adjust the greek letter Η with polytonic accents. In the first example it’s Eta with grave (Ὴ, needs space to the left), in the second we add a iota adscriptum (ῌ needs space to the right. xplacement shifts the image of the glyph by the given value without changing its box, xadvance changes the size of the glyph’s box:

lookup greekaccents1 {
 pos Eta' <79 0 79 0> gravecomb.grk;
} greekaccents1;

lookup greekaccents2 {
 pos Eta' <0 0 200 0> ypogegrammeni.cap;
 pos Eta' <79 0 279 0> ypogegrammeni.cap gravecomb.grk;
} greekaccents1;

Important:

  • Lookups are accessible via features, where one feature can activate one or more lookups and different features can activate the same lookup:
    feature gacc {          # featurenames are four-letter tags
      lookup greekaccents1;
      lookup greekaccents2;
    } gacc;
  • Lookups are applied to a language-system which needs to be defined, but make sure that that system exists in the font. The language-systems can be defined at the beginning of the feature-file, they will be applied to lookups in all subsequent features. If one needs to apply a lookup only in specific language-systems on has to do so explicitly inside the feature:
    languagesystem DFLT dflt;
    languagesystem grek dflt;
    languagesystem latn dflt;
    languagesystem latn TRK ;

    feature mkrn {
      lookup mykern; # This will be applied to all above language-systems
    } mkrn;

    feature itrk {
      script latn;
        language TRK  exclude_dflt;
          lookup turkish_i {
            sub i.sc by i.sc dotaccent; # this will only be applied to Turkish in latin script
          } turkish_i;
    } itrk;
  • As you can see above, lookups can be defined separately or nested inside features.
  • For bigger tasks, you can define glyphclasses (eg. before the lookups):
    @letters = [a-z aacute eacute adieresis odieresis];
    @LETTERS = [A-Z Aacute Eacute Adieresis Odieresis];
  • Make sure that you use the glyphnames as they appear in the font. This can be tricky and you might need to open the font in a font-editor or dump it with some tool (does somebody know a more direct way?) For example, the glyphname Delta can refer either to the greek letter or to the symbol in different versions of the same Adobe spec. Also, font-designers can name the glyphs different from Adobes proposals.
  • When I say "fix encoding errors" I mean just to substitue a glyph for one in other position in the file. This can be useful if the designer put a glyph in an incorrect unicode position. Bringhurst argue that if you use old-style numbers in running text (And you should), you should change the position of old-numbers to the position of the lining numbers. But this is not necessary with the onum feature. – TeXtnik Nov 7 '13 at 11:47
  • 1
    Of course, it can be useful, but it can pose problems if the resulting document is to be electronically processed further. Thérèse uses LT Didot as an example where oldstyle numbers exist but without an appropriate lookup. They’re encoded in the Personal Use Area at U+F730-U+F739. With Thérèse’s lookup we will nicely see the numeral 2 printed as oldstyle in the PDF, but imagine a visually impaired. His screenreader will stumble upon the glyph U+F732 and probably not output anything meaningful. Also, if you try to copy/paste, the output might not satisfy you. – georgd Nov 7 '13 at 12:23
  • Reading your nice answer it seems that cases 3-6 of the question are solved. I don't expect to fix 1 and 2 with feature files :-) but do you think there is something more than can be refine in a font using feature files? (just to get all the possibilities in one post) – TeXtnik Nov 7 '13 at 15:29
  • Well, not much. Optical size could be put here, but I think, fontspec has a far better interface for that; the same goes for the OS/2 table with which you can override the font’s vertical metrics (ascender, descender, linegap) but here too I think, TeX has better tools for it. The only aspect that might be interesting are anchors for mark and mark-to-mark-positioning and for cursive attachment. Still thinking of good examples… – georgd Nov 7 '13 at 16:16
  • Mark and mark-to-mark positioning seem to be broken. Also, contextuals seem not to work properly in my new tests. Have to investigate further and file bugs… – georgd Nov 8 '13 at 8:12
6

Here are three examples from my experience:

Sometimes a font has oldstyle figures in both its roman and its italic, but the onum feature is defined only for the roman. Didot LT Pro is one such font, and its oldstyle italic figures can be made easily accessible this way:

\documentclass{article}
\usepackage{filecontents,fontspec}

\begin{filecontents*}{didot.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

# fix for italic
feature inum {
  sub zero by zero.onum;
  sub one by one.onum;
  sub two by two.onum;
  sub three by three.onum;
  sub four by four.onum;
  sub five by five.onum;
  sub six by six.onum;
  sub seven by seven.onum;
  sub eight by eight.onum;
  sub nine by nine.onum;
} inum;
\end{filecontents*}

\setmainfont[FeatureFile={didot.fea},
  UprightFeatures={Numbers=OldStyle},
  ItalicFeatures={RawFeature={+inum}}]
  {Didot LT Pro}
\begin{document}
1234567890 \textit{1234567890}
\end{document}

Sometimes a font has ligatures, but the liga feature is not defined. Freundschafts Antiqua is a case in point. You can use the ligatures this way:

\documentclass{article}
\usepackage{filecontents,fontspec}

\begin{filecontents*}{frnd.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

feature liga {
  sub \f \i by \fi;
  sub \f \l by \fl;
} liga;
\end{filecontents*}

\setmainfont[FeatureFile={frnd.fea},
  ItalicFont={FreundschaftsKursivA}]
  {FreundschaftsAnt}
\begin{document}
fine flowers
\end{document}

Notice that you don’t have to say RawFeature={+liga}, because fontspec enables that feature by default.

Hermecito is a font with neither liga nor sups defined, though it has ligatures and superior figures. Its small caps are adversely affected by the kind of fix used for Freundschafts Antiqua, but a more verbose approach works:

\documentclass{article}
\usepackage{filecontents,fontspec,realscripts}

\begin{filecontents*}{herm.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

feature liga {
  sub \f \f by \ff;
  sub \f \i by \fi;
  sub \f \l by \fl;
  sub \f \f \i by \ffi;
  sub \f \f \l by \ffl;
} liga;

feature sups {
  sub \zero by \zerosuperior;
  sub \one by \onesuperior;
  sub \two by \twosuperior;
  sub \three by \threesuperior;
  sub \four by \foursuperior;
  sub \five by \fivesuperior;
  sub \six by \sixsuperior;
  sub \seven by \sevensuperior;
  sub \eight by \eightsuperior;
  sub \nine by \ninesuperior;
} sups;
\end{filecontents*}

\setmainfont[FeatureFile={herm.fea},
  SmallCapsFont={HermecitoSpecial SC},
  RawFeature={+liga},
  SmallCapsFeatures={RawFeature={-liga}}]
  {HermecitoSpecial}
\begin{document}
finest,\footnote{One} fluffiest\footnote{Two} felines\footnote{Three}
\end{document}
  • Can you confirm that this doesn't work any more with LuaTeX 0.95.0 as installed by TL 2016? I was pulling my hair out to find out what I was doing wrong when the same example files work well with LuaTeX beta-0.80.0 as of TL 2015. Or did they perhaps change the syntax? – Florian Jan 18 '17 at 19:40
  • @Florian Right. You can find the gory details about the new approach at tex.stackexchange.com/q/312154 – Thérèse Jan 18 '17 at 19:43
  • Thanks so much, somehow I overlooked this question. This works pretty well, though I liked the concept of being able to reuse actual .fea-files much better. – Florian Jan 18 '17 at 23:17
5

The kerning between two letter can be modified using this feature file:

mykern.fea

languagesystem DFLT dflt;
languagesystem latn dflt;
feature kern {
pos \V  \A -800;
} kern;

The unit is em/1000.

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.