Changes

Jump to navigation Jump to search
2,994 bytes added ,  16:57, 16 December 2017
Hebrew addition
[[Arabic fonts]] >
 
{{todo|overview page for the use of middle-eastern scripts}}
== Examples Arabic ==
== This is an example environment for typesetting Arabic ==documents in Mark IV (ConTeXt with LuaTeX). It won't work at all in Mark II (with either pdfTeX or XeTeX).
This is an example style file for typesetting Arabic documentsSave it as "ara-sty.tex" and use "\environment ara-sty" in your document.
<texcode>
% engine=luatex\startenvironment ara-sty 
\mainlanguage[arabic]
% Fontsetup 
\definefontfeature
[arabic]
\definefontsynonym [Arabic-Italic] [name:arabtype] [features=arabic]
\definefontsynonym [Arabic-Bold-Italic] [name:arabtype] [features=arabic]
\stoptypescript
\starttypescript [serif] [arabic] [name]
\def\LatinTextDir {\textdir TLT}
\def\LatinGlobalDir {\pagedir TLT\bodydir TLT\pardir TLT\textdir TLT}
 
\define\setarabic
{\ArabicGlobalDir%
\usetypescript[Arabic]%
\setupbodyfont[Arabic,20pt]}
\definestartstop
[commands=\Arabic\ArabicParDir]
\define[1]\ARRT
{{\Arabic\ArabicTextDir#1}}
\define\setArabicsetlatin {\LatinGlobalDir% \usetypescript[lm]% \setupbodyfont[lm,20pt]} \definestartstop [latinpar] [commands=\Arabic\LatinParDir] \define[1]\LT {{\LatinTextDir#1}} \setcharactermirroring[1] \stopenvironment</texcode> === Description === Here is some description: <texcode>\mainlanguage[arabic]</texcode> Sets the main language to Arabic, so that translatable titles are translated to Arabic. <texcode>\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]</texcode> Here we define OpenType font features needed to render Arabic properly. <texcode>\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 </texcode> Then, we define "Arabic" typescript, here we used a font named "arabtype". Since this font has only regular weight, we set bold and italic to use the same font. <texcode>\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}</texcode> Here we define some directional commands to use it in the next parts. <texcode>\define\setarabic
{\ArabicGlobalDir%
\usetypescript[Arabic]%
\setupbodyfont[Arabic,20pt]}
 
\definestartstop
[arabicpar]
[commands=\Arabic\ArabicParDir]
 
\define[1]\RT
{{\Arabic\ArabicTextDir#1}}
 
</texcode>
 
Here we define "arabicpar" environment for Arabic paragraphs in Latin context, and "\RT" for short Arabic sentences and "\setarabic" command to set the main document direction and font to Arabic.
 
<texcode>
\define\setlatin
{\LatinGlobalDir%
\usetypescript[lm]%
\setupbodyfont[lm,20pt]}
\definestartstop
\define[1]\LT
{{\LatinTextDir#1}}
</texcode>
The counter Latine commands, "latinpar", "\define\setLatin {\LatinGlobalDir% LT" and "\usetypescript[lm]% \setupbodyfont[lm,20pt]}setlatin".
<texcode>
\setcharactermirroring[1]
</texcode>
To enable mirroring of BiDi mirrored characters, like () and []. This also enables "implicit bidi", so that you don't need to explicitly specify the direction of individual Arabic sentences inside Latin context in vise versa. === arabic.tex Using it ===
To use Now, lets try 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' ."Hello World" example:
<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]environment ara-sty
% ScheherazadeRegOT is the font file name (without extension) replace it with your preferred font \starttext\font\Arab = ScheherazadeRegOT*arabsetarabic
أهلا بالعالم!\hoffset=0ptstoptext</texcode>
% For inner paragraph control within an LR paragraph== Hebrew ==
\definestartstop [arabictext] [commands=% {\textdir TRT% \Arab}](Example by Rik Kabel on the mailing list, 2017-12-15)
\def\ArabicText#1{\startarabictext#1\stoparabictext}Depending on the font, correct niqqud placement requires some combination (sometimes all) of the following font features: lang, ccmp, and script.
% For global Arabic <texcode>\definefontfeature [hebrew] [oldstyle] [ lang=heb, ccmp=yes, script=hebr,]\starttext\definedfont[name:EzraSIL*hebrew at 72pt]\setupalign[r2l]טְרוֹפוֹתִי\stoptext</texcode>
\def\ArabicDirGlobal{%\pagedir TRT\bodydir TRT\textdir TRT\pardir TRT}The same settings work well for Narkisim. For David_CLM you only need the script setting.
\def\Arabic{\ArabicDirGlobal\Arab}Correction by Hans, 2017-12-16:
% For separate Arabic-script paragraphsThere is a font feature hebrew already predefined
<texcode>\def\ArabicDirPar{\textdir TRT\pardir TRT}definefontfeature [hebrewoldstyle] [oldstyle] [...]</texcode>
\definestartstop [arab] [commands=% {\Arab% \ArabicDirPar}]if you have to set a language depends on the font (often dflt is ok).
\showframe[text]This is the predefined set:
<texcode>\starttextdefinefontfeature [semitic-complete] [mode=node,analyze=yes,language=dflt,ccmp=yes, autoscript=position,autolanguage=position, init=yes,medi=yes,fina=yes,isol=yes, mark=yes,mkmk=yes,kern=yes,curs=yes, liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes]
\startarabdefinefontfeature [semitic-simple] [mode=node,analyze=yes,language=dflt,ccmp=yes, autoscript=position,autolanguage=position, init=yes,medi=yes,fina=yes,isol=yes, mark=yes,mkmk=yes,kern=yes,curs=yes, rlig=yes,calt=yes]
اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ وَ\definefontfeatureآلِ مُحَمَّدٍ وَ ارْزُقْنِي [arabic]الْيَقِينَ وَ حُسْنَ الظَّنِّ بِكَ [semitic-complete]وَ أَثْبِتْ رَجَاءَكَ فِي قَلْبِيوَ اقْطَعْ رَجَائِي عَمَّنْ سِوَاكَحَتَّى لَا أَرْجُوَ غَيْرَكَ وَ لَاأَثِقَ إِلَّا بِك‏ [script=arab]
\stoparabdefinefontfeature [syriac] [arabic] [fin2=yes,fin3=yes,med2=yes]
\blankdefinefontfeature [hebrew] [semitic-complete] [script=hebr]
Here is some mixed {\em Arabic-} (\ArabicText{عربي}) anddefinefontfeatureLatin-script. As you can see, Aleph does a very good job mixing{\em LR} (\ArabicText{يسار-يمين}) and {\em RL} [simplearabic](\ArabicText{يمين [semitic-يسار}) texts. \ArabicText{وsimple]هنا جملة منقطعة في وسط قرينةلاتينية}. Aleph even does a great job breaking Arabicphrases across lines. [script=arab]
\stoptextdefinefontfeature [simplehebrew] [semitic-simple] [script=hebr]
</texcode>
 
[[Category:International]]
[[Category:Fonts]]

Navigation menu