0

For a few weeks, I've had a nice working font feature to automatically change "et" for "&" when it's in italic mode.

But suddenly, It now longer works....

I suspect something to do with the contextual constrain, since the same ligature with no context works just fine.

I would appreciate very much any help.

BTW, is there still no official guide/manual for this kind of programming font features ?

MWE :

\documentclass{article}

\usepackage{fontspec}

\directlua{

 fonts.handlers.otf.addfeature 
 {
   name = "itet",
   type = "chainsubstitution",

   lookups = {
            {
                type = "ligature",
                data = {
                    ["&"] = { "e","t" },
                },
            },
     },

    data = {
      rules = {
        {
          before  = { { " " }},
          after  = { { " ", "," }},
          current = {{"e"},{"t"}},
          lookups = { 1 },
        },  
      },
    },
}
}

\setmainfont{Baskerville}[ItalicFeatures = {RawFeature = {+itet}}]

\begin{document}
et \emph{et}
\end{document}

Edit:

It turns out, that for some mysterious reasons the following was happening:

  • In my current work, I was using \usepackage{fourier} after \usepackage{fontspec}; and that was bad.
  • This use was impacting the MWE, even if it was not using fourier.

So, in fact, that was all my bad + some mysterious things in the cache.

Answer:

Don't use fourier after fontspec, as discussed in enter link description here

Thanks for all your help! Including the modification proposed in answer (that is indeed, very good)

9
  • Which of the many Baskervilles are you using?
    – Thérèse
    Jan 9, 2020 at 14:18
  • @Thérèse I just picked a random font, usually I use Adobe's Kepler, but with Baskerville the same issue arises. I think with any other It would too Jan 9, 2020 at 14:20
  • It’s working for me with Crimson. Do you perhaps have a package that’s not up-to-date, or two versions of a package?
    – Thérèse
    Jan 9, 2020 at 14:26
  • I uploaded all my packages lately with TeXLive. How do I know if I have two versions of a package ? Ok that's weird, It works for some fonts now, but not with my setting of Kepler. Perhaps there is a way to reset the way fontspec maps font ? Jan 9, 2020 at 14:29
  • 1
    tex.stackexchange.com/q/523254 may help you figure out how the interference happens.
    – Thérèse
    Jan 9, 2020 at 14:53

1 Answer 1

2

At least on my system (with a current luaotfload/fontloader) the spaces in the before/after rules are not enough as it doesn't affect occurences at the begin and end of lines. It works if I use 0xFFFC, see also https://www.mail-archive.com/[email protected]/msg85615.html

\documentclass{article}

\usepackage{fontspec}

\directlua{
 fonts.handlers.otf.addfeature
 {
   name = "itet",
   type = "chainsubstitution",
   lookups = {
            {
                type = "ligature",
                data = {
                    ["&"] = { "e","t" },
                },
            },
     },
    data = {
      rules = {
        {
          before  = { { 0xFFFC } },
         % before  = { {" "} },
          after   = { { 0xFFFC,  "," } },
         % after   = { { " ",  "," } },
          current = {{"e"},{"t"}},
          lookups = { 1 },
        },
      },
    },
}
}

\setmainfont{TeXGyreHeros}[ItalicFeatures = {RawFeature = {+itet}}]

\begin{document}
et blub et blet etbub et,

\emph{et} abc \emph{et} abc \emph{et}

\itshape et blub et blet etbub et,
et
\end{document}

Output with my code

enter image description here

Output with the commented before/after rules:

enter image description here

1
  • I edited my first post ... to explain what happened. Thanks for your answer, It corrects something that was indeed annoying Jan 9, 2020 at 18:16

You must log in to answer this question.

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