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 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 > > > Though this font feature works outside math, it does not seem to have any > effect within the math font. Why is that? Can we add font feature to the > math font? Are the character codes different? > > Notice that I could not get it to work, so I commented out the fallback > for Persian digits, to make things simpler. To get the proof of concept, I > am trying to change period to forward slash (see below). > > Is the syntax I use for having two features in \defontfontsynonym > correct? Actually, I did try with only mathperiod and it does not work, > either. > > When I change 0x2F (slash) to 0x066B in "replacements", I get an error as > follows. > > > fonts > otf chain > feature 'mpf', type 'gsub_contextchain', > chain lookup 'mpf': rule 1 matches at char U+0002E (period) for (1,1,1) > chars, lookuptype 'gsub_multiple' > > error: ...ext/tex/texmf-context/tex/context/base/mkiv/font-ots.lua:1232: > attempt to index field '?' (a nil value) > > tex error > tex error on line 1 in file > /Users/bateni/farsitex/context/bostan/examples/mathfa/1.tex: ? > > \page ->\par > \dosingleempty \page_breaks_process > \strc_pagenumbers_flush_final_page ...\else \page > > [\p_strc_pagenumbers_page ... > \dostoptext ...\strc_pagenumbers_flush_final_page > \page \the > \everystoptext ... > l.1 \dostoptext > > \clf_stoptext ->\luafunction \16>>clf_stoptext > > l.46 \stoptext > > > > Best, > MHB >