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
|
%%
%% This is file `kashida-xepersian-hm.def'
%%
%% Copyright (c) Hossein Movahhedian 2020
%%
%% It may be distributed and/or modified under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
%% Copyright notice: the following code is partly adapted from the code in
%% 'kashida-xepersian.def' from xepersian package (v22.8).
\ExplSyntaxOn
\ProvidesExplFile {kashida-xepersian.def} {2018/01/04} {0.1} { Fixes~implementation~of~Kashida~in~xepersian~package }
\int_const:Nn \c_xepersian_zwj_int {"200D} % zero-width joiner
\int_const:Nn \c_xepersian_lrm_int {"200E} % left-right-mark
\int_const:Nn \c_xepersian_two_int {2} % 2
\int_const:Nn \c_xepersian_four_int {4} % 4
\int_const:Nn \c_xepersian_ksh_int {"0640} % kashida
\int_const:Nn \c_xepersian_d_int {10} % dual-joiner class
\int_const:Nn \c_xepersian_l_int {11} % lam
\int_const:Nn \c_xepersian_r_int {12} % right-joiner
\int_const:Nn \c_xepersian_a_int {13} % alef
\int_const:Nn \c_xepersian_h_int {14} % heh
\int_const:Nn \c_xepersian_y_int {15} % yeh
\int_const:Nn \c_xepersian_v_int {4096} % vowel or other combining mark (to be ignored)
\bool_new:N \l_kashida_on_bool
\bool_new:N \l_kashida_hm_fix_bool
\bool_new:N \l_kashida_xb_fix_bool
\tl_new:N \l_hskip_zero_tl
\tl_new:N \l_hskip_default_tl
\cs_new:Npn \xepersian_kashida #1
{
\bool_if:NT \l_kashida_on_bool
{
\c_xepersian_lrm_int\c_xepersian_zwj_int\tex_penalty:D 10000
\tex_leaders:D \tex_hrule:D height \XeTeXglyphbounds \c_xepersian_two_int
\int_use:N \XeTeXcharglyph \c_xepersian_ksh_int depth \XeTeXglyphbounds \c_xepersian_four_int
\int_use:N \XeTeXcharglyph \c_xepersian_ksh_int \skip_horizontal:n { #1 }
\c_xepersian_zwj_int
}
}
\XeTeXinterchartokenstate = 1
\clist_set:Nn \l_xepersian_a_clist { 0622,0623,0625,0627 } % ا، إ، أ، آ
\clist_map_inline:Nn \l_xepersian_a_clist
{
\XeTeXcharclass "#1 \c_xepersian_a_int
}
\clist_set:Nn \l_xepersian_d_clist { 0626,0628,062A,062B,062C,062D,062E,0633,0634,0635,0636,0637,0638,0639,063A,0640,0641,0642,0643,0645,0646,0647,067E,0686,06A9,06AF } % ئ,ب,ت,ث,ج,ح,خ,س,ش,ص,ض,ط,ظ,ع,غ,ـ,ف,ق,ك,م,ن,ه,پ,چ,ک,گ
\clist_map_inline:Nn \l_xepersian_d_clist
{
\XeTeXcharclass "#1 \c_xepersian_d_int
}
\clist_set:Nn \l_xepersian_l_clist { 0644 } % ل
\clist_map_inline:Nn \l_xepersian_l_clist
{
\XeTeXcharclass "#1 \c_xepersian_l_int
}
\clist_set:Nn \l_xepersian_r_clist { 0624,0629,062F,0630,0631,0632,0648,0698 } % ؤ,ة,د,ذ,ر,ز,و,ژ
\clist_map_inline:Nn \l_xepersian_r_clist
{
\XeTeXcharclass "#1 \c_xepersian_r_int
}
\clist_set:Nn \l_xepersian_v_clist { 064B,064C,064D,064E,064F,0650,0651,0652 } % ً,ٌ,ٍ,َ,ُ,ِ,ّ,ْ
\clist_map_inline:Nn \l_xepersian_v_clist
{
\XeTeXcharclass "#1 \c_xepersian_v_int
}
\clist_set:Nn \l_xepersian_y_clist { 0649,064A,06CC }
\clist_map_inline:Nn \l_xepersian_y_clist
{
\XeTeXcharclass "#1 \c_xepersian_y_int
}
\XeTeXinterchartoks \c_xepersian_y_int \c_xepersian_y_int = {\bool_if:NTF \l_kashida_hm_fix_bool {\xepersian_kashida {\l_hskip_default_tl}} {\xepersian_kashida \l_hskip_zero_tl}}
\XeTeXinterchartoks \c_xepersian_d_int \c_xepersian_y_int = {\bool_if:NTF \l_kashida_hm_fix_bool {\xepersian_kashida {\l_hskip_default_tl}} {\xepersian_kashida \l_hskip_zero_tl}}
\XeTeXinterchartoks \c_xepersian_y_int \c_xepersian_d_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_d_int \c_xepersian_d_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_l_int \c_xepersian_d_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_d_int \c_xepersian_l_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_l_int \c_xepersian_l_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_d_int \c_xepersian_r_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_d_int \c_xepersian_a_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_l_int \c_xepersian_r_int = {\xepersian_kashida \l_hskip_zero_tl}
\XeTeXinterchartoks \c_xepersian_l_int \c_xepersian_a_int = {}
\NewDocumentCommand \KashidaOn {} { \bool_set_true:N \l_kashida_on_bool }
\NewDocumentCommand \KashidaOff {} { \bool_set_false:N \l_kashida_on_bool }
\NewDocumentCommand \KashidaXBFixOn {} { \bool_set_true:N \l_kashida_xb_fix_bool }
\NewDocumentCommand \KashidaXBFixOff {} { \bool_set_false:N \l_kashida_xb_fix_bool }
\NewDocumentCommand \KashidaHMFixOn {} { \bool_set_true:N \l_kashida_hm_fix_bool }
\NewDocumentCommand \KashidaHMFixOff {} { \bool_set_false:N \l_kashida_hm_fix_bool }
\ExplSyntaxOff
\makeatletter
\newif\if@Kashida@on
\newif\if@Kashida@XB@fix
\makeatother
\ExplSyntaxOn
\KashidaHMFixOn
\tl_set:Nn \l_hskip_zero_tl { 0 em plus 0.5 em }
\bool_if:NTF \l_kashida_hm_fix_bool
{
\tl_if_empty:NT \l_hskip_default_tl { \tl_set:Nn \l_hskip_default_tl { 0.14 em plus 0.5 em } }
}
{
\tl_set:NV \l_hskip_default_tl \l_hskip_zero_tl
}
\KashidaOn
\ExplSyntaxOff
\endinput
%%
%% END OF FILE
%%
|