%!TEX TS-program = mkiv

\definefontfeature
 [arab-default]
 [mode=node,language=dflt,script=arab,
  init=yes,medi=yes,fina=yes,isol=yes,
  locl=yes,calt=yes,clig=yes,ccmp=yes,
  liga=yes,dlig=yes,rlig=yes,clig=yes,
  mark=yes,mkmk=yes,kern=yes,curs=yes]

\definefont[FaarsiFontK][BKamran*arab-default at 12pt]
\definefont[FaarsiFontN][BNazanin*arab-default at 11pt]
\definefont[FaarsiFontNastaliq][IranNastaliq*arab-default at 18pt]

\definestartstop[FaarsiK][style=\textdir TRT\FaarsiFontK]
\definestartstop[FaarsiN][style=\textdir TRT\FaarsiFontN]
\definestartstop[FaarsiNastaliq][style=\textdir TRT\FaarsiFontNastaliq]

\usetypescript[palatino][ec] 
\usetypescript[times][ec] 
\setupbodyfont[palatino,10pt]
%\setupbodyfont[times,10pt]


\definestartstop[RomanText][style={\textdir TLT\switchtobodyfont[12pt]}]


\starttext
\pardir TRT
%%%%%%%%%%%
\startbuffer[FaarsiText]
دیر مغان.
دِیرِ مُغان.
اين آزمايش نوشتن فارسى است بدون هيچ آمادگى.
 اين آزمايش نوشتن فارسى است بدون هيچ آمادگى.
 اين آزمايش نوشتن فارسى است بدون هيچ آمادگى.
 اين آزمايش نوشتن فارسى است بدون هيچ آمادگى.
\stopbuffer
%%%%%%%%%%%

%%%%%%%%%%%
\pardir TLT
\startbuffer[FaarsiK] 
\RomanText{This is some text in English.} \pardir TRT

\startFaarsiK

\getbuffer[FaarsiText]
\blank[2*big]

\getbuffer[FaarsiText] \ \pardir TLT
 \startRomanText
This is some text in English in the midst of some text in Persian 
\stopRomanText
\  
\getbuffer[FaarsiText]

\stopFaarsiK
\stopbuffer
%%%%%%%%%%%

%%%%%%%%%%%%
\startbuffer[FaarsiN]
\RomanText{This is some text in English.}

\startFaarsiN

\getbuffer[FaarsiText]
\blank[2*big]

\getbuffer[FaarsiText] \  % needed to enforce a space
\startRomanText
This is some text in English in the midst of some text in Persian
\stopRomanText
\ % needed to enforce a space
\getbuffer[FaarsiText]

\stopFaarsiN
\stopbuffer
%%%%%%%%%%%

%%%%%%%%%%%
\startbuffer[FaarsiNastaliq]
\RomanText{This is some text in English.}

\startFaarsiNastaliq

\getbuffer[FaarsiText]
\blank[2*big]

\getbuffer[FaarsiText] \ % needed to enforce a space
\startRomanText
This is some text in English in the midst of some text in Persian
\stopRomanText
\ % needed to enforce a space
\getbuffer[FaarsiText]

\stopFaarsiNastaliq
\stopbuffer
%%%%%%%%%%%

\getbuffer[FaarsiK]
\blank

\getbuffer[FaarsiN]
\blank

\getbuffer[FaarsiNastaliq]

\stoptext