5

I am using TeXlive 2016 on Ubuntu with LuaLaTex, all up to date. As of a week ago (or so), the following code worked for me. It defines a new, custom Open Type feature using Lua code, as described by others. In the Preamble:

\ExplSyntaxOn
\DeclareDocumentCommand \CreateFontFeature { m m }
 {
  \IfEndWith{#1}{,}{\StrGobbleRight{#1}{1}[\@fakezero]}{\def\@fakezero{#1}}
  \def\@fakeone{["\@fakezero"}
  \StrSubstitute{\@fakeone}{=}{"]="}[\@faketwo]
  \StrSubstitute{\@faketwo}{,}{",\space["}[\@fakethree]
  \directlua{
    fonts.handlers.otf.addfeature {
      name = "#2",
      {type = "substitution", data = {\@fakethree},},
      "feature #2 for some fonts",
    }
  }
 }
%
\ExplSyntaxOff
\CreateFontFeature{emdash=emdash.alt}{emda}
%
\newfontfamily\agp[RawFeature=+emda]{Adobe Garamond Pro}

Then in the document, I use that font as {\agp text}.

What it did was substutite the shorter emdash for the usual long one. Sadly, the shorter emdash is not in one of the OT feature sets.

Just today, I discovered that the above code no longer works. Apparently the +emda is not being processed and passed to the font any more.

Possibility 1: In my total code, much too long to post here as a MWE, I did something that interfered with the above.

Possibility 2: I notice that there have been some recent updates to fontspec and luaotfload. An issue?

So my question is: Are any other user doing something like this? Experience, as of today?

2
  • 3
    To debug whether it's a fontspec, look in the log file for the "NFSS spec" of the created family. If it has the +emda, it's not my fault... Feb 9, 2017 at 7:30
  • @WillRobertson Yes, +emda is there. Now look at Ulrike's reply, below. It appears that there was a syntax change. But the fontspec docs for v. 2.5c has the old code on page 57, Figure I. Update docs?
    – user103221
    Feb 9, 2017 at 17:03

1 Answer 1

5

It looks as if the syntax has changed. Looking at some context examples which works in a current context (e.g. http://minimals.metatex.org/current/context/test/doc/context/tests/mkiv/fonts/extensions-001.tex) the differences seems to be that data and type are no longer in a subtable, and that the explaining text has been removed. This here works for me:

\documentclass{article}
\usepackage{fontspec}

\directlua{
    fonts.handlers.otf.addfeature {
      name = "emda",
      type = "substitution",
      data = {emdash="A"},
      %"feature for xxx" %makes it fail
    }}

\newfontfamily\agp[RawFeature=+emda]{Arial}


\begin{document}
 —  {\agp —}
\end{document}

enter image description here

1
  • That saved me a LOT of digging through my own code, looking for a mystery mistake!
    – user103221
    Feb 9, 2017 at 15:19

You must log in to answer this question.