Difference between revisions of "Arabic and Hebrew"

From Wiki
Jump to navigation Jump to search
Line 70: Line 70:
  
 
\setcharactermirroring[1]
 
\setcharactermirroring[1]
</texcode>
 
 
=== arabic.tex ===
 
 
To use a specific font just put it under the current directory where you run context, and replace ScheherazadeRegOT with your font file name. Then run 'context arabic.tex' .
 
 
<texcode>
 
% engine=luatex
 
 
% OpenType features needed for Arabic
 
\definefontfeature
 
  [arab]
 
  [mode=node,language=dflt,script=arab,
 
  init=yes,medi=yes,fina=yes,isol=yes,
 
  liga=yes,dlig=yes,rlig=yes,clig=yes,
 
  mark=yes,mkmk=yes,kern=yes,curs=yes]
 
 
% ScheherazadeRegOT is the font file name (without extension) replace it with your preferred font
 
\font\Arab = ScheherazadeRegOT*arab
 
 
\hoffset=0pt
 
 
% For inner paragraph control within an LR paragraph
 
 
\definestartstop
 
  [arabictext]
 
  [commands=%
 
    {\textdir TRT%
 
    \Arab}]
 
 
\def\ArabicText#1{\startarabictext#1\stoparabictext}
 
 
% For global Arabic script
 
 
\def\ArabicDirGlobal{%
 
\pagedir TRT\bodydir TRT\textdir TRT\pardir TRT}
 
 
\def\Arabic{\ArabicDirGlobal\Arab}
 
 
% For separate Arabic-script paragraphs
 
 
\def\ArabicDirPar{\textdir TRT\pardir TRT}
 
 
\definestartstop
 
  [arab]
 
  [commands=%
 
    {\Arab%
 
    \ArabicDirPar}]
 
 
\showframe[text]
 
 
\starttext
 
 
\startarab
 
 
اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ وَ
 
آلِ مُحَمَّدٍ وَ ارْزُقْنِي
 
الْيَقِينَ وَ حُسْنَ الظَّنِّ بِكَ
 
وَ أَثْبِتْ رَجَاءَكَ فِي قَلْبِي
 
وَ اقْطَعْ رَجَائِي عَمَّنْ سِوَاكَ
 
حَتَّى لَا أَرْجُوَ غَيْرَكَ وَ لَا
 
أَثِقَ إِلَّا بِك‏
 
 
\stoparab
 
 
\blank
 
 
Here is some mixed {\em Arabic-} (\ArabicText{عربي}) and
 
Latin-script. As you can see, Aleph does a very good job mixing
 
{\em LR} (\ArabicText{يسار-يمين}) and {\em RL}
 
(\ArabicText{يمين-يسار}) texts. \ArabicText{و
 
هنا جملة منقطعة في وسط قرينة
 
لاتينية}. Aleph even does a great job breaking Arabic
 
phrases across lines.
 
 
\stoptext
 
 
</texcode>
 
</texcode>

Revision as of 18:18, 28 June 2008


TODO: overview page for the use of middle-eastern scripts (See: To-Do List)


Examples

Arabic

This is an example style file for typesetting Arabic documents.

% engine=luatex
\mainlanguage[arabic]

% Font
\definefontfeature
   [arabic]
   [mode=node,language=dflt,script=arab,
    init=yes,medi=yes,fina=yes,isol=yes,
    liga=yes,dlig=yes,rlig=yes,clig=yes,
    mark=yes,mkmk=yes,kern=yes,curs=yes]

\starttypescript [serif] [arabic]
 \definefontsynonym [Arabic-Light]       [name:arabtype] [features=arabic]
 \definefontsynonym [Arabic-Bold]        [name:arabtype] [features=arabic]
 \definefontsynonym [Arabic-Italic]      [name:arabtype] [features=arabic]
 \definefontsynonym [Arabic-Bold-Italic] [name:arabtype] [features=arabic]
 \stoptypescript

\starttypescript [serif] [arabic] [name]
 \usetypescript[serif][fallback]
 \definefontsynonym [Serif]           [Arabic-Light]       [features=arabic]
 \definefontsynonym [SerifItalic]     [Arabic-Italic]      [features=arabic]
 \definefontsynonym [SerifBold]       [Arabic-Bold]        [features=arabic]
 \definefontsynonym [SerifBoldItalic] [Arabic-Bold-Italic] [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}
\def\LatinParDir     {\textdir TLT\pardir TLT}
\def\LatinTextDir    {\textdir TLT}
\def\LatinGlobalDir  {\pagedir TLT\bodydir TLT\pardir TLT\textdir TLT}

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

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

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

\definestartstop
  [latinpar]
  [commands=\Arabic\LatinParDir]

\define[1]\LT
  {{\LatinTextDir#1}}

\define\setLatin
  {\LatinGlobalDir%
   \usetypescript[lm]%
   \setupbodyfont[lm,20pt]}

\setcharactermirroring[1]