5

I am trying to get Arabic Chapter Name in the header and some arabic text in the margins using ConTeXt MarkIV

Here is the MWE:

\mainlanguage[arabic]
\setupdirections[bidi=global]
\definefontfeature
  [arabic]
  [mode=node,language=dflt,script=arab,
    init=yes,medi=yes,fina=yes,isol=yes,
    liga=yes,dlig=yes,rlig=yes,tlig=yes,
    calt=yes,trep=yes,clig=yes,
    mark=yes,mkmk=yes,kern=yes,curs=yes]


\starttypescript [serif] [arabic]
  \definefontsynonym [Arabic-Regular] [file:ScheherazadeRegOT.ttf] [features=arabic]
  \definefontsynonym [Arabic-Bold] [file:ScheherazadeRegOT.ttf] [features=arabic]
\stoptypescript

\starttypescript [serif] [arabic] [name]
 \usetypescript[serif][fallback]
 \definefontsynonym [Serif]     [Arabic-Regular] [features=arabic]
 \definefontsynonym [SerifBold] [Arabic-Bold]    [features=arabic]
\stoptypescript

\starttypescript [Arabic]
  \definetypeface [Arabic] [rm] [serif] [arabic] [default] 
\stoptypescript 

\def\ArabicGlobalDir {\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT}
\def\ArabicParDir    {\textdir TRT\pardir TRT}
\def\ArabicTextDir   {\textdir TRT}

\define\setarabic
  {\ArabicGlobalDir%
   \usetypescript[Arabic]%
   \setupbodyfont[Arabic,20pt]}

\definestartstop
  [arabicpar]
  [commands=\Arabic\ArabicParDir]

\define[1]\RT
  {{\Arabic\ArabicTextDir#1}}

\pagedir TRT
\bodydir TRT
\pardir TRT
\textdir TRT

\setuppapersize[A4]

\setuplayout[
  grid=min,
  backspace=55.999mm, width=130mm,
  topspace=39.666mm, height=210mm,
  header=12mm, footer=9mm,
  ]

\setupbodyfont[Arabic,24pt]
\setupinterlinespace[line=42pt]

\setupheads[number=no]
\setuphead[chapter][style=\bfd,before=,after=\blank,alternative=middle,grid=both]
\setuphead[section][style=\bfc,before=\blank,after=,grid=both]

\setupbackgrounds[header][text][frame=off, bottomframe=on]

\setupheadertexts
        [{\getmarking[chapter]}]    [{صفحة }]
        [{صفحة }]        [{\getmarking[chapter]}]

\setupinmargin[stack=yes]

\starttext

\chapter{الآجرومية}

\margintext{الآجرومية}

الحمد لله رب العالمين، وصلى الله وسلم وبارك على عبده ورسوله نبينا محمد وعلى آله وصحبه أجمعين، أما بعد:
فلا يخفى على من له أدنى عناية بالعلم الشرعي لا سيما ما يتعلق بالكتاب العزيز والسنة النبوية لا يخفى عليه أهمية معرفة اللغة العربية بفنونها العشرة أو الإثني عشر: 

\stoptext

I tried searching in the ConTeXt manual and here, but could not get any solutions.

Header Issue

2

I have little knowledge of how to write arabic with context, usually I use polyglossia, appear that you have defined command to write right to left text \ArabicTextDir, you can use it to resolve the problem with:

\setupheadertexts [{\getmarking[chapter]}] [{\ArabicTextDir صفحة}][{صفحة }] [{\getmarking[chapter]}] 

and

\chapter{\ArabicTextDir الآجرومية}

Code

\mainlanguage[arabic]
\setupdirections[bidi=global]
\definefontfeature
  [arabic]
  [mode=node,language=dflt,script=arab,
    init=yes,medi=yes,fina=yes,isol=yes,
    liga=yes,dlig=yes,rlig=yes,tlig=yes,
    calt=yes,trep=yes,clig=yes,
    mark=yes,mkmk=yes,kern=yes,curs=yes]


\starttypescript [serif] [arabic]
  \definefontsynonym [Arabic-Regular] [file:ScheherazadeRegOT.ttf] [features=arabic]
  \definefontsynonym [Arabic-Bold] [file:ScheherazadeRegOT.ttf] [features=arabic]
\stoptypescript

\starttypescript [serif] [arabic] [name]
 \usetypescript[serif][fallback]
 \definefontsynonym [Serif]     [Arabic-Regular] [features=arabic]
 \definefontsynonym [SerifBold] [Arabic-Bold]    [features=arabic]
\stoptypescript

\starttypescript [Arabic]
  \definetypeface [Arabic] [rm] [serif] [arabic] [default] 
\stoptypescript 

\def\ArabicGlobalDir {\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT}
\def\ArabicParDir    {\textdir TRT\pardir TRT}
\def\ArabicTextDir   {\textdir TRT}

\define\setarabic
  {\ArabicGlobalDir%
   \usetypescript[Arabic]%
   \setupbodyfont[Arabic,20pt]}

\definestartstop
  [arabicpar]
  [commands=\Arabic\ArabicParDir]

\define[1]\RT
  {{\Arabic\ArabicTextDir#1}}

\pagedir TRT
\bodydir TRT
\pardir TRT
\textdir TRT

\setuppapersize[A4]

\setuplayout[
  grid=min,
  backspace=55.999mm, width=130mm,
  topspace=39.666mm, height=210mm,
  header=12mm, footer=9mm,
  ]

\setupbodyfont[Arabic,24pt]
\setupinterlinespace[line=42pt]

\setupheads[number=no]
\setuphead[chapter][style=\bfd,before=,after=\blank,alternative=middle,grid=both]
\setuphead[section][style=\bfc,before=\blank,after=,grid=both]

\setupbackgrounds[header][text][frame=off, bottomframe=on]

\setupheadertexts
        [{\getmarking[chapter]}]    [{\ArabicTextDir صفحة}]
        [{صفحة }]        [{\getmarking[chapter]}]

\setupinmargin[stack=yes]

\starttext

\chapter{\ArabicTextDir الآجرومية}

\margintext{الآجرومية}

الحمد لله رب العالمين، وصلى الله وسلم وبارك على عبده ورسوله نبينا محمد وعلى آله وصحبه أجمعين، أما بعد:
فلا يخفى على من له أدنى عناية بالعلم الشرعي لا سيما ما يتعلق بالكتاب العزيز والسنة النبوية لا يخفى عليه أهمية معرفة اللغة العربية بفنونها العشرة أو الإثني عشر: 

\stoptext

Output

enter image description here

  • Your solution works as well. I found a shorter version from ConTeXt mailing list. – Ibn Saeed Jan 18 '16 at 18:15
1

I found the following solution from ConTeXt Mailing List answered by Hans.

\setupmargindata[margintext]
[align=r2l]

\setupalign[r2l]  

\setupheader[style=\righttoleft, state=normal]

The above solution works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.