7

I am trying to do some sequence-for-sequence glyph replacement. As far as I can tell from the Adobe spec, the LHS and RHS of a "sub … by …" rule cannot both contain multiple glyphs; and in any case, luatex 0.70.2-2012091206 (from TeXLive 2012) segfaults if I try.

Hence, I tried the following:

languagesystem DFLT dflt;
languagesystem latn dflt;

lookup A_TO_O {
    sub a by o;
} A_TO_O;

lookup U_TO_O {
    sub u by o;
} U_TO_O;

feature test {
    sub [t]' e by s;
    sub [a]' lookup A_TO_O [u]' lookup U_TO_O;
} test;

along with the following LaTeX input:

\documentclass{scrbook}
\usepackage{fontspec}
\setmainfont[FeatureFile=test.fea,RawFeature=+test;]{Times New Roman}
\begin{document}
A test and baud boud bastard.
\end{document}

I'm trying here to replace "te" with "se" in the first rule, and "au" with "oo" in the second.

This does not work; in fact, it doesn't do anything (the first rule doesn't fire). This seems to mean that LuaTeX didn't like it (it does the same thing if I introduce a definite syntax error), but I can't find any error messages.

If I comment out the second rule, the first one fires, and I get "sest" instead of "test" in the output.

  • That is exactly what I said in my second sentence: as far as I can tell, multiple glyphs on the RHS are not allowed, hence the contorted code in my example. – Reuben Thomas May 7 '13 at 10:34
7

I’m a novice at OT feature programming myself, so probably my tips aren’t all that helpful, but since you never got any answer…

Maybe it doesn’t help to combine the lookups, but it makes the code more readable at least:

lookup AU_TO_OO {
  sub a by o;
  sub u by o;
} AU_TO_OO;
feature test {
  sub t' e by s;
  sub a' lookup AU_TO_OO u' lookup AU_TO_OO;
} test;

The marks ' in the second rule aren’t really necessary, but they shouldn’t do harm either. It’s worth a try, though:

  sub a lookup AU_TO_OO u lookup AU_TO_OO;

I’m not sure if combining the input glyph sequences should work:

  sub a' u' lookup AU_TO_OO;

I think one could even shorten the lookup, because it’s called twice:

lookup AU_TO_OO {
  sub [a u] by o;
} AU_TO_OO;

In every case only one rule in the lookup matches for any glyph in the input glyph sequence, so that should work fine.

Update: Most of what I wrote above, it turns out, does not work although it should according to Adobe’s documentation of the feature file syntax. A comment by @KhaledHosny hints at the cause for this: LuaTeX uses FontForge code to handle feature files, but not a recent version thereof. Adobe changed the format in late 2008 (v1.8), adding lookup stuff our code relies on. So one needs to follow version 1.7 of the specification until LuaTeX is updated some day. To keep track of that see the bug report.

  • Welcome to TeX.SX! – Ludovic C. Nov 15 '13 at 11:56

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.