Difference between revisions of "Arabic and Hebrew"

From Wiki
Jump to navigation Jump to search
(Cleaned out. please use the sandbox (leftside toolbox) for experimentation)
(Adapted example from Aleph Guide)
Line 1: Line 1:
 
{{todo|overview page for the use of middle-eastern scripts}}
 
{{todo|overview page for the use of middle-eastern scripts}}
 +
 +
== Examples ==
 +
 +
=== 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 %
 +
\hoffset=-8.88cm} % compensate for a bug in \bodydir 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>

Revision as of 21:32, 13 June 2008


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


Examples

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' .

% 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 %
\hoffset=-8.88cm} % compensate for a bug in \bodydir 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