From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/95661 Path: news.gmane.org!.POSTED!not-for-mail From: Mohammad Hossein Bateni Newsgroups: gmane.comp.tex.context Subject: Re: Changing decimals points to Persian ones via font features Date: Tue, 2 Aug 2016 15:54:34 -0400 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0437234633405417844==" X-Trace: blaine.gmane.org 1470167706 29253 195.159.176.226 (2 Aug 2016 19:55:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 Aug 2016 19:55:06 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Aug 02 21:55:02 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 1bUfmH-00075A-D4 for gctc-ntg-context-518@m.gmane.org; Tue, 02 Aug 2016 21:55:01 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id F2A7513FD3; Tue, 2 Aug 2016 21:54:49 +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 4Cce0UejTf1J; Tue, 2 Aug 2016 21:54:49 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 3986D13FD4; Tue, 2 Aug 2016 21:54:49 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id BF81213FD2 for ; Tue, 2 Aug 2016 21:54:47 +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 8rtYY3ip11aM for ; Tue, 2 Aug 2016 21:54:47 +0200 (CEST) Original-Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) (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 15D7713FD1 for ; Tue, 2 Aug 2016 21:54:37 +0200 (CEST) Original-Received: by mail-lf0-f42.google.com with SMTP id f93so146228857lfi.2 for ; Tue, 02 Aug 2016 12:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=x6GrDjfjOlF1geTzWdknx6NovL5lH9j5pbyLHlGxyhk=; b=XOahJw3MeMrj+CvWHNS3014XlBbo5a0q5NWunifNLrY6iI3iwKA8gWRr++f4ZzDapy H9mEwKSfn0KveIrrAsjZnrLlSMvhs3bwgTDJ1MDrxoHBBgoGy5LT6wWyFBNLxpcjgyGN sVg0MJbDqq9Lr7+RK8rR21M6blOGeGWEzgEhuFR+Wunh+8aD8V9I0gumE3GpUclmyszP v4zuWiNIdMdlcGj0qNCrZZlOyV/a1GhCFx636kQvtA87NizLPl2Fh3Ch+OO3LGShIoRw c66FH+oO7OvCknwjdw2FtLm3oAdQpqNosaACRUU6Cge0/V5xIgk4f99UekGUC81lMBOX ocwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=x6GrDjfjOlF1geTzWdknx6NovL5lH9j5pbyLHlGxyhk=; b=chLuUVOIpRkS+Zz23L/LUbvApbfZlnTvEusV2hv6mW2mNcE2T6Pf4Q4TFdfRaJPuJ4 Hcs0nF8S0IXPxtBPj1Xq/XFsddyiw5kVYS42Jts4Bhb3+Vkc+Ia4pbh2/URlAeWkagJF uVgSzjfBEmBhPiKoQWeZ8SSwmv64/27xqkavkia8RQZIXIINrfMyh2bxC/TpDtX+mYqr neCYxOwhwgxaubiMPGyyAZid/8tF48Mn82cPvrPRLX+wIV1rRGY5kt7hV2+wV8igryo3 xcADU6M1wd+V+xl1ubLKPIn4h0Q4AuPMmxH/gb/bTedN+dTVYyOQymhJoCJ0A6utphwm jNMw== X-Gm-Message-State: AEkoouvF4SIWsvcsRvpTEBj/A9LkcI2zTglcjnyOKcpNSL8sHrqLr8V9o1OLn1906dY3kwTzSRLs120cPzhKPA== X-Received: by 10.25.216.26 with SMTP id p26mr21890434lfg.122.1470167675883; Tue, 02 Aug 2016 12:54:35 -0700 (PDT) Original-Received: by 10.25.215.164 with HTTP; Tue, 2 Aug 2016 12:54:34 -0700 (PDT) In-Reply-To: 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:95661 Archived-At: --===============0437234633405417844== Content-Type: multipart/alternative; boundary=001a114024a414d7e405391c1607 --001a114024a414d7e405391c1607 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Could the problem be because math fonts use mode=3Dbase instead of mode=3Dnode? Or is it because in math fonts, the digits and/or full-stop have different codes? =E2=80=94MHB 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 automaticall= y > 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. Th= is > 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][digitsextendedarabicindi= c][check=3Dyes,force=3Dyes,offset=3Ddigitsnormal] > > \definefontsynonym > [MathRoman][name:modern][features=3D{math\mathsizesuffix,mathperiod},good= ies=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 th= e > 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 > --001a114024a414d7e405391c1607 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Could the problem be because math fonts use mode=3Dbase in= stead of mode=3Dnode?=C2=A0 Or is it because in math fonts, the digits and/= or full-stop have different codes?
=E2=80=94MHB

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)=C2=A0to the Arabic/Farsi version (u= nicode 0x66B).=C2=A0 This will go well with the mapping from Latin digits t= o Farsi digits (done in a sample with mathdigits fallback).

<= /div>
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.=C2=A0 However, I do not want to simpl= y map 0x2E to 0x66B, because then "full stop" outside a number wi= ll also change.=C2=A0 In particular, 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-of-equation periods unchanged.

<= /div>
Here is how I tried to achieve it.


\start= luacode
digits =3D { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3= 8, 0x39 }
-- 0x66B instead of 0x2F gives an error!
replacements =3D {= [0x002E] =3D { 0x2F } }
fonts.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 replacements,
=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 { { 0x002E } },
=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 { d= igits },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 lookups =3D { 1 },
=C2=A0 =C2=A0= =C2=A0 }
=C2=A0 =C2=A0 }
=C2=A0 }
}
\stopluacode

\defin= efontfeature[mathperiod][mpf=3Dyes]

\resetfontfallback [mathdigits]<= br>%\definefontfallback[mathdigits][dejavusansmono][digitsextendedarabicind= ic][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][fe= atures=3D{math\mathsizesuffix,mathperiod},goodies=3Dlm-math,fallbacks=3Dmat= hdigits]

\starttext
$123.45.$

123.45.

\addff{mathpe= riod}
123.45.
\stoptext


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

Notice that= I could not get it to work, so I commented out the fallback for Persian di= gits, to make things simpler.=C2=A0 To get the proof of concept, I am tryin= g to change period to forward slash (see below).

Is the syntax I use= for having two features in \defontfontsynonym correct?=C2=A0 Actually, I d= id try with only mathperiod and it does not work, either.

When= I change 0x2F (slash) to 0x066B in "replacements", I get an erro= r as follows.


fonts =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > otf = chain > feature 'mpf', type 'gsub_contextchain', chain l= ookup 'mpf': rule 1 matches at char U+0002E (period) for (1,1,1) ch= ars, lookuptype 'gsub_multiple'

error: ...ext/tex/texmf-cont= ext/tex/context/base/mkiv/font-ots.lua:1232: attempt to index field '?&= #39; (a nil 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\dosingleempty \page_breaks_process
\strc_pagenumbers_flush_final_pag= e ...\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 ...=
\dostoptext ...\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_sto= ptext ->\luafunction \16>>clf_stoptext

l.46 \stoptext



Best,
MHB


--001a114024a414d7e405391c1607-- --===============0437234633405417844== 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= --===============0437234633405417844==--