diff options
Diffstat (limited to 'Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx')
-rw-r--r-- | Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx | 206 |
1 files changed, 112 insertions, 94 deletions
diff --git a/Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx b/Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx index 582a05d6388..0daba1b3e04 100644 --- a/Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx +++ b/Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx @@ -67,7 +67,7 @@ make time to fix. % }^^A % } % -% \date{Released \quad 2020-05-20 \quad v0.5f} +% \date{Released \quad 2020-05-31 \quad v1.0a} % % \maketitle % @@ -96,7 +96,9 @@ make time to fix. \RequirePackage{zref-savepos}[2020-03-03] \RequirePackage{xepersian} \ExplSyntaxOn -\ProvidesExplPackage {xepersian-hm} {2020-05-20} {0.5f} { Fixes~issues~in~xepersian~package } +\ProvidesExplPackage {xepersian-hm} {2020-05-31} {1.0a} { Fixes~issues~in~xepersian~package } + +\box_new:N \l_xephm_ksh_box \int_const:Nn \c_xephm_ksh_int {"0640} % kashida \int_const:Nn \c_xephm_lrm_int {"200E} % left-right-mark @@ -125,6 +127,9 @@ make time to fix. \tl_new:N \l_xephm_main_font_full_tl \tl_new:N \l_xephm_main_font_name_tl +\tl_new:N \l_xephm_font_full_tl +\tl_new:N \l_xephm_font_name_tl + \tl_new:N \l_xephm_skip_default_tl \tl_new:N \l_xephm_active_ligs_tl @@ -144,7 +149,8 @@ make time to fix. \int_set:Nn \l_xephm_max_penalty_int { 10000 } \tl_set:Nn \l_xephm_stretch_glyph_tl { glyph } -\tl_set:Nn \l_xephm_stretch_hrule_tl { hrule } +\tl_set:Nn \l_xephm_stretch_leaders_glyph_tl { leaders+glyph } +\tl_set:Nn \l_xephm_stretch_leaders_hrule_tl { leaders+hrule } \tl_set:Nn \l_xephm_fnt_kayhan_tl { kayhan } \tl_set:Nn \l_xephm_fnt_kayhannavaar_tl { kayhannavaar } @@ -211,7 +217,7 @@ make time to fix. \msg_new:nnn { xepersian-hm } { error-kashida-character-is-not-available-in-the-main-font } { - Sorry,~ kashida~ character~ is~ not~ available~ in~ the~ main~ font~! + Sorry,~ kashida~ character~ is~ not~ available~ in~ the~ main~ font~#1! } \msg_new:nnn { xepersian-hm } { error-value-not-available-for-kashida-option } @@ -230,6 +236,16 @@ make time to fix. and~ is~ not~ regarded~ as~ stable. } +\msg_new:nnn { xepersian-hm } { hm-series-font-not-found } + { + Either~ the~ font~`#1'~ is~ not~ installed~ on~ your~ system~ or~ does~ not~ + belong~ to~ HM~Series~fonts.~ + Please~ note~ that~ the~ option~ `Kashida=leaders+glyph'~ is~ currently~ only~ + supported~ by~ HM~Series~fonts.~ + If~ you~ know~ of~ any~ other~ font~ that~ supports~ this~ option,~ please~ + let~ me~ know~ to~ add~ it~ to~ the~ list~ of~ corresponding~ fonts.~ + } + \keys_define:nn { xepersian-hm } { Kashida .code:n = @@ -239,7 +255,8 @@ make time to fix. { \l_xephm_stretch_glyph_tl { - \tl_set:Nn \l_xephm_gap_filler_tl { \l_xephm_stretch_glyph_tl } + \msg_warning:nnn { xepersian-hm } { warning-experimental-feature } { Kashida=glyph } + \tl_set:Nx \l_xephm_gap_filler_tl { \l_xephm_stretch_glyph_tl } \AtBeginDocument { \tl_set:Nx \l_xephm_main_font_full_tl { \tex_fontname:D \tex_the:D \tex_font:D } @@ -248,13 +265,17 @@ make time to fix. \int_set:Nn \l_xephm_kashida_slot_int { \xetex_charglyph:D \c_xephm_ksh_int } \int_compare:nT { \l_xephm_kashida_slot_int = \c_zero_int } { - \msg_error:nn { xepersian-hm } { error-kashida-character-is-not-available-in-the-main-font } + \msg_error:nnx { xepersian-hm } { error-kashida-character-is-not-available-in-the-main-font } { \l_xephm_main_font_name_tl } } } } - \l_xephm_stretch_hrule_tl + \l_xephm_stretch_leaders_glyph_tl + { + \tl_set:Nx \l_xephm_gap_filler_tl { \l_xephm_stretch_leaders_glyph_tl } + } + \l_xephm_stretch_leaders_hrule_tl { - \tl_set:Nn \l_xephm_gap_filler_tl { \l_xephm_stretch_hrule_tl } + \tl_set:Nx \l_xephm_gap_filler_tl { \l_xephm_stretch_leaders_hrule_tl } } } { } { \tl_set:Nx \l_xephm_gap_filler_tl { #1 } } \tl_if_empty:NT \l_xephm_gap_filler_tl { \msg_error:nn { xepersian-hm } { error-specify-value-for-kashida-option } } @@ -351,7 +372,7 @@ make time to fix. % \begin{macrocode} %<*kashida-xepersian-hm-def> \ExplSyntaxOn -\ProvidesExplFile {kashida-xepersian-hm.def} {2020-05-20} {0.5f} { Fixes~implementation~of~Kashida~in~xepersian~package } +\ProvidesExplFile {kashida-xepersian-hm.def} {2020-05-31} {1.0a} { Fixes~implementation~of~Kashida~in~xepersian~package } \newXeTeXintercharclass \c_xephm_d_charclass % dual-joiner class \newXeTeXintercharclass \c_xephm_l_charclass % lam @@ -473,24 +494,45 @@ make time to fix. } } -%% Partly adapted from the code provided by Jonathan Kew in: -%% https://tug.org/pipermail/xetex/2009-February/012307.html. -%% Somebody notified me that the code in 'kashida-xepersian.def' from xepersian -%% package is an exact copy of Jonathan Kew's code. Being unaware of this, in -%% the earlier versions of this package I made a mistake and acknowledged -%% Vafa Khalighi instead of Jonathan Kew. A sincere thank you to Jonathan Kew -%% for his excellent code. -\cs_new:Npn \xephm_kashida_hrule #1 - { - \bool_if:NT \l_xephm_kashida_hm_fix_bool +\cs_new:Npn \xephm_kashida_leaders #1 +{ + \bool_if:NT \l_xephm_kashida_hm_fix_bool { - \c_xephm_lrm_int\c_xephm_zwj_int\tex_penalty:D 10000 - \tex_leaders:D \tex_hrule:D height \XeTeXglyphbounds \c_xephm_two_int - \int_use:N \XeTeXcharglyph \c_xephm_ksh_int depth \XeTeXglyphbounds \c_xephm_four_int - \int_use:N \XeTeXcharglyph \c_xephm_ksh_int \skip_horizontal:n { #1 } - \c_xephm_zwj_int + \tl_if_eq:NNTF \l_xephm_gap_filler_tl \l_xephm_stretch_leaders_glyph_tl + { + \tl_set:Nx \l_xephm_font_full_tl { \tex_fontname:D \tex_the:D \tex_font:D } + \tl_set:Nx \l_xephm_font_name_tl { \l_xephm_font_full_tl } + \tl_set:Nx \l_xephm_font_init_tl { \l_xephm_font_name_tl } + \regex_replace_once:nnN { ^"\[?(HM)[\_\ ](X|F).* } { \1\2 } \l_xephm_font_init_tl\relax + \tl_set:Nn \l_tmpa_tl { HMF } + \tl_set:Nn \l_tmpb_tl { HMX } + \bool_if:nTF { \str_if_eq_p:NN { \l_xephm_font_init_tl } { \l_tmpa_tl } || \str_if_eq_p:NN { \l_xephm_font_init_tl } { \l_tmpb_tl } } + { + \hbox_set:Nn \l_xephm_ksh_box { \XeTeXglyph\XeTeXglyphindex"kashida" } + \c_xephm_zwj_int \tex_penalty:D 10000 + \tex_leaders:D \copy\l_xephm_ksh_box \skip_horizontal:n { #1 } + \c_xephm_zwj_int + } + { + \msg_error:nnx { xepersian-hm } { hm-series-font-not-found } { \l_xephm_font_name_tl } + } + } + { + %% Partly adapted from the code provided by Jonathan Kew in: + %% https://tug.org/pipermail/xetex/2009-February/012307.html. + %% Somebody notified me that the code in 'kashida-xepersian.def' from xepersian + %% package is an exact copy of Jonathan Kew's code. Being unaware of this, in + %% the earlier versions of this package I made a mistake and acknowledged + %% Vafa Khalighi instead of Jonathan Kew. A sincere thank you to Jonathan Kew + %% for his excellent code. + \c_xephm_lrm_int\c_xephm_zwj_int\tex_penalty:D 10000 + \tex_leaders:D \tex_hrule:D height \XeTeXglyphbounds \c_xephm_two_int + \int_use:N \XeTeXcharglyph \c_xephm_ksh_int depth \XeTeXglyphbounds \c_xephm_four_int + \int_use:N \XeTeXcharglyph \c_xephm_ksh_int \skip_horizontal:n { #1 } + \c_xephm_zwj_int + } } - } +} \XeTeXinterchartokenstate = 1 @@ -524,81 +566,57 @@ make time to fix. \XeTeXcharclass "#1 \c_xephm_y_charclass } -\str_case:VnTF \l_xephm_gap_filler_tl - { - \l_xephm_stretch_glyph_tl - { - \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_y_charclass = - { - \bool_if:NTF \l_xephm_kashida_hm_fix_bool - { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_skip_default_tl \c_xephm_zwj_int } - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_y_charclass = - { - \bool_if:NTF \l_xephm_kashida_hm_fix_bool - { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_skip_default_tl \c_xephm_zwj_int } - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - } - \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = - { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_a_charclass = - { } - } - \l_xephm_stretch_hrule_tl - { - \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_y_charclass = - { - \bool_if:NTF \l_xephm_kashida_hm_fix_bool - { \xephm_kashida_hrule \l_xephm_skip_default_tl } - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_y_charclass = - { - \bool_if:NTF \l_xephm_kashida_hm_fix_bool - { \xephm_kashida_hrule \l_xephm_skip_default_tl } - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - } - \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = - { \xephm_kashida_hrule \c_xephm_skip_a_tl } - \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_a_charclass = - { } - } +\tl_if_eq:NNTF \l_xephm_gap_filler_tl \l_xephm_stretch_glyph_tl { + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_y_charclass = { + \bool_if:NTF \l_xephm_kashida_hm_fix_bool + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_skip_default_tl \c_xephm_zwj_int } + { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_y_charclass = { + \bool_if:NTF \l_xephm_kashida_hm_fix_bool + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_skip_default_tl \c_xephm_zwj_int } + { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = { \c_xephm_zwj_int \xephm_kashida_glyph \c_xephm_skip_a_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_a_charclass = { } +} +{ + \bool_if:nTF { + \tl_if_eq_p:NN \l_xephm_gap_filler_tl \l_xephm_stretch_leaders_glyph_tl || + \tl_if_eq_p:NN \l_xephm_gap_filler_tl \l_xephm_stretch_leaders_hrule_tl } { - \msg_warning:nnn { xepersian-hm } { warning-experimental-feature } { Kashida=glyph } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_y_charclass = { + \bool_if:NTF \l_xephm_kashida_hm_fix_bool + { \xephm_kashida_leaders \l_xephm_skip_default_tl } + { \xephm_kashida_leaders \c_xephm_skip_a_tl } + } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_y_charclass = { + \bool_if:NTF \l_xephm_kashida_hm_fix_bool + { \xephm_kashida_leaders \l_xephm_skip_default_tl } + { \xephm_kashida_leaders \c_xephm_skip_a_tl } + } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = { \xephm_kashida_leaders \c_xephm_skip_a_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_a_charclass = { } } { \msg_error:nnx { xepersian-hm } { error-value-not-available-for-kashida-option } { \l_xephm_gap_filler_tl } } +} \NewDocumentCommand \KashidaHMFixOn {} { \bool_set_true:N \l_xephm_kashida_hm_fix_bool } \NewDocumentCommand \KashidaHMFixOff {} { \bool_set_false:N \l_xephm_kashida_hm_fix_bool } |