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:

<div>\directlua{ </div><div>&nbsp; &nbsp;fonts.handlers.otf.addfeature{</div><div> &nbsp; &nbsp; name = "apo-nosc",</div><div> &nbsp; &nbsp; type = "chainsubstitution",</div><div> &nbsp; &nbsp; lookups = {</div><div> &nbsp; &nbsp; &nbsp; {</div><div> &nbsp; &nbsp; &nbsp; &nbsp; type = "substitution",</div><div> &nbsp; &nbsp; &nbsp; &nbsp; data = {</div><div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ["quoteright.sc"] = "quoteright.fr",&nbsp;</div><div> &nbsp; &nbsp; &nbsp; &nbsp; },</div><div> &nbsp; &nbsp; &nbsp; },</div><div> &nbsp; &nbsp; },</div><div> &nbsp; &nbsp; data = {</div><div> &nbsp; &nbsp; &nbsp; rules = {</div><div> &nbsp; &nbsp; &nbsp; &nbsp; {</div><div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; before&nbsp; = { { "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"} },</div><div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current = { { "quoteright.sc" } },</div><div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lookups = { 1 },</div><div> &nbsp; &nbsp; &nbsp; &nbsp; },</div><div> &nbsp; &nbsp; &nbsp; },</div><div> &nbsp; &nbsp; },</div><div> &nbsp; }</div><div> }</div>When I write, for example, < \textsc{l'albero L'Albero} >, t
he 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: 631
    Are the two quotes intentionally at the same height? Because they are.
  • mauro sacchettomauro sacchetto Posts: 353
    edited May 2020
    ops... sorry, obviously not. This is the right image

  • Simon CozensSimon Cozens Posts: 723
    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: 2,955
    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: 353
    edited May 2020

    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.