ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mohammad Hossein Bateni <bateni@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Changing decimals points to Persian ones via font features
Date: Mon, 8 Aug 2016 11:24:40 -0400	[thread overview]
Message-ID: <CAMHZ1dZoRgKzGLHVtwJO7TES3rqEY8D68sZ2Hc9Wg9p7uixdBg@mail.gmail.com> (raw)
In-Reply-To: <18b44f25-0c1d-9923-647d-870ae08bd572@wxs.nl>


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

  reply	other threads:[~2016-08-08 15:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01 13:46 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 [this message]
2016-08-08 15:36       ` Hans Hagen
2016-08-08 14:42 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMHZ1dZoRgKzGLHVtwJO7TES3rqEY8D68sZ2Hc9Wg9p7uixdBg@mail.gmail.com \
    --to=bateni@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).