Replacement lookup

I would like to implement a replacement lookup in a font instead of relying on the software. I explain the thing from the software point of view, since I am more expert in LaTeX than in fonts. The relevant part of code is as follows:

\directlua{

   fonts.handlers.otf.addfeature{
    name = "apo-nosc",
    type = "chainsubstitution",
    lookups = {
      {
        type = "substitution",
        data = {
          ["quoteright.sc"] = "quoteright.fr", 
        },
      },
    },
    data = {
      rules = {
        {
          before  = { { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} },
          current = { { "quoteright.sc" } },
          lookups = { 1 },
        },
      },
    },
  }
}
When I write, for example, < \textsc{l'albero L'Albero} >, the first apostrophe is correctly rendered with the low apostrophe, that is with quoteright.sc. In the second case, the replacement rule for Luatex that I set replaces quoteright.sc with the high apostrophe, that is quoteright because the apostrophe is still between two capitals:



Is it possible to create a similar rule within the font that makes additional code in the text unnecessary?
And what should I adopt? A Contextual or Chaining Contextual Substitution?
Thank you

Comments

  • George ThomasGeorge Thomas Posts: 527
    Are the two quotes intentionally at the same height? Because they are.
  • mauro sacchettomauro sacchetto Posts: 251
    edited May 21
    ops... sorry, obviously not. This is the right image

  • Simon CozensSimon Cozens Posts: 413
    Is it possible to create a similar rule within the font that makes additional code in the text unnecessary?
    Sure - that's "sub [A-Z] quoteright.sc' by quoteright.fr" in AFKDO Language, right?
    And what should I adopt? A Contextual or Chaining Contextual Substitution?
    Thank you
    Does it matter? Implementations will often replace a contextual with a chaining contextual for generality.
  • John HudsonJohn Hudson Posts: 1,828
    You could also do this just by putting the /quoteright.sc/ in the c2sc but not in the smcp feature. That way, you could select the whole word and apply either just smcp or both smcp/c2sc to determine what gets converted to smallcaps.
  • mauro sacchettomauro sacchetto Posts: 251
    edited May 21

    I managed to build a Contextual Alternates lookup that refers to a Single Substitution lookup: it works fine. The second solution is actually simpler. Is there reason to prefer one or the other, or are they equivalent?
Sign In or Register to comment.