Dear Hans & Wolfgang,

I resolved some of the minor issues.  But the main question still stands.
Is it possible to add an OTF feature to the math font?  In the very simple
case, I want to change any sequence like "1.2" to "1/2".  My feature (see
below) works for text fonts but not in math mode.

Thanks,
MHB

On Tue, Aug 2, 2016 at 3:54 PM, Mohammad Hossein Bateni <bat...@gmail.com>
wrote:

> Could the problem be because math fonts use mode=base instead of
> mode=node?  Or is it because in math fonts, the digits and/or full-stop
> have different codes?
> —MHB
>
> On Mon, Aug 1, 2016 at 9:46 AM, Mohammad Hossein Bateni <bat...@gmail.com>
> wrote:
>
>> Dear list,
>>
>> I want to add a customized font feature to the math font, to
>> automatically change the decimal point (unicode 0x2E) to the Arabic/Farsi
>> version (unicode 0x66B).  This will go well with the mapping from Latin
>> digits to Farsi digits (done in a sample with mathdigits fallback).
>>
>> For instance, I want to code in $123.45$ and get a result like ۱۲۳٫۴۵.
>> However, I do not want to simply map 0x2E to 0x66B, because then "full
>> stop" outside a number will also change.  In particular, I'd like to have
>> the mapping only when full-stop is preceded and succeeded by a digit.  This
>> will, among other things, leave the end-of-equation periods unchanged.
>>
>> Here is how I tried to achieve it.
>>
>>
>> \startluacode
>> digits = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }
>> -- 0x66B instead of 0x2F gives an error!
>> replacements = { [0x002E] = { 0x2F } }
>> fonts.handlers.otf.addfeature {
>>   name = "mpf",
>>   type = "chainsubstitution",
>>   lookups = { {
>>     type = "multiple",
>>     data = replacements,
>>   } },
>>   data = {
>>     rules = {
>>       {
>>         current = { { 0x002E } },
>>         after   = { digits },
>>         before  = { digits },
>>         lookups = { 1 },
>>       }
>>     }
>>   }
>> }
>> \stopluacode
>>
>> \definefontfeature[mathperiod][mpf=yes]
>>
>> \resetfontfallback [mathdigits]
>> %\definefontfallback[mathdigits][dejavusansmono][
>> digitsextendedarabicindic][check=yes,force=yes,offset=digitsnormal]
>>
>> \definefontsynonym [MathRoman][name:modern][
>> features={math\mathsizesuffix,mathperiod},goodies=lm-math,
>> fallbacks=mathdigits]
>>
>> \starttext
>> $123.45.$
>>
>> 123.45.
>>
>> \addff{mathperiod}
>> 123.45.
>> \stoptext
>>
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to