ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Changing decimals points to Persian ones via font features
@ 2016-08-01 13:46 Mohammad Hossein Bateni
  2016-08-02 19:54 ` Mohammad Hossein Bateni
  2016-08-08 14:42 ` Hans Hagen
  0 siblings, 2 replies; 6+ messages in thread
From: Mohammad Hossein Bateni @ 2016-08-01 13:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3136 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 3752 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Changing decimals points to Persian ones via font features
  2016-08-01 13:46 Changing decimals points to Persian ones via font features Mohammad Hossein Bateni
@ 2016-08-02 19:54 ` Mohammad Hossein Bateni
  2016-08-08 14:44   ` Hans Hagen
  2016-08-08 14:42 ` Hans Hagen
  1 sibling, 1 reply; 6+ messages in thread
From: Mohammad Hossein Bateni @ 2016-08-02 19:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3527 bytes --]

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 <bateni@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
>
>
> 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
>

[-- Attachment #1.2: Type: text/html, Size: 4270 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Changing decimals points to Persian ones via font features
  2016-08-01 13:46 Changing decimals points to Persian ones via font features Mohammad Hossein Bateni
  2016-08-02 19:54 ` Mohammad Hossein Bateni
@ 2016-08-08 14:42 ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2016-08-08 14:42 UTC (permalink / raw)
  To: ntg-context

On 8/1/2016 3:46 PM, 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

there are no features in math as in text if only because in math each 
symbol is a separate entity (so 1.2 is three things) .. you can try:


\def\digitsperiodsymbol{!}

$ ... \digits{123.456} ... $

-----------------------------------------------------------------
                                           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 / 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
___________________________________________________________________________________

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

* Re: Changing decimals points to Persian ones via font features
  2016-08-02 19:54 ` Mohammad Hossein Bateni
@ 2016-08-08 14:44   ` Hans Hagen
  2016-08-08 15:24     ` Mohammad Hossein Bateni
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2016-08-08 14:44 UTC (permalink / raw)
  To: ntg-context

On 8/2/2016 9:54 PM, Mohammad Hossein Bateni 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?

math fonts are defined and then don't change i.e. they are quite static 
and all juggling with individual symbols of sequences is done using 
predictable methods

> —MHB
>
> On Mon, Aug 1, 2016 at 9:46 AM, Mohammad Hossein Bateni
> <bateni@gmail.com <mailto:bateni@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
>
>
>     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
>
>
>
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           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 / 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
___________________________________________________________________________________

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

* Re: Changing decimals points to Persian ones via font features
  2016-08-08 14:44   ` Hans Hagen
@ 2016-08-08 15:24     ` Mohammad Hossein Bateni
  2016-08-08 15:36       ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Mohammad Hossein Bateni @ 2016-08-08 15:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 6691 bytes --]

Thanks, Hans!

I see; this does work except for the trouble of annotating with \digits
macro.  Would it be possible if I wrote a processor in Lua to do the work?

nodes.tasks.appendaction ("processors", "before", "fix_persian_mathperiod")

Can I find out if a node is inside math?  If I look at the corresponding
font, how can I find out if this is a math font or not?


I take it that in math fonts, kerning does not work, either?  In my case,
the Persian decimal separator usually has a part below the baseline that
extends to the left, and because all (Persian) digits are above the
baseline, I get an ugly space in the middle.  If kerning is not possible at
all, I can try to change the dimensions of Persian decimal separator symbol
because the kern is always necessary.  Is it possible to change the
dimensions of the symbol or is that also fixed and unchangeable?

Thanks a lot!
—MHB



On Mon, Aug 8, 2016 at 10:44 AM, Hans Hagen <pragma@wxs.nl> wrote:

> On 8/2/2016 9:54 PM, Mohammad Hossein Bateni 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?
>>
>
> math fonts are defined and then don't change i.e. they are quite static
> and all juggling with individual symbols of sequences is done using
> predictable methods
>
> —MHB
>>
>> On Mon, Aug 1, 2016 at 9:46 AM, Mohammad Hossein Bateni
>> <bateni@gmail.com <mailto:bateni@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][digitsexten
>> dedarabicindic][check=yes,force=yes,offset=digitsnormal]
>>
>>     \definefontsynonym
>>     [MathRoman][name:modern][features={math\mathsizesuffix,mathp
>> eriod},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
>>
>>
>>
>>
>> ____________________________________________________________
>> _______________________
>> 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/list
>> info/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ____________________________________________________________
>> _______________________
>>
>>
>
> --
>
> -----------------------------------------------------------------
>                                           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 / http://www.ntg.nl/mailman/list
> info/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ____________________________________________________________
> _______________________
>

[-- Attachment #1.2: Type: text/html, Size: 9435 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Changing decimals points to Persian ones via font features
  2016-08-08 15:24     ` Mohammad Hossein Bateni
