11

Since a few days I've been using the fontspec option \setmainfont[Renderer=Basic] ... in order to use the microtype option tracking=true with LuaLaTeX.

I have a simple question on this: why does using Renderer=Basic make computing my pdf sooooo much slower. It takes virtually hours now to complete on single run with lualatexmk -- and several (10+) minutes of high-fan-activity computing with the normal lualatex engine.

So, again: what does Renderer=Basic mean? And what is the difference to the default?

5
  • 1
    Fwiw with the latest luaotfload you can just enable letterspacing from fontspec: {\fontspec[LetterSpace=.125]{Iwona}foo} without having to request base mode. The implementation is experimental, though. Jun 15, 2013 at 9:33
  • 1
    Does your LetterSpace=.125 just always and everywhere add .125-space between letters? I wanted to use tracking=true, because it just increases the look without any further options, especially it optimises spacing of small caps. In other words is LetterSpace=.125 equivalent to tracking=true? Jun 16, 2013 at 19:05
  • 1
    the letterspacing callback increases kerning between glyphs by a fixed amount whereas pdftex implementation (\letterspacefont) that microtype was written for increases the sidebearings of letters. Also, microtype’s tracking option includes extra functionality like handling of boundaries (outer spacing, outer kerning, etc.) that are outside the scope of font-based letterspacing. Jun 16, 2013 at 23:11
  • @phg Can you add an answer?
    – egreg
    Oct 5, 2013 at 22:10
  • @egreg Once it’s official, sure. Right now I’m still waiting for Robert’s input so the implementation can be finalized. I appreciate that you guys are keen on leaving nothing unanswered. On the other hand, an answer that might be invalidated by the next release isn’t worth much. At the moment letterspacing in Luaotfload is still in flux (in fact, there are two mutually incompatible implementations of it!). Oct 6, 2013 at 10:43

1 Answer 1

10

Version 2.4 of Luaotfload (CTAN link) officially supports letterspacing similar to Xetex. You can enable it at font definition time (see the manual for details):

\font \mainfont = "file:Iwona-Regular.otf:letterspace=15" at 42pt

where the value is a percentage of the requested font size, i.e. 6.3 pt in above example. (Alternatively, you can specify the value directly as a factor using the option kernfactor. In order to achieve the same effect as in the example you would add kernfactor=0.15. The kern factor, though equivalent to letterspace in functionality, makes more sense internally and is to a large extent consistent with the behavior of Context’s \setcharacterkerning family of macros that the letterspacing code is derived from.) This width is inserted as additional kern between glyphs, with special handling for already existing kerns, ligatures, and other denizens of TeX’s node list.

In Fontspec terms, the feature should be directly accessible via the LetterSpace key of \fontspec, \set.*font etc.

Beware, since this feature is quite new and only tested so much, there may still be some issues with it. Currently (January 2014) there are two bug reports on the tracker that have patches in version 2.4 but require further testing.

Also, the output is not guaranteed to be identical with Xetex or the \letterspacefont primitive (or Pdftex, for that matter). For comparison, a short test file:

\def \testfont {Iwona-Regular.otf}
%\def \testfont {lmroman10-regular.otf}
%\def \testfont {MinionPro_Regular.otf}
\def \testsize {20pt}

\ifdefined \directlua
  \input luaotfload.sty
  \font \mainfont                  = "file:\testfont" at \testsize
  \font \mainfontlskern            = "file:\testfont:letterspace=15" at \testsize
  \letterspacefont \mainfontlsfont = \mainfont 150
\else
  \font \mainfont         = "[\testfont]" at \testsize
  \font \mainfontlskern   = "[\testfont]:letterspace=15" at \testsize
  \def \mainfontlsfont {<unsupported!>}
\fi

\newdimen \scratchwd
\newbox   \scratchbox

\def \test #1{%
  foo
  \begingroup
    #1%
    \setbox \scratchbox \hbox {bar baz}%
    \global \scratchwd = \wd \scratchbox%
    \box \scratchbox
  \endgroup\
  bar
  (\the \scratchwd)
  \endgraf
}

\mainfont

\test \mainfontlskern %% font kerning
\test \mainfontlsfont %% increased sidebearings

\bye

The values for \letterspacefont and the letterspace option may differ in subtle ways. According to the Pdftex manual,

This primitive creates an instance of \Something{font} with the widths
of all glyphs increased by \Something{integer} thousandths of an em (as
set in \Something{font}).  The effect is letter spacing, but the glyphs
are actually larger (sidebearings are increased), so a single glyph will
take more space.

Afaics the same holds for the Luatex implementation of \letterspacefont. Since the font size and the em (quad) dimension are identical for most fonts, the output should not differ by much. There is, however, another more visible difference: the \letterspacefont method also affects surrounding spaces whereas letterspace only works between glyphs. This behavior may change in future versions, or the microtype package may add support for adapting the spacing.


In summation, there are three approaches to letterspacing in modern TeX:

  • extending sidebearings of glyphs -- this is the strategy used in Pdftex as well as Luatex’s \letterspacefont. The value is specified in thousandths of an em.
  • adding spaces between glyphs -- according to the fontspec manual, this is the Xetex approach. The value is specified in hundredths (percent) of the font size.
  • inserting kerns between glyphs -- this is what Context and Luaotfload do. In Context and Luatofload with the kernfactor option, the value is a factor applied to the font size. Luaotfload’s letterspace option (which is again used by the fontspec package) emulates Xetex in that it interprets the value as hundredths (percent) of the font size.

Post scriptum regarding the original question: fontspec’s Renderer option, when used with Luaotfload, selects one of the two available processing modes.

  • base mode, which is the default in Context, should be “good enough” for most Latin-based scripts. Usually, though apparently not in OP’s case, it results in faster typesetting. The drawback is that base mode omits most Opentype features, so it is not an option for many scripts. The implementation is in font-otb.lua.
  • node mode, which is the default in Luaotfload, applies Opentype font features during typesetting, at the cost of a minor performance loss. The features ccmp, locl, rlig, liga, clig, kern, mark, and mkmk are active by default for the DFLT script (in Luaotfload, not Context). You can look up their definition in the Opentype spec. The implementation can be found in font-otn.lua.
1
  • Should we use microtype or rely on the options offered by LuaTeX through luaotfload?
    – skan
    Nov 25, 2016 at 11:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .