From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/95646 Path: news.gmane.org!.POSTED!not-for-mail From: Mohammad Hossein Bateni Newsgroups: gmane.comp.tex.context Subject: Changing decimals points to Persian ones via font features Date: Mon, 1 Aug 2016 15:46:34 +0200 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1813026062730958429==" X-Trace: blaine.gmane.org 1470059245 14232 80.91.229.8 (1 Aug 2016 13:47:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 Aug 2016 13:47:25 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Aug 01 15:47:10 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUDYj-0003FO-VV for gctc-ntg-context-518@m.gmane.org; Mon, 01 Aug 2016 15:47:10 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3EC0213BCE; Mon, 1 Aug 2016 15:46:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05UlyihmYqHp; Mon, 1 Aug 2016 15:46:51 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 752E213BDB; Mon, 1 Aug 2016 15:46:51 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id BD66E13BC7 for ; Mon, 1 Aug 2016 15:46:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NBdS7cO8yKHE for ; Mon, 1 Aug 2016 15:46:46 +0200 (CEST) Original-Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id DE18313BBE for ; Mon, 1 Aug 2016 15:46:35 +0200 (CEST) Original-Received: by mail-lf0-f44.google.com with SMTP id l69so115881867lfg.1 for ; Mon, 01 Aug 2016 06:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=e8DiU2Ky3eePNCmVxv+8sk2H2mMsTbQd0Q5f9U7yJ/U=; b=TaaWZRpO147jJkLgAu/QOa8vtCVxvpLzVJjO0Xm+v1eh5ka/0Hl6TtpfwaLe2kY5r8 lOHa/cgLOyD+TDJOAVa0/+RRNMZDIASYuurGTe67VbFs1rT8MGQn2AemEFBV0b5GONol 98+AcSp0ZWLCyeZ3DCQxRulziXstL4TbSgiDsD2sriWEobjn4reiOJzlgQrEOlDRc1Xo 4ordEizmgFgPV96tE12GQiudZU2OBu650Yx5cZ5vWg3QENOEvNBNjhRt+uG2is6ZlgJt DhApDaz3GZfAstVTX8yiw9w8INFZ1Rkyut2C8FLZ92gl72xBQcEkt5w2ucVWAvHmhEOh D4ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=e8DiU2Ky3eePNCmVxv+8sk2H2mMsTbQd0Q5f9U7yJ/U=; b=b5+uIBBQp/Y62YZYvCM4WdpbLt/bvOIVPuKmEJCz/a5IJverfZBTmMi+6iGvGiXG/Q 9bseE+6F+q8j/mYG0r6Xovw9a/jzDpquZVB6kpdsWz8jaeKg2VNX4UmeSMT/LV3ODqO9 n6+1VQ9kP1Z9h1Ya5NLQ6LqDN3KTmWOQs88gFmIqY6uQF0c4sOgBXuyi6RHDyubdoUCn dqGhgjYmka4WF1ccmWQnAMKKxcVPVUizewMqLOjTVRo+YphuLcaeXbYTJ3nDesT5uYDP ONUZU1QB/tcHaouKwDfEvGVvPaLg7XAr02O5xM6GP6GpTiI528FNEvSnFzt2ivHXd7pA TPrg== X-Gm-Message-State: AEkoous386XBmFZUYmmCHk5GrGVwylvup9Id+q5SxWucjgrvyvgJ5RokEQJ2iemf53kHp9/zuY/JvqSxQOYWcw== X-Received: by 10.25.207.10 with SMTP id f10mr15928583lfg.108.1470059194754; Mon, 01 Aug 2016 06:46:34 -0700 (PDT) Original-Received: by 10.25.215.164 with HTTP; Mon, 1 Aug 2016 06:46:34 -0700 (PDT) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:95646 Archived-At: --===============1813026062730958429== Content-Type: multipart/alternative; boundary=001a1141886e1a2c6b053902d477 --001a1141886e1a2c6b053902d477 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =DB=B1=DB=B2= =DB=B3=D9=AB=DB=B4=DB=B5. 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 =3D { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 } -- 0x66B instead of 0x2F gives an error! replacements =3D { [0x002E] =3D { 0x2F } } fonts.handlers.otf.addfeature { name =3D "mpf", type =3D "chainsubstitution", lookups =3D { { type =3D "multiple", data =3D replacements, } }, data =3D { rules =3D { { current =3D { { 0x002E } }, after =3D { digits }, before =3D { digits }, lookups =3D { 1 }, } } } } \stopluacode \definefontfeature[mathperiod][mpf=3Dyes] \resetfontfallback [mathdigits] %\definefontfallback[mathdigits][dejavusansmono][digitsextendedarabicindic]= [check=3Dyes,force=3Dyes,offset=3Ddigitsnormal] \definefontsynonym [MathRoman][name:modern][features=3D{math\mathsizesuffix,mathperiod},goodie= s=3Dlm-math,fallbacks=3Dmathdigits] \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 --001a1141886e1a2c6b053902d477 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear list,

