ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* LMTX: reimplementing texquotes as OTF feature
@ 2022-11-11 21:19 Leah Neukirchen via ntg-context
  2022-11-11 22:51 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Leah Neukirchen via ntg-context @ 2022-11-11 21:19 UTC (permalink / raw)
  To: ntg-context; +Cc: Leah Neukirchen

Hi,

as Hans recommended in the last video meeting, I tried to implement
the texquotes feature using OTF features, and hit two problems:

1) To support German quotes as well, I have two ligatures that end
   up as the same glyph:
      `` -> “
      "' -> “
   This can't be in the same ligature feature, as it will overwrite
   the table entry with a duplicate key.

   After some fiddling, I decided to map "' to a Unicode PUA symbol
   and then add a second feature that maps this symbol to “ using
   the substitute feature.  This works for TeX Gyre Schola.
   But perhaps someone knows a nicer way.

2) This approach doesn't work for lmodern or palatino, I still
   get "' as inch-sign/quote there... anything else I need to tweak
   for these fonts?


\startluacode
    fonts.handlers.otf.addfeature {
        name = "texlig",
        type = "ligature",
        data = {
            ['“'] = { "`", "`" },
            ['”'] = { "'", "'" },
            ['„'] = { '"', "`" },
            [''] = { '"', "'" },
            ['‘'] = { "`" },
            ['’'] = { "'" }
        }
    }
    fonts.handlers.otf.addfeature {
        name = "texsub",
        type = "substitute",
        data = {
            [''] = '“',
        }
    }
\stopluacode

% with lmodern or palatino it breaks
\setupbodyfont[schola]

\definefontfeature[ltest][texlig=yes,texsub=yes,trep=no]
\addff{ltest}

\starttext

``foo'' `foo' "`foo"' 19" rack

\stoptext


Thanks,
-- 
Leah Neukirchen  <leah@vuxu.org>  https://leahneukirchen.org/
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LMTX: reimplementing texquotes as OTF feature
  2022-11-11 21:19 LMTX: reimplementing texquotes as OTF feature Leah Neukirchen via ntg-context
@ 2022-11-11 22:51 ` Hans Hagen via ntg-context
  2022-11-12 14:57   ` Leah Neukirchen via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen via ntg-context @ 2022-11-11 22:51 UTC (permalink / raw)
  To: Leah Neukirchen via ntg-context; +Cc: Hans Hagen

On 11/11/2022 10:19 PM, Leah Neukirchen via ntg-context wrote:
> Hi,
> 
> as Hans recommended in the last video meeting, I tried to implement
> the texquotes feature using OTF features, and hit two problems:
> 
> 1) To support German quotes as well, I have two ligatures that end
>     up as the same glyph:
>        `` -> “
>        "' -> “
>     This can't be in the same ligature feature, as it will overwrite
>     the table entry with a duplicate key.
> 
>     After some fiddling, I decided to map "' to a Unicode PUA symbol
>     and then add a second feature that maps this symbol to “ using
>     the substitute feature.  This works for TeX Gyre Schola.
>     But perhaps someone knows a nicer way.
> 
> 2) This approach doesn't work for lmodern or palatino, I still
>     get "' as inch-sign/quote there... anything else I need to tweak
>     for these fonts?
> 
> 
> \startluacode
>      fonts.handlers.otf.addfeature {
>          name = "texlig",
>          type = "ligature",
>          data = {
>              ['“'] = { "`", "`" },
>              ['”'] = { "'", "'" },
>              ['„'] = { '"', "`" },
>              [''] = { '"', "'" },
>              ['‘'] = { "`" },
>              ['’'] = { "'" }
>          }
>      }
>      fonts.handlers.otf.addfeature {
>          name = "texsub",
>          type = "substitute",
>          data = {
>              [''] = '“',
>          }
>      }
> \stopluacode
> 
> % with lmodern or palatino it breaks
> \setupbodyfont[schola]
> 
> \definefontfeature[ltest][texlig=yes,texsub=yes,trep=no]
> \addff{ltest}
> 
> \starttext
> 
> ``foo'' `foo' "`foo"' 19" rack
> 
> \stoptext
can you show what is wrong and what it should be with

     fonts.handlers.otf.addfeature {
         name = "germantexlig",
         type = "ligature",
         data = {
             ['“'] = { "`", "`" },
             ['”'] = { "'", "'" },
             ['„'] = { '"', "`" },
             ['“'] = { '"', "'" },
             ['‘'] = { "`" },
             ['’'] = { "'" }
         }
     }

best not use an existign feature because we accumulate ... features come 
in order (you can force order if needed as you probably saw in one of 
the test files)

\definefontfeature[ltest][germantexlig=yes,trep=no] \addff{ltest}


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LMTX: reimplementing texquotes as OTF feature
  2022-11-11 22:51 ` Hans Hagen via ntg-context
@ 2022-11-12 14:57   ` Leah Neukirchen via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Leah Neukirchen via ntg-context @ 2022-11-12 14:57 UTC (permalink / raw)
  To: Hans Hagen via ntg-context; +Cc: Leah Neukirchen

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

Hans Hagen via ntg-context <ntg-context@ntg.nl> writes:

> can you show what is wrong and what it should be with
>
>     fonts.handlers.otf.addfeature {
>         name = "germantexlig",
>         type = "ligature",
>         data = {
>             ['“'] = { "`", "`" },
>             ['”'] = { "'", "'" },
>             ['„'] = { '"', "`" },
>             ['“'] = { '"', "'" },
>             ['‘'] = { "`" },
>             ['’'] = { "'" }
>         }
>     }

Since `` and "' map to the same character, only "' works.
The table has only 5 entries, not 6!  (This took me a while to realize. ;))

> best not use an existign feature because we accumulate ... features
> come in order (you can force order if needed as you probably saw in
> one of the test files)
>
> \definefontfeature[ltest][germantexlig=yes,trep=no] \addff{ltest}

I think "texlig" and "texsub" aren't existing features.  But even
renaming doesn't help.

I've attached the working Schola screenshot and the broken LModern
behavior.


[-- Attachment #2: 2022-11-12-155544_188x27_scrot.png --]
[-- Type: image/png, Size: 2175 bytes --]

[-- Attachment #3: 2022-11-12-155557_198x23_scrot.png --]
[-- Type: image/png, Size: 2256 bytes --]

[-- Attachment #4: Type: text/plain, Size: 67 bytes --]


-- 
Leah Neukirchen  <leah@vuxu.org>  https://leahneukirchen.org/

[-- Attachment #5: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-12 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 21:19 LMTX: reimplementing texquotes as OTF feature Leah Neukirchen via ntg-context
2022-11-11 22:51 ` Hans Hagen via ntg-context
2022-11-12 14:57   ` Leah Neukirchen via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).