@ 2016-08-08 15:36       ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2016-08-08 15:36 UTC (permalink / raw)
  To: ntg-context

On 8/8/2016 5:24 PM, Mohammad Hossein Bateni wrote:
> Thanks, Hans!
>
> I see; this does work except for the trouble of annotating with \digits
> macro.  Would it be possible if I wrote a processor in Lua to do the work?
>
> nodes.tasks.appendaction ("processors", "before", "fix_persian_mathperiod")
>
> Can I find out if a node is inside math?  If I look at the corresponding
> font, how can I find out if this is a math font or not?

it's doable but then you also have to fight exceptions and that is no fun

>
> I take it that in math fonts, kerning does not work, either?  In my
> case, the Persian decimal separator usually has a part below the
> baseline that extends to the left, and because all (Persian) digits are
> above the baseline, I get an ugly space in the middle.  If kerning is
> not possible at all, I can try to change the dimensions of Persian
> decimal separator symbol because the kern is always necessary.  Is it
> possible to change the dimensions of the symbol or is that also fixed
> and unchangeable?

probably best is to collect all that info, also for different math 
fonts, and then cook up some virtual font support for it (across fonts), 
if only because digits is one aspect if bidi math and there is more needed

> Thanks a lot!
> —MHB
>
>
>
> On Mon, Aug 8, 2016 at 10:44 AM, Hans Hagen <pragma@wxs.nl
> <mailto:pragma@wxs.nl>> wrote:
>
>     On 8/2/2016 9:54 PM, Mohammad Hossein Bateni 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?
>
>
>     math fonts are defined and then don't change i.e. they are quite
>     static and all juggling with individual symbols of sequences is done
>     using predictable methods
>
>         —MHB
>
>         On Mon, Aug 1, 2016 at 9:46 AM, Mohammad Hossein Bateni
>         <bateni@gmail.com <mailto:bateni@gmail.com>
>         <mailto:bateni@gmail.com <mailto:bateni@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
>
>
>             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
>
>
>
>
>         ___________________________________________________________________________________
>         If your question is of interest to others as well, please add an
>         entry to the Wiki!
>
>         maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> /
>         http://www.ntg.nl/mailman/listinfo/ntg-context
>         <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/
>         <http://foundry.supelec.fr/projects/contextrev/>
>         wiki     : http://contextgarden.net
>         ___________________________________________________________________________________
>
>
>
>     --
>
>     -----------------------------------------------------------------
>                                               Hans Hagen | PRAGMA ADE
>                   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>            tel: 038 477 53 69 | www.pragma-ade.nl
>     <http://www.pragma-ade.nl> | www.pragma-pod.nl
>     <http://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 <mailto:ntg-context@ntg.nl> /
>     http://www.ntg.nl/mailman/listinfo/ntg-context
>     <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/
>     <http://foundry.supelec.fr/projects/contextrev/>
>     wiki     : http://contextgarden.net
>     ___________________________________________________________________________________
>
>
>
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           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 / 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
___________________________________________________________________________________

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

end of thread, other threads:[~2016-08-08 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 13:46 Changing decimals points to Persian ones via font features Mohammad Hossein Bateni
2016-08-02 19:54 ` Mohammad Hossein Bateni
2016-08-08 14:44   ` Hans Hagen
2016-08-08 15:24     ` Mohammad Hossein Bateni
2016-08-08 15:36       ` Hans Hagen
2016-08-08 14:42 ` Hans Hagen

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).