diff options
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def | 100 |
1 files changed, 64 insertions, 36 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def b/Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def index ea91b088773..da06b603b86 100644 --- a/Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def +++ b/Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def @@ -13,7 +13,7 @@ %% this license is at: http://www.latex-project.org/lppl.txt %% \ExplSyntaxOn -\ProvidesExplFile {kashida-xepersian-hm.def} {2020-05-07} {0.5d} { Fixes~implementation~of~Kashida~in~xepersian~package } +\ProvidesExplFile {kashida-xepersian-hm.def} {2020-05-12} {0.5e} { Fixes~implementation~of~Kashida~in~xepersian~package } \newXeTeXintercharclass \c_xephm_d_charclass % dual-joiner class \newXeTeXintercharclass \c_xephm_l_charclass % lam @@ -21,44 +21,72 @@ \newXeTeXintercharclass \c_xephm_a_charclass % alef \newXeTeXintercharclass \c_xephm_y_charclass % yeh -%% Partly adapted from LaTeX2e source -\cs_new:Nn \xephm_line_break: { - \if_mode_vertical: - \GenericError{ - \space\space\space\space\space\space\space\space\space\space\space\space\space\space\space - }{ - LaTeX Error: There’s no line here to end - }{ - See the LaTeX manual or LaTeX Companion for explanation. - }{ - Your command was ignored.\MessageBreak - Type \space I <command> <return> \space to replace it~ - with another command,\MessageBreak - or \space <return> \space to continue without it.} - \else: - \l_tmpa_skip \tex_lastskip:D - \tex_unskip:D - \tex_penalty:D -\l_xephm_line_break_penalty_int - \dim_compare:nT { \l_tmpa_skip > \c_zero_skip } - { \skip_horizontal:N \l_tmpa_skip \tex_ignorespaces:D } - \fi: +\bool_if:NT \l_xephm_ligature_bool +{ + \clist_new:N \l_xephm_ligatures_clist + \int_new:N \l_xephm_lig_names_len_int + \int_set:Nn \l_xephm_lig_names_len_int { \clist_count:N \l_xephm_lig_names_clist } + \int_step_inline:nnnn { 1 } { 2 } { \l_xephm_lig_names_len_int } + { + \int_set:Nn \l_tmpa_int { #1 } + \int_set:Nn \l_tmpb_int { \int_eval:n { \l_tmpa_int + 1 } } + \tl_set:Nf \l_tmpa_tl { \clist_item:Nn \l_xephm_lig_names_clist { \l_tmpa_int } } + \clist_set:Nx \l_tmpa_clist { { \clist_item:Nn \l_xephm_lig_names_clist { \l_tmpb_int } } } + \bool_if:nT { \tl_if_eq_p:NN \l_xephm_active_ligs_tl \l_tmpa_tl || \tl_if_eq_p:NN \l_xephm_active_ligs_tl \l_xephm_lig_default_tl } + { + \clist_put_left:Nx \l_xephm_ligatures_clist { \l_tmpa_clist } + } + } + \clist_map_inline:Nn \l_xephm_ligatures_clist + { + \seq_set_split:Nnn \l_tmpa_seq { = } { #1 } + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl { } { } + \seq_pop_left:NN \l_tmpa_seq \l_tmpb_tl { } { } + \tl_const:cx { \tl_use:N \l_tmpb_tl } { \char"\l_tmpa_tl \ } + } } -\NewDocumentCommand { \discouragebadlinebreaks } { O{\l_xephm_line_break_penalty_int} O{\c_xephm_skip_b_tl} m } - { - \IfNoValueF {#1} - { \int_set:Nn \l_xephm_line_break_penalty_int {#1} } - \IfNoValueF {#2} - { \tl_set:Nn \l_xephm_skip_default_tl {#2} } - \xephm_put_line_breaks:n { #3 } - } +\bool_if:NT \l_xephm_linebreakpenalty_bool +{ + %% Partly adapted from LaTeX2e source + \cs_new:Nn \xephm_line_break: { + \if_mode_vertical: + \GenericError{ + \space\space\space\space\space\space\space\space\space\space\space\space\space\space\space + }{ + LaTeX Error: There’s no line here to end + }{ + See the LaTeX manual or LaTeX Companion for explanation. + }{ + Your command was ignored.\MessageBreak + Type \space I <command> <return> \space to replace it~ + with another command,\MessageBreak + or \space <return> \space to continue without it.} + \else: + \l_tmpa_skip \tex_lastskip:D + \tex_unskip:D + \tex_penalty:D -\l_xephm_line_break_penalty_int + \dim_compare:nT { \l_tmpa_skip > \c_zero_skip } + { \skip_horizontal:N \l_tmpa_skip \tex_ignorespaces:D } + \fi: + } + + \NewDocumentCommand { \discouragebadlinebreaks } { O{\l_xephm_line_break_penalty_int} O{\c_xephm_skip_b_tl} m } + { + \IfNoValueF {#1} + { \int_set:Nn \l_xephm_line_break_penalty_int {#1} } + \IfNoValueF {#2} + { \tl_set:Nn \l_xephm_skip_default_tl {#2} } + \xephm_put_line_breaks:n { #3 } + } -\cs_new_protected:Nn \xephm_put_line_breaks:n - { - \tl_set:Nn \l_xephm_line_break_tl { #1 } - \regex_replace_all:nnN { ([ابپتثجحخچدذرزژسشعغصضفقطظکگلمنوهیـ])+ } { \ \0 \ \c{xephm_line_break:}\ } \l_xephm_line_break_tl - \tl_use:N \l_xephm_line_break_tl - } + \cs_new_protected:Nn \xephm_put_line_breaks:n + { + \tl_set:Nn \l_xephm_line_break_tl { #1 } + \regex_replace_all:nnN { ([ابپتثجحخچدذرزژسشعغصضفقطظکگلمنوهیـ])+ } { \ \0 \ \c{xephm_line_break:}\ } \l_xephm_line_break_tl + \tl_use:N \l_xephm_line_break_tl + } +} %% Partly adapted from the code provided by David Carlisle in: %% https://tex.stackexchange.com/questions/356709/how-to-know-the-width-and-fill-the-glue-space-between-two-characters-when-using/356721#356721 |