1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
%D \module
%D [ file=m-arabtex, % was font-arb,
%D version=2003.02.22, % 1999.11.06,
%D title=\CONTEXT\ Modules,
%D subtitle=Arabic,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
% I still need to hook in some features into the setup
% macro. I also have to (re)define farsi etc. in ways
% similar to arab, so that we have dedicated environments.
%
% keywords needed: vocalize transscribe
%
% \startarabic[option=vocalize] % or vocalize=yes
% ......
% \stoparabic
\writestatus{loading}{Context Font Macros / ArabTeX support}
%D At the \NTG\ 10\high{th} anniversary meeting Klaus Lagally
%D introduced the audience to arabic typesetting, and after
%D that I knew that some day I really had to look into his
%D generic package. And then, sort of simultaniously Maarten
%D Wisse and Imran Ahsan Nyazee asked me if \CONTEXT\ could
%D support \ARABTEX, a package that provides right to left
%D typesetting of (several variants of) arab and hebrew.
%D Having implemented support for chinese a few weeks before,
%D I could not resist to build in support for arab and hebrew
%D too. Writing support for languages that don't give me any
%D cue on how to pronounce their script, is kind of special.
%D This is a beta version, since I still have to take care of some
%D macros that conflict with existing stuff.
\unprotect
\definesystemvariable{ARABTEX}
\def\setupARABTEX
{\getparameters[\??ARABTEX]}
\setupARABTEX
[\s!rscale=1.2,
\c!before=,
\c!after=,
\c!inner=\setarab,
\c!style=\setarabicfont\fontstylesuffix]
%D A few (maybe too) simple hooks into the font mechanism. The
%D hook into the language module is not yet done.
% \unexpanded\def\setarabicfont#1% rscale
% {\scratchdimen\@@ARABTEXrscale\bodyfontsize
% \font\arbfont\truefontname{Arabic#1} at \currentfontscale\scratchdimen
% \setx@skels
% \newfonttrue
% \arbfont}
%
% more modern
%
% \unexpanded\def\setarabicfont#1% rscale
% {\definefont[arbfont][Arabic#1 sa \@@ARABTEXrscale]%
% \setx@skels
% \newfonttrue
% \arbfont}
%
% more efficient
\unexpanded\def\setarabicfont#1%
{\setx@skels
\newfonttrue
\definedfont[Arabic#1 sa \ARABTEXparameter\s!rscale]}
%D Just to be compatible with Arab\TEX\ we define:
\unexpanded\def\nash {\setarabicfont\s!Regular}
\unexpanded\def\nashbf {\setarabicfont\s!Bold }
\unexpanded\def\pnash {\setarabicfont\s!Regular}
\unexpanded\def\pnashbf{\setarabicfont\s!Bold }
\unexpanded\def\xnash {\setarabicfont\s!Regular}
\unexpanded\def\xnashbf{\setarabicfont\s!Bold }
%D The display arabic environment (will be an installable
%D object) uses a few conditionals. Let's do it the
%D \CONTEXT\ way and define an anvironment that we later can
%D adapt.
\newif\if@ignore
\newif\if@endpe
\def\setupARABTEXalternative[#1]%
{\dodoubleempty\getparameters[\??ARABTEX#1]}
\def\defineARABTEXalternative
{\dodoubleempty\dodefineARABTEXalternative}
\def\dodefineARABTEXalternative[#1][#2]%
{\iffirstargument % \startarab is defined but used already
\getparameters
[\??ARABTEX#1]
[\c!before=\@@ARABTEXbefore,
\c!after=\@@ARABTEXafter,
\c!inner=\@@ARABTEXinner,
\c!style=\@@ARABTEXstyle,
\s!rscale=\@@ARABTEXrscale,
#2]%
\setvalue {\e!start#1}{\displayARABTEXalternative{#1}}%
\unexpanded\setvalue{#1}{\inlineARABTEXalternative {#1}}%
\unexpanded\def\RL{\getvalue{#1}}%
\unexpanded\def\LR{\a@LR}%
\let\R=\RL
\let\L=\LR
\expandafter\all@wcmd\csname\e!stop#1\endcsname
\else
\defineARABTEXalternative[arabic]%
\fi}
\def\initializeARABTEXinternals
{\ARABTEXparameter\c!inner
\the\everyARABTEXpreset}
\newtoks \everyARABTEXpreset
\let\currentARABTEXalternative\empty
\def\ARABTEXparameter#1%
{\csname\??ARABTEX\currentARABTEXalternative#1\endcsname}
\def\inlineARABTEXalternative#1#2%
{\bgroup
\edef\currentARABTEXalternative{#1}%
\initializeARABTEXinternals
\a@RL{#2}%
\egroup}
\def\displayARABTEXalternative#1%
{\dodoubleempty\dostartARABTEXalternative[#1]}
\def\dostartARABTEXalternative[#1][#2]%
{\begingroup
\edef\currentARABTEXalternative{#1}%
\getparameters[\??ARABTEX\currentARABTEXalternative][#2]%
\ifnum1<0\ARABTEXparameter\c!n\relax
\startcolumns
\else
\ARABTEXparameter\c!before
\fi
\initializeARABTEXinternals
\initializeARABTEXend
\arabtext
\initializeARABTEXalternative}
\def\initializeARABTEXalternative
{\ARABTEXparameter\c!style}
\def\initializeARABTEXend% \CONTEXT\ does use \end quite differently
{\long\def\end##1%
{\endarabtext
\ifnum1<0\ARABTEXparameter\c!n\relax
\stopcolumns
\else
\ARABTEXparameter\c!after
\fi
\endgroup}%
\let\a@l@end\end
\letvalue{\e!stop\currentARABTEXalternative}=\end
\long\def\end##1%
{\endarabtext
\endgroup
\if@ignore\global\@ignorefalse\expandafter\ignorespaces\fi}}
%D Arabic verbatim.
\def\typearab{\a@@verb}
%D Some \LATEX\ macros.
\def \makeatletter{\unprotect}
\def \makeatother {\protect}
\def \typeout {\writestatus{arabtex}}
%D We have to save some macros.
\let\ARABTEXversion=\empty
\def\startloadingARABTEX% ugly hacks
{\catcode`!=12
\catcode`?=12
\pushmacro\output \let \output \scratchtoks
\pushmacro\LaTeX \let \LaTeX \undefined
\pushmacro\CJK \let \CJK \undefined
% \pushmacro\peek@token \let \peek@token \undefined
% \pushmacro\edmacloaded \let \edmacloaded \undefined
\pushmacro\year \let \year \normalyear
\pushmacro\month \let \month \normalmonth
\pushmacro\day \let \day \normalday
\pushmacro\input \def \input ##1 {\normalinput ##1 }
\pushmacro\linewidth
\pushmacro\datum \def\datum {\toks0}
\pushmacro\version \def\version {\toks2}
\pushmacro\theversion \let\theversion \ARABTEXversion
\pushmacro\emphasize
\pushmacro\cap}
\def\stoploadingARABTEX
{\catcode`!=11
\catcode`?=11
\popmacro\cap
\popmacro\emphasize
\popmacro\theversion
\popmacro\version
\popmacro\datum
\popmacro\linewidth
\popmacro\input
\popmacro\day
\popmacro\month
\popmacro\year
% \popmacro\edmacloaded
% \popmacro\peek@token
\popmacro\CJK
\popmacro\LaTeX
\popmacro\output}
%D We save some macros:
\startloadingARABTEX
%D When loading \ARABTEX\ we have to set back the~! and~?.
\input arabtex.sty
%D Since \ARABTEX\ has its own \type {\cap}, we save the
%D new meaning. We also redefine some \PLAIN\ macros, which
%D happen to have a different meaning in \LATEX.
\let\ARABTEXversion\theversion
\let\ARABTEXcap \cap
\appendtoks
\let\cap\ARABTEXcap
\to \everyARABTEXpreset
\def\ARABTEXsh@ft#1%
{\dimen@.00#1ex
\multiply\dimen@\slantperpoint
\kern-.0156\dimen@}
\appendtoks
\let\sh@ft\ARABTEXsh@ft
\to \everyARABTEXpreset
\def\ARABTEXd#1%
{{\o@lign{\relax#1\crcr\hidewidth\sh@ft{10}%
.\hidewidth}}}
\def\ARABTEXb#1%
{{\o@lign{\relax#1\crcr\hidewidth\sh@ft{29}%
\vbox to.2ex{\hbox{\char22}\vss}\hidewidth}}}
\appendtoks
\let\b\ARABTEXb
\let\d\ARABTEXd
\to \everyARABTEXpreset
\def \ARABTEXbreakA {\hfill\break}
\def \ARABTEXbreakB {\break}
\edef\ARABTEXbar {\string|}
\def \ARABTEXcomma {\relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
\appendtoks
\let\\=\ARABTEXbreakA
\let\|=\ARABTEXbreakB
\let |=\ARABTEXbar
\let\,=\ARABTEXcomma
\to \everyARABTEXpreset
\let\ARABTEXprotect\relax
\appendtoks
\let\protect\ARABTEXprotect
\to \everyARABTEXpreset
%D Now we can pop the saved macros.
\stoploadingARABTEX
%D Ah, we have to get rid of some \type {\protect} stuff but
%D to permit testing we add it in the \CONTEXT\ way.
% \bgroup
% \catcode`\<=\@other
% \unexpanded\gdef\a@ins
% {\ifmmode
% \expandafter<%
% \else
% \dontleavehmode \bgroup
% \arab@codes \set@arabfont \@waslafalse \@wasfalse
% \expandafter\arab@insert
% \fi}
% \unexpanded\gdef\<{\a@ins}
% \catcode`\<=\active
% \global\let<=\a@ins
% \egroup
%
% cleaner:
\defineactivecharacter < {\a@ins} \unexpanded\gdef\<{\a@ins}%
\def\normal@a@ins
{\dontleavehmode % context prefers this instead of \leavevmode
\bgroup
\arab@codes
\set@arabfont
\@waslafalse
\@wasfalse
\arab@insert}
\unexpanded\gdef\a@ins
{\mathortext<\normal@a@ins}
%D We also need to register a few macros:
\all@wcmd\initializeARABTEXalternative % no argument, internal command
\all@wcmd\tx % no argument, small font
\all@wcmd\txx % no argument, smaller font
%D We also hook it into the presetter.
\appendtoks
\let\normaltx \tx \def\tx {\normaltx \setarabicfont\fontstylesuffix}%
\let\normaltxx\txx\def\txx{\normaltxx\setarabicfont\fontstylesuffix}%
\to \everyARABTEXpreset
%D The main definitions are:
\definefontsynonym [ArabicRegular] [xnsh14]
\definefontsynonym [ArabicBold] [xnsh14bf]
\defineARABTEXalternative
[arabic]
[\c!inner=\setarab,
\c!style=\setarabicfont\fontstylesuffix]
\defineARABTEXalternative
[farsi]
[\c!inner=\setfarsi,
\c!style=\setarabicfont\fontstylesuffix]
\defineARABTEXalternative
[urdu]
[\c!inner=\seturdu,
\c!style=\setarabicfont\fontstylesuffix]
\defineARABTEXalternative
[maghribi]
[\c!inner=\setmaghribi,
\c!style=\setarabicfont\fontstylesuffix]
%D Apart from such definitions, one can adapt the settings
%D using \type {\setupARABTEXalternative}.
%D
%D A few years ago at the Holland Festivities, I attended {\em
%D The Cave}, one of the most impressive combinations of music
%D and video I know. This composition of Steve Reich (music)
%D and .. (video) concentrates on the common grounds of arabs
%D and jews: their ancestor Abram. Listening to the \CDROM's
%D of {\em The Cave}, provided me the right ambiance for
%D filling in the details of this module. In {\em The Cave},
%D interviews, music, and |<|believe it or not|>| rhythmic
%D typography are the cornerstones. Remembering those big
%D screens, it strikes me that like music, \TEX\ too is a
%D perfect instrument to cross cultural and linguistic
%D borders. So, let's load Hebrew support as well:
\unexpanded\def\sethebrewfont#1%
{\setx@skels
\newfonttrue
\definedfont[Hebrew#1 sa \ARABTEXparameter\s!rscale]}
% \let \setheb \sethebrew
\unexpanded\def\pheb {\sethebrewfont\s!Regular}
\unexpanded\def\phebbf{\sethebrewfont\s!Bold}
% \startloadingARABTEX
% \ReadFile{hebtex.sty}
% \ReadFile{apatch.sty}
% \ReadFile{hepatch.sty}
% \stoploadingARABTEX
\definefontsynonym [HebrewRegular] [hclassic]
\definefontsynonym [HebrewBold] [hcaption]
\defineARABTEXalternative
[hebrew]
[\c!inner=\sethebrew,
\c!style=\sethebrewfont\fontstylesuffix]
%D Now we're done:
\protect \endinput
% everyoutput : \charsubdefmax \arab@charsubdefmax
% \defineconversion [abjad] [\abj@d]
%
% voetnoten verbatim lijsten indexen tabellen uitlijnen
%
% \v!hoofdstuk=al-fa.slu
% \v!inhoud=al-mu.htawayAtu
% \v!figuren=qA'imaTu al-.suwaru
% \v!tabellen=qA'imaTu al-^gadAwilu
% \v!grafieken=qA'imaTu al-rusUmu
% \v!index=al-fihrisu
% \v!bijlage=al-mul.haqu
% \usemodule[arabtex]
%
% \usetypescript[postscript] \switchtotypeface[postscript]
%
% \setarab \novocalize
%
% \starttext
%
% \placecontent
%
% \section{\<mu.hammad>} % short arabic use \< .. >
% \section{\<mu.hammad>} % short arabic use \< .. >
%
% \startarabic
% mu.hammad 'i_d q"aAm zay"d" + i_d yaqUm zyd + A_d zyd q"aAm
%
% mu.hammad 'i_d q"aAm zay"d" + i_d yaqUm zyd + A_d zyd q"aAm
% \stoparabic
%
% \section{\<al-maq.sad>}
%
% \startarabic
% mu.hammad 'i_d q"aAm zay"d" + i_d yaqUm zyd + A_d zyd q"aAm
% \stoparabic
%
% \stoptext
|