I want to add a customized f= ont feature to the math font, to automatically change the decimal point (un= icode 0x2E)=C2=A0to the Arabic/Farsi version (unicode 0x66B).=C2=A0 This wi= ll go well with the mapping from Latin digits to Farsi digits (done in a sa= mple with mathdigits fallback).

For instance, I wa= nt to code in $123.45$ and get a result like =DB=B1=DB=B2=DB=B3=D9=AB=DB=B4= =DB=B5.=C2=A0 However, I do not want to simply map 0x2E to 0x66B, because t= hen "full stop" outside a number will also change.=C2=A0 In parti= cular, I'd like to have the mapping only when full-stop is preceded and= succeeded by a digit.=C2=A0 This will, among other things, leave the end-o= f-equation periods unchanged.

Here is how I tried = to achieve it.


\startluacode
digits =3D { 0x30, = 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }
-- 0x66B instead = of 0x2F gives an error!
replacements =3D { [0x002E] =3D { 0x2F } }
fo= nts.handlers.otf.addfeature {
=C2=A0 name =3D "mpf",
=C2=A0= type =3D "chainsubstitution",
=C2=A0 lookups =3D { {
=C2= =A0 =C2=A0 type =3D "multiple",
=C2=A0 =C2=A0 data =3D replace= ments,
=C2=A0 } },
=C2=A0 data =3D {
=C2=A0 =C2=A0 rules =3D {
= =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 current =3D { { 0x002= E } },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 after =C2=A0 =3D { digits },
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 before =C2=A0=3D { digits },
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 lookups =3D { 1 },
=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }<= br>=C2=A0 }
}
\stopluacode

\definefontfeature[mathperiod][mpf= =3Dyes]

\resetfontfallback [mathdigits]
%\definefontfallback[math= digits][dejavusansmono][digitsextendedarabicindic][check=3Dyes,force=3Dyes,= offset=3Ddigitsnormal] =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
\= definefontsynonym [MathRoman][name:modern][features=3D{math\mathsizesuffix,= mathperiod},goodies=3Dlm-math,fallbacks=3Dmathdigits]

\starttext
= $123.45.$

123.45.

\addff{mathperiod}
123.45.
\stoptext<= div>

Though this font feature works outside ma= th, it does not seem to have any effect within the math font.=C2=A0 Why is = that?=C2=A0 Can we add font feature to the math font?=C2=A0 Are the charact= er codes different?

Notice that I could not get it to work, s= o I commented out the fallback for Persian digits, to make things simpler.= =C2=A0 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?=C2=A0 Actually, I did try with only mathperiod a= nd it does not work, either.

When I change = 0x2F (slash) to 0x066B in "replacements", I get an error as follo= ws.


fonts =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > otf chain >= feature 'mpf', type 'gsub_contextchain', chain lookup '= ;mpf': rule 1 matches at char U+0002E (period) for (1,1,1) chars, looku= ptype 'gsub_multiple'

error: ...ext/tex/texmf-context/tex/co= ntext/base/mkiv/font-ots.lua:1232: attempt to index field '?' (a ni= l value)

tex error =C2=A0 =C2=A0 =C2=A0 > tex error on line 1 in = file /Users/bateni/farsitex/context/bostan/examples/mathfa/1.tex: ?

= \page ->\par
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\dosingl= eempty \page_breaks_process
\strc_pagenumbers_flush_final_page ...\else = \page
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [\p_strc_pagenumbers_page ...
\dostop= text ...\strc_pagenumbers_flush_final_page
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \= page \the \everystoptext ...
l.1 \dostoptext

\clf_stoptext ->\= luafunction \16>>clf_stoptext

l.46 \stoptext



Best,
MHB

--001a1141886e1a2c6b053902d477-- --===============1813026062730958429== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============1813026062730958429==--