diff options
author | Karl Berry <karl@freefriends.org> | 2020-04-20 21:15:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-04-20 21:15:05 +0000 |
commit | ed3c99cf16da62222e34fc96e0b743b87f2dcd0f (patch) | |
tree | ad6ffe836f3c2162b968a7ccd2450a1b3fa8eeaa /Master/texmf-dist | |
parent | f84b6e8b6b238868bbf4cdaa80c02d90b8928555 (diff) |
xepersian-hm (20apr20)
git-svn-id: svn://tug.org/texlive/trunk@54816 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/xelatex/xepersian-hm/README.txt | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.pdf | bin | 17991 -> 81522 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex | 75 | ||||
-rw-r--r-- | Master/texmf-dist/doc/xelatex/xepersian-hm/xepersian-hm.pdf | bin | 52190 -> 62986 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx | 566 | ||||
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xepersian-hm/kashida-xepersian-hm.def | 305 | ||||
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xepersian-hm/xepersian-hm.sty | 184 |
7 files changed, 792 insertions, 343 deletions
diff --git a/Master/texmf-dist/doc/xelatex/xepersian-hm/README.txt b/Master/texmf-dist/doc/xelatex/xepersian-hm/README.txt index e9df9499708..d243aaf7f53 100644 --- a/Master/texmf-dist/doc/xelatex/xepersian-hm/README.txt +++ b/Master/texmf-dist/doc/xelatex/xepersian-hm/README.txt @@ -23,8 +23,9 @@ package fixes these problems. The file `texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex' can be used as a simple example of the usage of the package. -Any comments or suggestions would be gratefully appreciated. -Please report any bugs or issues to `dma8hm1334@gmail.com'. +Please use the Bitbucket issue tracker: +https://bitbucket.org/dma8hm1334/xepersian-hm/issues +to report a bug, request a feature or if you have a comment. I will do my best to fix all the bugs you report, but, unfortunately, time is a big hurdle to overcome; so, my apologies in advance for those diff --git a/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.pdf b/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.pdf Binary files differindex 0579becb84e..7856b997467 100644 --- a/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.pdf +++ b/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.pdf diff --git a/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex b/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex index d3492c93ef6..bd6e403c09a 100644 --- a/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex +++ b/Master/texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex @@ -1,32 +1,77 @@ % \PassOptionsToPackage{Kashida=off,RTLdocument=on}{xepersian} % Load xepersian with a few options \documentclass{report} -\usepackage{xcolor} -% \usepackage[Kashida]{xepersian} % Fails -\usepackage[Kashida,kashidastretch=0.14 em plus 0.5 em]{xepersian-hm} % Succeeds -% \usepackage[Kashida,kashidastretch=noskip]{xepersian-hm} % Succeeds -% \usepackage[Kashida,kashidastretch=default]{xepersian-hm} % Succeeds -% \usepackage[Kashida,kashidastretch=kayhan]{xepersian-hm} % Succeeds -% \usepackage[Kashida,kashidastretch=khorramshahr]{xepersian-hm} % Succeeds +% \textwidth=345.0pt +% \textheight=550.0pt +% \textheight=620pt +% \usepackage[Kashida]{xepersian} % Fails +% \usepackage{xepersian-hm} % Succeeds +% \usepackage[Kashida=hrule,kashidastretch=0.14 em plus 0.5 em]{xepersian-hm} % Succeeds +% \usepackage[Kashida=hrule,kashidastretch=0.14 em plus 5.5 em]{xepersian-hm} % Succeeds +\usepackage[Kashida=glyph,linebreakpenalty=8,kashidastretch=0.14 em plus 5.5 em]{xepersian-hm} % Succeeds +% \usepackage[Kashida=glyph,kashidastretch=kayhan]{xepersian-hm} % Succeeds +% \usepackage[Kashida,kashidastretch=0.14 em plus 0.5 em]{xepersian-hm} % Succeeds +% \usepackage[Kashida,kashidastretch=noskip]{xepersian-hm} % Succeeds +% \usepackage[Kashida,kashidastretch=default]{xepersian-hm} % Succeeds +% \usepackage[Kashida,kashidastretch=kayhan]{xepersian-hm} % Succeeds +% \usepackage[Kashida,kashidastretch=khorramshahr]{xepersian-hm} % Succeeds % \settextfont[Scale=4.5,Colour=darkgray]{XB Kayhan} -\settextfont[Scale=4.5,Colour=darkgray]{HM XKayhan} +\settextfont[Scale=4.5]{HM XKayhan} % \settextfont[Scale=4.5,Colour=darkgray]{HM XNiloofar} % \settextfont[Scale=4.5,Colour=darkgray]{HM XYas} % \settextfont[Scale=4.5,Colour=darkgray]{HM XZar} +% \settextfont[Scale=1,Colour=darkgray]{HM XKayhan} -% \setlatintextfont[Scale=2.5,Colour=teal]{XB Kayhan} -\setlatintextfont[Scale=2.5,Colour=teal]{HM XKayhan} +% \setlatintextfont[Scale=2.5,Colour=0000FF]{XB Kayhan} +\setlatintextfont[Scale=1.5,Colour=0000FF]{HM XKayhan} -\def\SampleText{راهی جایی تابی چاپی چاههی تلاشهایی شتابهایی تابی چاپی راهی تلاشهــایی که کتابهایی که کلاههایی که} +\defpersianfont\HMXKayhanIt[Scale=4.5]{HM XKayhan Italic} +\defpersianfont\HMXKayhanOb[Scale=4.5]{HM XKayhanOb Oblique} +\defpersianfont\HMXKayhanOl[Scale=4.5]{HM XKayhan Outline} +\defpersianfont\HMXKayhanSd[Scale=4.5]{HM XKayhan Shadow} + +\def\SampleText{\discouragebadlinebreaks{ + راهی جایی تابی چاپی چاههی تلاشهایی + شتابهایی تابی چاپی راهی تلاشهــایی + که کتابهایی که کلاههایی که کتابهایی }} \setlength\parindent{0pt} \pagestyle{empty} + \begin{document} -\color{red} -\KashidaOff \SampleText \lr{(Kashida Off)~} +\KashidaOff\lr{(Kashida Off, Regular)} -\KashidaOn \SampleText \lr{(Kashida On)~} +\SampleText -\end{document} +\newpage + +\KashidaOn\lr{(Kashida On, Regular)} + +\SampleText + +\newpage + +\KashidaOn\lr{(Kashida On, Italic)} + +{\HMXKayhanIt \SampleText} + +\newpage +\KashidaOn\lr{(Kashida On, Oblique)} + +{\HMXKayhanOb \SampleText} + +\newpage + +\KashidaOn\lr{(Kashida On, Outline)} + +{\HMXKayhanOl \SampleText} + +\newpage + +\KashidaOn\lr{(Kashida On, Shadow)} + +{\HMXKayhanSd \SampleText} + +\end{document} diff --git a/Master/texmf-dist/doc/xelatex/xepersian-hm/xepersian-hm.pdf b/Master/texmf-dist/doc/xelatex/xepersian-hm/xepersian-hm.pdf Binary files differindex 9c3cff93a1c..98b788d7874 100644 --- a/Master/texmf-dist/doc/xelatex/xepersian-hm/xepersian-hm.pdf +++ b/Master/texmf-dist/doc/xelatex/xepersian-hm/xepersian-hm.pdf 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 72cbc1d0286..6a7d84f07ee 100644 --- a/Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx +++ b/Master/texmf-dist/source/xelatex/xepersian-hm/xepersian-hm.dtx @@ -15,8 +15,9 @@ package fixes these problems. The file `texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex' can be used as a simple example of the usage of the package. -Any comments or suggestions would be gratefully appreciated. -Please report any bugs or issues to `dma8hm1334@gmail.com'. +Please use the Bitbucket issue tracker: +https://bitbucket.org/dma8hm1334/xepersian-hm/issues +to report a bug, request a feature or if you have a comment. I will do my best to fix all the bugs you report, but, unfortunately, time is a big hurdle to overcome; so, my apologies in advance for those @@ -34,13 +35,6 @@ which I cannot make time to fix. % version 1.3c or higher (your choice). The latest version of % this license is at: http://www.latex-project.org/lppl.txt % -% \iffalse -%<kashida-xepersian-hm> -%<kashida-xepersian-hm>% Copyright notice: the following code is partly adapted from the code in -%<kashida-xepersian-hm>% 'kashida-xepersian.def' from xepersian package (v22.8). -%<kashida-xepersian-hm> -% \fi -% %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. @@ -61,6 +55,7 @@ which I cannot make time to fix. %</driver|package> %<*driver> \documentclass[full]{l3doc} +\usepackage{longtable} \usepackage{hypdoc} \addtolength{\hoffset}{-10mm} \begin{document} @@ -70,24 +65,24 @@ which I cannot make time to fix. % \fi % % \title{^^A -% The \textsf{xepersian-hm} package\\ Fixes issues in xepersian package^^A +% The \textsf{xepersian-hm} package\\Fixing kashida in xepersian^^A % } -% +% % \author{^^A % Hossein Movahhedian\thanks % {^^A % E-mail: % \href{mailto:dma8hm1334@gmail.com} -% {dma8hm1334@gmail.com}^^A +% {\textsf{dma8hm1334@gmail.com}} % }^^A % } -% -% \date{Released 2020-03-26} -% -% \maketitle -% +% +% \date{Released 2020-04-20 \qquad v0.5a} +% % \begin{documentation} -% +% +% \maketitle +% % Kashida feature in \textsf{xepersian} has problems with some fonts such as \texttt{HM Series} % fonts available at % \href{https://dma8hm1334.bitbucket.io}{\texttt{https://dma8hm1334.bitbucket.io}} @@ -98,16 +93,19 @@ which I cannot make time to fix. % The file \texttt{texmf-dist/doc/xelatex/xepersian-hm/kashida-example.tex} can be % used as a simple example of the usage of the package. % -% Any comments or suggestions would be gratefully appreciated. -% Please report any bug or issue to \href{mailto:dma8hm1334@gmail.com}{\textsf{dma8hm1334@gmail.com}}. +% Please use the Bitbucket issue tracker: +% \href{https://bitbucket.org/dma8hm1334/xepersian-hm/issues}{\textsf{https://bitbucket.org/dma8hm1334/xepersian-hm/issues}} +% to report a bug, request a feature or if you have a comment. % % I will do my best to fix all the bugs you report, but, unfortunately, % time is a big hurdle to overcome; so, my apologies in advance for those % which I cannot make time to fix. % +% \section{Package loading and options} +% % Please note that \textsf{xepersian-hm} loads \textsf{xepersian} automatically, % so you may only pass options to the package using the command -% \verb|\PassOptionsToPackage| before \verb|\documentclass|, for example: +% \verb|\PassOptionsToPackage| before \verb|\documentclass|. For example: % % \begin{verbatim} % \PassOptionsToPackage{Kashida=off,RTLdocument=on}{xepersian} @@ -118,15 +116,33 @@ which I cannot make time to fix. % % The options available in \textsf{xepersian-hm} are: % \begin{itemize} -% \item \texttt{Kashida}: with two possible values, \texttt{on} which enables -% \texttt{Kashida} feature and \texttt{off} which disables that feature. For -% example \texttt{Kashida=on} enables \texttt{Kashida} feature. +% \item \texttt{Kashida}: which implements kashida feature with two possible values: +% \begin{itemize} +% \item \texttt{glyph}: which uses the \texttt{Kashida} character to stretch the text. +% Please note that this feature is still experimental and is not regarded as stable. +% If you are going to use this option be ready for unpredictable results. +% \item \texttt{hrule}: which uses a horizontal rule (\verb|\hrule|) to stretch the text. +% \end{itemize} +% For example \texttt{Kashida=glyph} inserts a stretched \texttt{Kashida} glyph where ever it is needed. +% \item \texttt{linebreakpenalty}: which specifies the amount of penalty for preventing bad line-breaking. +% You may strictly specify the value of this option. For example \texttt{'linebreakpenalty=8'} or you +% may use the default values. The available default values of penalties which are put into the +% horizontal list output are the negative of the followings: +% +% \begin{longtable}{ll} +% \texttt{min}: & \texttt{0} \\ +% \texttt{low}: & \texttt{8} \\ +% \texttt{medium}: & \texttt{15} \\ +% \texttt{high}: & \texttt{25} \\ +% \texttt{max}: & \texttt{10000} \\ +% \end{longtable} +% % \item \texttt{kashidastretch}: which specifies the amount of extra stretching % for some combinations of characters. You may strictly specify the value of % this option. For example \texttt{'kashidastretch=0.14 em plus 0.5 em'} or you % may use the default values. The available default values are: % -% \begin{tabular}{ll} +% \begin{longtable}{lll} % \texttt{kayhan} & \texttt{0.14 em plus 0.5 em} \\ % \texttt{khorramshahr} & \texttt{0.131 em plus 0.5 em} \\ % \texttt{kayhannavaar} & \texttt{0.129 em plus 0.5 em} \\ @@ -158,11 +174,20 @@ which I cannot make time to fix. % \texttt{ziba} & \texttt{0.119 em plus 0.5 em} \\ % \texttt{default} & \texttt{0.14 em plus 0.5 em} \\ % \texttt{noskip} & \texttt{0 em plus 0.5 em} -% \end{tabular} +% \end{longtable} % % For example: \mbox{\texttt{'kashidastretch=titr'}} is equivalent to\linebreak % \mbox{\texttt{'kashidastretch=0.12 em plus 0.5 em'}} % \end{itemize} +% +% \section{Commands} +% +% \begin{description} +% \item \verb|\discouragebadlinebreaks{|{\it text}\verb|}| {\it text} may not contain paragraph breaks. +% This command puts a penalty after each Persian word. +% The value of the penalty is set by the option \texttt{linebreakpenalty}. +% The default value is 8. +% \end{description} % % \end{documentation} % @@ -178,85 +203,133 @@ which I cannot make time to fix. % % \begin{macrocode} \RequirePackage{l3keys2e} +\RequirePackage{graphicx}[2019-11-30] +\RequirePackage{zref-savepos}[2020-03-03] \RequirePackage{xepersian} \ExplSyntaxOn -\ProvidesExplPackage {xepersian-hm} {2020-03-26} {0.4} { Fixes~issues~in~xepersian~package } - -\tl_set:Nn \l_kayhan_tl { kayhan } -\tl_set:Nn \l_khorramshahr_tl { khorramshahr } -\tl_set:Nn \l_kayhannavaar_tl { kayhannavaar } -\tl_set:Nn \l_kayhanpook_tl { kayhanpook } -\tl_set:Nn \l_kayhansayeh_tl { kayhansayeh } -\tl_set:Nn \l_khoramshahr_tl { khoramshahr } -\tl_set:Nn \l_khorramshahr_tl { khorramshahr } -\tl_set:Nn \l_niloofar_tl { niloofar } -\tl_set:Nn \l_paatch_tl { paatch } -\tl_set:Nn \l_riyaz_tl { riyaz } -\tl_set:Nn \l_roya_tl { roya } -\tl_set:Nn \l_shafigh_tl { shafigh } -\tl_set:Nn \l_shafighKurd_tl { shafighKurd } -\tl_set:Nn \l_shafighUzbek_tl { shafighUzbek } -\tl_set:Nn \l_shiraz_tl { shiraz } -\tl_set:Nn \l_sols_tl { sols } -\tl_set:Nn \l_tabriz_tl { tabriz } -\tl_set:Nn \l_titr_tl { titr } -\tl_set:Nn \l_titre_tl { titre } -\tl_set:Nn \l_traffic_tl { traffic } -\tl_set:Nn \l_vahid_tl { vahid } -\tl_set:Nn \l_vosta_tl { vosta } -\tl_set:Nn \l_yaghut_tl { yaghut } -\tl_set:Nn \l_yagut_tl { yagut } -\tl_set:Nn \l_yas_tl { yas } -\tl_set:Nn \l_yekan_tl { yekan } -\tl_set:Nn \l_yermook_tl { yermook } -\tl_set:Nn \l_zar_tl { zar } -\tl_set:Nn \l_ziba_tl { ziba } -\tl_set:Nn \l_default_tl { default } -\tl_set:Nn \l_noskip_tl { noskip } +\ProvidesExplPackage {xepersian-hm} {2020-04-20} {0.5a} { Fixes~issues~in~xepersian~package } + +\bool_set_false:N \l_xephm_kashida_hm_fix_bool + +\tl_new:N \l_xephm_gap_filler_tl + +\bool_set_false:N \l_xephm_linebreakpenalty_bool + +\int_new:N \l_xephm_line_break_penalty_int +\int_new:N \l_xephm_min_penalty_int +\int_new:N \l_xephm_low_penalty_int +\int_new:N \l_xephm_med_penalty_int +\int_new:N \l_xephm_high_penalty_int +\int_new:N \l_xephm_max_penalty_int + +\int_set:Nn \l_xephm_min_penalty_int { 0 } +\int_set:Nn \l_xephm_low_penalty_int { 8 } +\int_set:Nn \l_xephm_med_penalty_int { 15 } +\int_set:Nn \l_xephm_high_penalty_int { 25 } +\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_kayhan_tl { kayhan } +\tl_set:Nn \l_xephm_khorramshahr_tl { khorramshahr } +\tl_set:Nn \l_xephm_kayhannavaar_tl { kayhannavaar } +\tl_set:Nn \l_xephm_kayhanpook_tl { kayhanpook } +\tl_set:Nn \l_xephm_kayhansayeh_tl { kayhansayeh } +\tl_set:Nn \l_xephm_khoramshahr_tl { khoramshahr } +\tl_set:Nn \l_xephm_khorramshahr_tl { khorramshahr } +\tl_set:Nn \l_xephm_niloofar_tl { niloofar } +\tl_set:Nn \l_xephm_paatch_tl { paatch } +\tl_set:Nn \l_xephm_riyaz_tl { riyaz } +\tl_set:Nn \l_xephm_roya_tl { roya } +\tl_set:Nn \l_xephm_shafigh_tl { shafigh } +\tl_set:Nn \l_xephm_shafighKurd_tl { shafighKurd } +\tl_set:Nn \l_xephm_shafighUzbek_tl { shafighUzbek } +\tl_set:Nn \l_xephm_shiraz_tl { shiraz } +\tl_set:Nn \l_xephm_sols_tl { sols } +\tl_set:Nn \l_xephm_tabriz_tl { tabriz } +\tl_set:Nn \l_xephm_titr_tl { titr } +\tl_set:Nn \l_xephm_titre_tl { titre } +\tl_set:Nn \l_xephm_traffic_tl { traffic } +\tl_set:Nn \l_xephm_vahid_tl { vahid } +\tl_set:Nn \l_xephm_vosta_tl { vosta } +\tl_set:Nn \l_xephm_yaghut_tl { yaghut } +\tl_set:Nn \l_xephm_yagut_tl { yagut } +\tl_set:Nn \l_xephm_yas_tl { yas } +\tl_set:Nn \l_xephm_yekan_tl { yekan } +\tl_set:Nn \l_xephm_yermook_tl { yermook } +\tl_set:Nn \l_xephm_zar_tl { zar } +\tl_set:Nn \l_xephm_ziba_tl { ziba } +\tl_set:Nn \l_xephm_default_tl { default } +\tl_set:Nn \l_xephm_noskip_tl { noskip } \keys_define:nn { xepersian-hm } { - Kashida .code:n = \tex_input:D { kashida-xepersian-hm.def } , - - kashidastretch .code:n = + Kashida .code:n = { \tl_set:Nn \l_tmpa_tl { #1 } \tl_case:NnTF \l_tmpa_tl { - \l_kayhan_tl { \tl_set:Nn \l_hskip_default_tl { 0.14 em plus 0.5 em } } - \l_khorramshahr_tl { \tl_set:Nn \l_hskip_default_tl { 0.131 em plus 0.5 em } } - \l_kayhannavaar_tl { \tl_set:Nn \l_hskip_default_tl { 0.129 em plus 0.5 em } } - \l_kayhanpook_tl { \tl_set:Nn \l_hskip_default_tl { 0.133 em plus 0.5 em } } - \l_kayhansayeh_tl { \tl_set:Nn \l_hskip_default_tl { 0.135 em plus 0.5 em } } - \l_khoramshahr_tl { \tl_set:Nn \l_hskip_default_tl { 0.128 em plus 0.5 em } } - \l_khorramshahr_tl { \tl_set:Nn \l_hskip_default_tl { 0.13 em plus 0.5 em } } - \l_niloofar_tl { \tl_set:Nn \l_hskip_default_tl { 0.132 em plus 0.5 em } } - \l_paatch_tl { \tl_set:Nn \l_hskip_default_tl { 0.127 em plus 0.5 em } } - \l_riyaz_tl { \tl_set:Nn \l_hskip_default_tl { 0.125 em plus 0.5 em } } - \l_roya_tl { \tl_set:Nn \l_hskip_default_tl { 0.142 em plus 0.5 em } } - \l_shafigh_tl { \tl_set:Nn \l_hskip_default_tl { 0.143 em plus 0.5 em } } - \l_shafighKurd_tl { \tl_set:Nn \l_hskip_default_tl { 0.126 em plus 0.5 em } } - \l_shafighUzbek_tl { \tl_set:Nn \l_hskip_default_tl { 0.123 em plus 0.5 em } } - \l_shiraz_tl { \tl_set:Nn \l_hskip_default_tl { 0.122 em plus 0.5 em } } - \l_sols_tl { \tl_set:Nn \l_hskip_default_tl { 0.124 em plus 0.5 em } } - \l_tabriz_tl { \tl_set:Nn \l_hskip_default_tl { 0.119 em plus 0.5 em } } - \l_titr_tl { \tl_set:Nn \l_hskip_default_tl { 0.12 em plus 0.5 em } } - \l_titre_tl { \tl_set:Nn \l_hskip_default_tl { 0.121 em plus 0.5 em } } - \l_traffic_tl { \tl_set:Nn \l_hskip_default_tl { 0.124 em plus 0.5 em } } - \l_vahid_tl { \tl_set:Nn \l_hskip_default_tl { 0.134 em plus 0.5 em } } - \l_vosta_tl { \tl_set:Nn \l_hskip_default_tl { 0.136 em plus 0.5 em } } - \l_yaghut_tl { \tl_set:Nn \l_hskip_default_tl { 0.138 em plus 0.5 em } } - \l_yagut_tl { \tl_set:Nn \l_hskip_default_tl { 0.137 em plus 0.5 em } } - \l_yas_tl { \tl_set:Nn \l_hskip_default_tl { 0.126 em plus 0.5 em } } - \l_yekan_tl { \tl_set:Nn \l_hskip_default_tl { 0.141 em plus 0.5 em } } - \l_yermook_tl { \tl_set:Nn \l_hskip_default_tl { 0.139 em plus 0.5 em } } - \l_zar_tl { \tl_set:Nn \l_hskip_default_tl { 0.116 em plus 0.5 em } } - \l_ziba_tl { \tl_set:Nn \l_hskip_default_tl { 0.119 em plus 0.5 em } } - \l_default_tl { \tl_set:Nn \l_hskip_default_tl { 0.14 em plus 0.5 em } } - \l_noskip_tl { \tl_set:Nn \l_hskip_default_tl { 0 em plus 0.5 em } } - } { } { \tl_set:Nn \l_hskip_default_tl { #1 } } + \l_xephm_stretch_glyph_tl { \tl_set:Nn \l_xephm_gap_filler_tl { \l_xephm_stretch_glyph_tl } } + \l_xephm_stretch_hrule_tl { \tl_set:Nn \l_xephm_gap_filler_tl { \l_xephm_stretch_hrule_tl } } + } { } { \tl_set:Nn \l_xephm_filler_default_tl { #1 } } + \bool_set_true:N \l_xephm_kashida_hm_fix_bool + \tex_input:D { kashida-xepersian-hm.def } } , - kashidastretch .default:n = \tl_set:Nn \l_hskip_default_tl { 0 em plus 0.5 em } , + + linebreakpenalty .code:n = + { + \int_set:Nn \l_tmpa_int { #1 } + \int_case:nnTF \l_tmpa_int + { + \l_xephm_min_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_min_penalty_int } } + \l_xephm_low_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_low_penalty_int } } + \l_xephm_med_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_med_penalty_int } } + \l_xephm_high_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_high_penalty_int } } + \l_xephm_max_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_max_penalty_int } } + } { } { \int_set:Nn \l_xephm_line_break_penalty_int { #1 } } + \bool_set_true:N \l_xephm_linebreakpenalty_bool + } , + + kashidastretch .code:n = + { + \tl_set:Nn \l_tmpb_tl { #1 } + \tl_case:NnTF \l_tmpb_tl + { + \l_xephm_kayhan_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.14 em plus 0.5 em } } + \l_xephm_khorramshahr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.131 em plus 0.5 em } } + \l_xephm_kayhannavaar_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.129 em plus 0.5 em } } + \l_xephm_kayhanpook_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.133 em plus 0.5 em } } + \l_xephm_kayhansayeh_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.135 em plus 0.5 em } } + \l_xephm_khoramshahr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.128 em plus 0.5 em } } + \l_xephm_khorramshahr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.13 em plus 0.5 em } } + \l_xephm_niloofar_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.132 em plus 0.5 em } } + \l_xephm_paatch_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.127 em plus 0.5 em } } + \l_xephm_riyaz_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.125 em plus 0.5 em } } + \l_xephm_roya_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.142 em plus 0.5 em } } + \l_xephm_shafigh_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.143 em plus 0.5 em } } + \l_xephm_shafighKurd_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.126 em plus 0.5 em } } + \l_xephm_shafighUzbek_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.123 em plus 0.5 em } } + \l_xephm_shiraz_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.122 em plus 0.5 em } } + \l_xephm_sols_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.124 em plus 0.5 em } } + \l_xephm_tabriz_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.119 em plus 0.5 em } } + \l_xephm_titr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.12 em plus 0.5 em } } + \l_xephm_titre_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.121 em plus 0.5 em } } + \l_xephm_traffic_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.124 em plus 0.5 em } } + \l_xephm_vahid_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.134 em plus 0.5 em } } + \l_xephm_vosta_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.136 em plus 0.5 em } } + \l_xephm_yaghut_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.138 em plus 0.5 em } } + \l_xephm_yagut_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.137 em plus 0.5 em } } + \l_xephm_yas_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.126 em plus 0.5 em } } + \l_xephm_yekan_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.141 em plus 0.5 em } } + \l_xephm_yermook_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.139 em plus 0.5 em } } + \l_xephm_zar_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.116 em plus 0.5 em } } + \l_xephm_ziba_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.119 em plus 0.5 em } } + \l_xephm_default_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.14 em plus 0.5 em } } + \l_xephm_noskip_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0 em plus 0.5 em } } + } { } { \tl_set:Nn \l_xephm_hskip_default_tl { #1 } } + } , + kashidastretch .default:n = \tl_set:Nn \l_xephm_hskip_default_tl { 0 em plus 0.5 em } , } \ProcessKeysOptions { xepersian-hm } @@ -274,121 +347,264 @@ which I cannot make time to fix. % \begin{macrocode} %<*kashida-xepersian-hm> \ExplSyntaxOn -\ProvidesExplFile {kashida-xepersian-hm.def} {2020-03-26} {0.4} { Fixes~implementation~of~Kashida~in~xepersian~package } - -\int_const:Nn \c_xepersianhm_zwj_int {"200D} % zero-width joiner -\int_const:Nn \c_xepersianhm_lrm_int {"200E} % left-right-mark -\int_const:Nn \c_xepersianhm_two_int {2} % 2 -\int_const:Nn \c_xepersianhm_four_int {4} % 4 -\int_const:Nn \c_xepersianhm_ksh_int {"0640} % kashida -\int_const:Nn \c_xepersianhm_d_int {10} % dual-joiner class -\int_const:Nn \c_xepersianhm_l_int {11} % lam -\int_const:Nn \c_xepersianhm_r_int {12} % right-joiner -\int_const:Nn \c_xepersianhm_a_int {13} % alef -\int_const:Nn \c_xepersianhm_h_int {14} % heh -\int_const:Nn \c_xepersianhm_y_int {15} % yeh -\int_const:Nn \c_xepersianhm_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 +\ProvidesExplFile {kashida-xepersian-hm.def} {2020-04-20} {0.5a} { Fixes~implementation~of~Kashida~in~xepersian~package } + +\int_const:Nn \c_xephm_zwj_int {"200D} % zero-width joiner +\int_const:Nn \c_xephm_lrm_int {"200E} % left-right-mark +\int_const:Nn \c_xephm_two_int {2} % 2 +\int_const:Nn \c_xephm_four_int {4} % 4 +\int_const:Nn \c_xephm_ksh_int {"0640} % kashida + +\int_new:N \l_xephm_counter_int + +\newXeTeXintercharclass \c_xephm_d_charclass % dual-joiner class +\newXeTeXintercharclass \c_xephm_l_charclass % lam +\newXeTeXintercharclass \c_xephm_r_charclass % right-joiner +\newXeTeXintercharclass \c_xephm_a_charclass % alef +\newXeTeXintercharclass \c_xephm_y_charclass % yeh + +\tl_new:N \l_xephm_hskip_zero_tl +\tl_new:N \l_xephm_hskip_default_tl + +\dim_new:N \l_xephm_diff_pos_dim + +%% 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 } { m } + { + \xephm_put_line_breaks:n { #1 } + } + +\tl_new: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 +\cs_new:Npn \xephm_kashida_glyph #1 +{ + \bool_if:NT \l_xephm_kashida_hm_fix_bool { - \bool_if:NT \l_kashida_on_bool + \c_xephm_lrm_int\tex_penalty:D 10000 + \mode_leave_vertical: + \tex_global:D \tex_advance:D \l_xephm_counter_int \c_one_int + + \tl_set:Nx \l_xephm_pos_tl { pos_\tex_romannumeral:D \l_xephm_counter_int } + \tl_set:Nx \l_xephm_zref_tl { zref_\tex_romannumeral:D \l_xephm_counter_int } + + \zsaveposx{x_i_\l_xephm_zref_tl} + \tl_set:Nx \l_tmpa_tl + { + \iow_now:cx { @auxout } + { + \ExplSyntaxOn + \tl_gset:Nn \exp_after:wN \token_to_str:N \cs:w get_x_i\l_xephm_pos_tl \cs_end: { \zposx{ x_i_\l_xephm_zref_tl } } + \ExplSyntaxOff + } + } + \l_tmpa_tl + \skip_horizontal:n { #1 } + \zsaveposx{x_f_\l_xephm_zref_tl} + \tl_set:Nx \l_tmpa_tl + { + \iow_now:cx { @auxout } + { + \ExplSyntaxOn + \tl_gset:Nn \exp_after:wN \token_to_str:N \cs:w get_x_f\l_xephm_pos_tl \cs_end: { \zposx{ x_f_\l_xephm_zref_tl } } + \ExplSyntaxOff + } + } + \l_tmpa_tl + \exp_after:wN + \if_meaning:w + \cs:w get_x_i\l_xephm_pos_tl \cs_end: \tex_relax:D + \else: + \dim_set:Nn \l_xephm_diff_pos_dim + { + \dim_eval:n { \cs:w get_x_i\l_xephm_pos_tl \cs_end: sp - \cs:w get_x_f\l_xephm_pos_tl \cs_end: sp } + } + \dim_compare:nTF { \l_xephm_diff_pos_dim == 0sp } + { } + { \llap { \resizebox { \l_xephm_diff_pos_dim \tex_relax:D } { \height } { \c_xephm_ksh_int } } } + \fi: + } +} + +%% 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 { - \c_xepersianhm_lrm_int\c_xepersianhm_zwj_int\tex_penalty:D 10000 - \tex_leaders:D \tex_hrule:D height \XeTeXglyphbounds \c_xepersianhm_two_int - \int_use:N \XeTeXcharglyph \c_xepersianhm_ksh_int depth \XeTeXglyphbounds \c_xepersianhm_four_int - \int_use:N \XeTeXcharglyph \c_xepersianhm_ksh_int \skip_horizontal:n { #1 } - \c_xepersianhm_zwj_int + \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 -\clist_set:Nn \l_xepersianhm_a_clist { 0622,0623,0625,0627 } % ا، إ، أ، آ -\clist_map_inline:Nn \l_xepersianhm_a_clist +\clist_set:Nn \l_xephm_a_clist { 0622,0623,0625,0627 } % ا، إ، أ، آ +\clist_map_inline:Nn \l_xephm_a_clist { - \XeTeXcharclass "#1 \c_xepersianhm_a_int + \XeTeXcharclass "#1 \c_xephm_a_charclass } -\clist_set:Nn \l_xepersianhm_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_xepersianhm_d_clist +\clist_set:Nn \l_xephm_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_xephm_d_clist { - \XeTeXcharclass "#1 \c_xepersianhm_d_int + \XeTeXcharclass "#1 \c_xephm_d_charclass } -\clist_set:Nn \l_xepersianhm_l_clist { 0644 } % ل -\clist_map_inline:Nn \l_xepersianhm_l_clist +\clist_set:Nn \l_xephm_l_clist { 0644 } % ل +\clist_map_inline:Nn \l_xephm_l_clist { - \XeTeXcharclass "#1 \c_xepersianhm_l_int + \XeTeXcharclass "#1 \c_xephm_l_charclass } -\clist_set:Nn \l_xepersianhm_r_clist { 0624,0629,062F,0630,0631,0632,0648,0698 } % ؤ,ة,د,ذ,ر,ز,و,ژ -\clist_map_inline:Nn \l_xepersianhm_r_clist +\clist_set:Nn \l_xephm_r_clist { 0624,0629,062F,0630,0631,0632,0648,0698 } % ؤ,ة,د,ذ,ر,ز,و,ژ +\clist_map_inline:Nn \l_xephm_r_clist { - \XeTeXcharclass "#1 \c_xepersianhm_r_int + \XeTeXcharclass "#1 \c_xephm_r_charclass } -\clist_set:Nn \l_xepersianhm_v_clist { 064B,064C,064D,064E,064F,0650,0651,0652 } % ً,ٌ,ٍ,َ,ُ,ِ,ّ,ْ -\clist_map_inline:Nn \l_xepersianhm_v_clist +\clist_set:Nn \l_xephm_y_clist { 0649,064A,06CC } % ی,ي,ى +\clist_map_inline:Nn \l_xephm_y_clist { - \XeTeXcharclass "#1 \c_xepersianhm_v_int + \XeTeXcharclass "#1 \c_xephm_y_charclass } -\clist_set:Nn \l_xepersianhm_y_clist { 0649,064A,06CC } -\clist_map_inline:Nn \l_xepersianhm_y_clist +\msg_new:nnx { xepersian-hm } { value-not-available-for-kashida-option } { - \XeTeXcharclass "#1 \c_xepersianhm_y_int + Sorry,~ value~ `\l_xephm_gap_filler_tl'~ is~ not~ available~ for~ kashida~ option~ yet! } -\XeTeXinterchartoks \c_xepersianhm_y_int \c_xepersianhm_y_int = {\bool_if:NTF \l_kashida_hm_fix_bool {\xepersian_kashida {\l_hskip_default_tl}} {\xepersian_kashida \l_hskip_zero_tl}} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_y_int = {\bool_if:NTF \l_kashida_hm_fix_bool {\xepersian_kashida {\l_hskip_default_tl}} {\xepersian_kashida \l_hskip_zero_tl}} -\XeTeXinterchartoks \c_xepersianhm_y_int \c_xepersianhm_d_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_d_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_d_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_l_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_l_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_r_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_a_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_r_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_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 } +\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_hskip_default_tl \c_xephm_zwj_int } + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_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_hskip_default_tl \c_xephm_zwj_int } + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_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_hskip_default_tl } + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_y_charclass = + { + \bool_if:NTF \l_xephm_kashida_hm_fix_bool + { \xephm_kashida_hrule \l_xephm_hskip_default_tl } + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_a_charclass = + { } + } + } { } { \msg_error:nn { xepersian-hm } { value-not-available-for-kashida-option } } -\ExplSyntaxOff -\makeatletter -\newif\if@Kashida@on -\newif\if@Kashida@XB@fix -\makeatother -\ExplSyntaxOn +\NewDocumentCommand \KashidaHMFixOn {} { \bool_set_true:N \l_xephm_kashida_hm_fix_bool } +\NewDocumentCommand \KashidaHMFixOff {} { \bool_set_false:N \l_xephm_kashida_hm_fix_bool } -\KashidaHMFixOn +\tex_let:D \KashidaOn \KashidaHMFixOn +\tex_let:D \KashidaOff \KashidaHMFixOff -\tl_set:Nn \l_hskip_zero_tl { 0 em plus 0.5 em } +\tl_set:Nn \l_xephm_hskip_zero_tl { 0 em plus 0.5 em } -\bool_if:NTF \l_kashida_hm_fix_bool +\bool_if:NTF \l_xephm_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_if_empty:NT \l_xephm_hskip_default_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.14 em plus 0.5 em } } } { - \tl_set:NV \l_hskip_default_tl \l_hskip_zero_tl + \tl_set:NV \l_xephm_hskip_default_tl \l_xephm_hskip_zero_tl } -\KashidaOn - \ExplSyntaxOff + +\makeatletter +\newif\if@Kashida@on +\newif\if@Kashida@XB@fix +\makeatother + \endinput %</kashida-xepersian-hm> % \end{macrocode} 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 ab66aae3083..637816e1552 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,126 +13,265 @@ %% this license is at: http://www.latex-project.org/lppl.txt %% %% File: xepersian-hm.dtx +\ExplSyntaxOn +\ProvidesExplFile {kashida-xepersian-hm.def} {2020-04-20} {0.5a} { Fixes~implementation~of~Kashida~in~xepersian~package } -% Copyright notice: the following code is partly adapted from the code in -% 'kashida-xepersian.def' from xepersian package (v22.8). +\int_const:Nn \c_xephm_zwj_int {"200D} % zero-width joiner +\int_const:Nn \c_xephm_lrm_int {"200E} % left-right-mark +\int_const:Nn \c_xephm_two_int {2} % 2 +\int_const:Nn \c_xephm_four_int {4} % 4 +\int_const:Nn \c_xephm_ksh_int {"0640} % kashida -\ExplSyntaxOn -\ProvidesExplFile {kashida-xepersian-hm.def} {2020-03-26} {0.4} { Fixes~implementation~of~Kashida~in~xepersian~package } - -\int_const:Nn \c_xepersianhm_zwj_int {"200D} % zero-width joiner -\int_const:Nn \c_xepersianhm_lrm_int {"200E} % left-right-mark -\int_const:Nn \c_xepersianhm_two_int {2} % 2 -\int_const:Nn \c_xepersianhm_four_int {4} % 4 -\int_const:Nn \c_xepersianhm_ksh_int {"0640} % kashida -\int_const:Nn \c_xepersianhm_d_int {10} % dual-joiner class -\int_const:Nn \c_xepersianhm_l_int {11} % lam -\int_const:Nn \c_xepersianhm_r_int {12} % right-joiner -\int_const:Nn \c_xepersianhm_a_int {13} % alef -\int_const:Nn \c_xepersianhm_h_int {14} % heh -\int_const:Nn \c_xepersianhm_y_int {15} % yeh -\int_const:Nn \c_xepersianhm_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 +\int_new:N \l_xephm_counter_int + +\newXeTeXintercharclass \c_xephm_d_charclass % dual-joiner class +\newXeTeXintercharclass \c_xephm_l_charclass % lam +\newXeTeXintercharclass \c_xephm_r_charclass % right-joiner +\newXeTeXintercharclass \c_xephm_a_charclass % alef +\newXeTeXintercharclass \c_xephm_y_charclass % yeh + +\tl_new:N \l_xephm_hskip_zero_tl +\tl_new:N \l_xephm_hskip_default_tl + +\dim_new:N \l_xephm_diff_pos_dim + +%% 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 } { m } + { + \xephm_put_line_breaks:n { #1 } + } + +\tl_new: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 +\cs_new:Npn \xephm_kashida_glyph #1 +{ + \bool_if:NT \l_xephm_kashida_hm_fix_bool + { + \c_xephm_lrm_int\tex_penalty:D 10000 + \mode_leave_vertical: + \tex_global:D \tex_advance:D \l_xephm_counter_int \c_one_int + + \tl_set:Nx \l_xephm_pos_tl { pos_\tex_romannumeral:D \l_xephm_counter_int } + \tl_set:Nx \l_xephm_zref_tl { zref_\tex_romannumeral:D \l_xephm_counter_int } + + \zsaveposx{x_i_\l_xephm_zref_tl} + \tl_set:Nx \l_tmpa_tl + { + \iow_now:cx { @auxout } + { + \ExplSyntaxOn + \tl_gset:Nn \exp_after:wN \token_to_str:N \cs:w get_x_i\l_xephm_pos_tl \cs_end: { \zposx{ x_i_\l_xephm_zref_tl } } + \ExplSyntaxOff + } + } + \l_tmpa_tl + \skip_horizontal:n { #1 } + \zsaveposx{x_f_\l_xephm_zref_tl} + \tl_set:Nx \l_tmpa_tl + { + \iow_now:cx { @auxout } + { + \ExplSyntaxOn + \tl_gset:Nn \exp_after:wN \token_to_str:N \cs:w get_x_f\l_xephm_pos_tl \cs_end: { \zposx{ x_f_\l_xephm_zref_tl } } + \ExplSyntaxOff + } + } + \l_tmpa_tl + \exp_after:wN + \if_meaning:w + \cs:w get_x_i\l_xephm_pos_tl \cs_end: \tex_relax:D + \else: + \dim_set:Nn \l_xephm_diff_pos_dim + { + \dim_eval:n { \cs:w get_x_i\l_xephm_pos_tl \cs_end: sp - \cs:w get_x_f\l_xephm_pos_tl \cs_end: sp } + } + \dim_compare:nTF { \l_xephm_diff_pos_dim == 0sp } + { } + { \llap { \resizebox { \l_xephm_diff_pos_dim \tex_relax:D } { \height } { \c_xephm_ksh_int } } } + \fi: + } +} + +%% 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_kashida_on_bool + \bool_if:NT \l_xephm_kashida_hm_fix_bool { - \c_xepersianhm_lrm_int\c_xepersianhm_zwj_int\tex_penalty:D 10000 - \tex_leaders:D \tex_hrule:D height \XeTeXglyphbounds \c_xepersianhm_two_int - \int_use:N \XeTeXcharglyph \c_xepersianhm_ksh_int depth \XeTeXglyphbounds \c_xepersianhm_four_int - \int_use:N \XeTeXcharglyph \c_xepersianhm_ksh_int \skip_horizontal:n { #1 } - \c_xepersianhm_zwj_int + \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 -\clist_set:Nn \l_xepersianhm_a_clist { 0622,0623,0625,0627 } % ا، إ، أ، آ -\clist_map_inline:Nn \l_xepersianhm_a_clist +\clist_set:Nn \l_xephm_a_clist { 0622,0623,0625,0627 } % ا، إ، أ، آ +\clist_map_inline:Nn \l_xephm_a_clist { - \XeTeXcharclass "#1 \c_xepersianhm_a_int + \XeTeXcharclass "#1 \c_xephm_a_charclass } -\clist_set:Nn \l_xepersianhm_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_xepersianhm_d_clist +\clist_set:Nn \l_xephm_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_xephm_d_clist { - \XeTeXcharclass "#1 \c_xepersianhm_d_int + \XeTeXcharclass "#1 \c_xephm_d_charclass } -\clist_set:Nn \l_xepersianhm_l_clist { 0644 } % ل -\clist_map_inline:Nn \l_xepersianhm_l_clist +\clist_set:Nn \l_xephm_l_clist { 0644 } % ل +\clist_map_inline:Nn \l_xephm_l_clist { - \XeTeXcharclass "#1 \c_xepersianhm_l_int + \XeTeXcharclass "#1 \c_xephm_l_charclass } -\clist_set:Nn \l_xepersianhm_r_clist { 0624,0629,062F,0630,0631,0632,0648,0698 } % ؤ,ة,د,ذ,ر,ز,و,ژ -\clist_map_inline:Nn \l_xepersianhm_r_clist +\clist_set:Nn \l_xephm_r_clist { 0624,0629,062F,0630,0631,0632,0648,0698 } % ؤ,ة,د,ذ,ر,ز,و,ژ +\clist_map_inline:Nn \l_xephm_r_clist { - \XeTeXcharclass "#1 \c_xepersianhm_r_int + \XeTeXcharclass "#1 \c_xephm_r_charclass } -\clist_set:Nn \l_xepersianhm_v_clist { 064B,064C,064D,064E,064F,0650,0651,0652 } % ً,ٌ,ٍ,َ,ُ,ِ,ّ,ْ -\clist_map_inline:Nn \l_xepersianhm_v_clist +\clist_set:Nn \l_xephm_y_clist { 0649,064A,06CC } % ی,ي,ى +\clist_map_inline:Nn \l_xephm_y_clist { - \XeTeXcharclass "#1 \c_xepersianhm_v_int + \XeTeXcharclass "#1 \c_xephm_y_charclass } -\clist_set:Nn \l_xepersianhm_y_clist { 0649,064A,06CC } -\clist_map_inline:Nn \l_xepersianhm_y_clist +\msg_new:nnx { xepersian-hm } { value-not-available-for-kashida-option } { - \XeTeXcharclass "#1 \c_xepersianhm_y_int + Sorry,~ value~ `\l_xephm_gap_filler_tl'~ is~ not~ available~ for~ kashida~ option~ yet! } -\XeTeXinterchartoks \c_xepersianhm_y_int \c_xepersianhm_y_int = {\bool_if:NTF \l_kashida_hm_fix_bool {\xepersian_kashida {\l_hskip_default_tl}} {\xepersian_kashida \l_hskip_zero_tl}} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_y_int = {\bool_if:NTF \l_kashida_hm_fix_bool {\xepersian_kashida {\l_hskip_default_tl}} {\xepersian_kashida \l_hskip_zero_tl}} -\XeTeXinterchartoks \c_xepersianhm_y_int \c_xepersianhm_d_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_d_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_d_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_l_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_l_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_r_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_d_int \c_xepersianhm_a_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_r_int = {\xepersian_kashida \l_hskip_zero_tl} -\XeTeXinterchartoks \c_xepersianhm_l_int \c_xepersianhm_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 } +\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_hskip_default_tl \c_xephm_zwj_int } + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_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_hskip_default_tl \c_xephm_zwj_int } + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_tl \c_xephm_zwj_int } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = + { \c_xephm_zwj_int \xephm_kashida_glyph \l_xephm_hskip_zero_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_hskip_default_tl } + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_y_charclass = + { + \bool_if:NTF \l_xephm_kashida_hm_fix_bool + { \xephm_kashida_hrule \l_xephm_hskip_default_tl } + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + } + \XeTeXinterchartoks \c_xephm_y_charclass \c_xephm_d_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_d_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_d_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_l_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_l_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_r_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_d_charclass \c_xephm_a_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_r_charclass = + { \xephm_kashida_hrule \l_xephm_hskip_zero_tl } + \XeTeXinterchartoks \c_xephm_l_charclass \c_xephm_a_charclass = + { } + } + } { } { \msg_error:nn { xepersian-hm } { value-not-available-for-kashida-option } } -\ExplSyntaxOff -\makeatletter -\newif\if@Kashida@on -\newif\if@Kashida@XB@fix -\makeatother -\ExplSyntaxOn +\NewDocumentCommand \KashidaHMFixOn {} { \bool_set_true:N \l_xephm_kashida_hm_fix_bool } +\NewDocumentCommand \KashidaHMFixOff {} { \bool_set_false:N \l_xephm_kashida_hm_fix_bool } -\KashidaHMFixOn +\tex_let:D \KashidaOn \KashidaHMFixOn +\tex_let:D \KashidaOff \KashidaHMFixOff -\tl_set:Nn \l_hskip_zero_tl { 0 em plus 0.5 em } +\tl_set:Nn \l_xephm_hskip_zero_tl { 0 em plus 0.5 em } -\bool_if:NTF \l_kashida_hm_fix_bool +\bool_if:NTF \l_xephm_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_if_empty:NT \l_xephm_hskip_default_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.14 em plus 0.5 em } } } { - \tl_set:NV \l_hskip_default_tl \l_hskip_zero_tl + \tl_set:NV \l_xephm_hskip_default_tl \l_xephm_hskip_zero_tl } -\KashidaOn - \ExplSyntaxOff + +\makeatletter +\newif\if@Kashida@on +\newif\if@Kashida@XB@fix +\makeatother + \endinput %% %% diff --git a/Master/texmf-dist/tex/xelatex/xepersian-hm/xepersian-hm.sty b/Master/texmf-dist/tex/xelatex/xepersian-hm/xepersian-hm.sty index 1a685d49694..1a3efc09707 100644 --- a/Master/texmf-dist/tex/xelatex/xepersian-hm/xepersian-hm.sty +++ b/Master/texmf-dist/tex/xelatex/xepersian-hm/xepersian-hm.sty @@ -28,85 +28,133 @@ \endinput } \RequirePackage{l3keys2e} +\RequirePackage{graphicx}[2019-11-30] +\RequirePackage{zref-savepos}[2020-03-03] \RequirePackage{xepersian} \ExplSyntaxOn -\ProvidesExplPackage {xepersian-hm} {2020-03-26} {0.4} { Fixes~issues~in~xepersian~package } +\ProvidesExplPackage {xepersian-hm} {2020-04-20} {0.5a} { Fixes~issues~in~xepersian~package } -\tl_set:Nn \l_kayhan_tl { kayhan } -\tl_set:Nn \l_khorramshahr_tl { khorramshahr } -\tl_set:Nn \l_kayhannavaar_tl { kayhannavaar } -\tl_set:Nn \l_kayhanpook_tl { kayhanpook } -\tl_set:Nn \l_kayhansayeh_tl { kayhansayeh } -\tl_set:Nn \l_khoramshahr_tl { khoramshahr } -\tl_set:Nn \l_khorramshahr_tl { khorramshahr } -\tl_set:Nn \l_niloofar_tl { niloofar } -\tl_set:Nn \l_paatch_tl { paatch } -\tl_set:Nn \l_riyaz_tl { riyaz } -\tl_set:Nn \l_roya_tl { roya } -\tl_set:Nn \l_shafigh_tl { shafigh } -\tl_set:Nn \l_shafighKurd_tl { shafighKurd } -\tl_set:Nn \l_shafighUzbek_tl { shafighUzbek } -\tl_set:Nn \l_shiraz_tl { shiraz } -\tl_set:Nn \l_sols_tl { sols } -\tl_set:Nn \l_tabriz_tl { tabriz } -\tl_set:Nn \l_titr_tl { titr } -\tl_set:Nn \l_titre_tl { titre } -\tl_set:Nn \l_traffic_tl { traffic } -\tl_set:Nn \l_vahid_tl { vahid } -\tl_set:Nn \l_vosta_tl { vosta } -\tl_set:Nn \l_yaghut_tl { yaghut } -\tl_set:Nn \l_yagut_tl { yagut } -\tl_set:Nn \l_yas_tl { yas } -\tl_set:Nn \l_yekan_tl { yekan } -\tl_set:Nn \l_yermook_tl { yermook } -\tl_set:Nn \l_zar_tl { zar } -\tl_set:Nn \l_ziba_tl { ziba } -\tl_set:Nn \l_default_tl { default } -\tl_set:Nn \l_noskip_tl { noskip } +\bool_set_false:N \l_xephm_kashida_hm_fix_bool + +\tl_new:N \l_xephm_gap_filler_tl + +\bool_set_false:N \l_xephm_linebreakpenalty_bool + +\int_new:N \l_xephm_line_break_penalty_int +\int_new:N \l_xephm_min_penalty_int +\int_new:N \l_xephm_low_penalty_int +\int_new:N \l_xephm_med_penalty_int +\int_new:N \l_xephm_high_penalty_int +\int_new:N \l_xephm_max_penalty_int + +\int_set:Nn \l_xephm_min_penalty_int { 0 } +\int_set:Nn \l_xephm_low_penalty_int { 8 } +\int_set:Nn \l_xephm_med_penalty_int { 15 } +\int_set:Nn \l_xephm_high_penalty_int { 25 } +\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_kayhan_tl { kayhan } +\tl_set:Nn \l_xephm_khorramshahr_tl { khorramshahr } +\tl_set:Nn \l_xephm_kayhannavaar_tl { kayhannavaar } +\tl_set:Nn \l_xephm_kayhanpook_tl { kayhanpook } +\tl_set:Nn \l_xephm_kayhansayeh_tl { kayhansayeh } +\tl_set:Nn \l_xephm_khoramshahr_tl { khoramshahr } +\tl_set:Nn \l_xephm_khorramshahr_tl { khorramshahr } +\tl_set:Nn \l_xephm_niloofar_tl { niloofar } +\tl_set:Nn \l_xephm_paatch_tl { paatch } +\tl_set:Nn \l_xephm_riyaz_tl { riyaz } +\tl_set:Nn \l_xephm_roya_tl { roya } +\tl_set:Nn \l_xephm_shafigh_tl { shafigh } +\tl_set:Nn \l_xephm_shafighKurd_tl { shafighKurd } +\tl_set:Nn \l_xephm_shafighUzbek_tl { shafighUzbek } +\tl_set:Nn \l_xephm_shiraz_tl { shiraz } +\tl_set:Nn \l_xephm_sols_tl { sols } +\tl_set:Nn \l_xephm_tabriz_tl { tabriz } +\tl_set:Nn \l_xephm_titr_tl { titr } +\tl_set:Nn \l_xephm_titre_tl { titre } +\tl_set:Nn \l_xephm_traffic_tl { traffic } +\tl_set:Nn \l_xephm_vahid_tl { vahid } +\tl_set:Nn \l_xephm_vosta_tl { vosta } +\tl_set:Nn \l_xephm_yaghut_tl { yaghut } +\tl_set:Nn \l_xephm_yagut_tl { yagut } +\tl_set:Nn \l_xephm_yas_tl { yas } +\tl_set:Nn \l_xephm_yekan_tl { yekan } +\tl_set:Nn \l_xephm_yermook_tl { yermook } +\tl_set:Nn \l_xephm_zar_tl { zar } +\tl_set:Nn \l_xephm_ziba_tl { ziba } +\tl_set:Nn \l_xephm_default_tl { default } +\tl_set:Nn \l_xephm_noskip_tl { noskip } \keys_define:nn { xepersian-hm } { - Kashida .code:n = \tex_input:D { kashida-xepersian-hm.def } , - - kashidastretch .code:n = + Kashida .code:n = { \tl_set:Nn \l_tmpa_tl { #1 } \tl_case:NnTF \l_tmpa_tl { - \l_kayhan_tl { \tl_set:Nn \l_hskip_default_tl { 0.14 em plus 0.5 em } } - \l_khorramshahr_tl { \tl_set:Nn \l_hskip_default_tl { 0.131 em plus 0.5 em } } - \l_kayhannavaar_tl { \tl_set:Nn \l_hskip_default_tl { 0.129 em plus 0.5 em } } - \l_kayhanpook_tl { \tl_set:Nn \l_hskip_default_tl { 0.133 em plus 0.5 em } } - \l_kayhansayeh_tl { \tl_set:Nn \l_hskip_default_tl { 0.135 em plus 0.5 em } } - \l_khoramshahr_tl { \tl_set:Nn \l_hskip_default_tl { 0.128 em plus 0.5 em } } - \l_khorramshahr_tl { \tl_set:Nn \l_hskip_default_tl { 0.13 em plus 0.5 em } } - \l_niloofar_tl { \tl_set:Nn \l_hskip_default_tl { 0.132 em plus 0.5 em } } - \l_paatch_tl { \tl_set:Nn \l_hskip_default_tl { 0.127 em plus 0.5 em } } - \l_riyaz_tl { \tl_set:Nn \l_hskip_default_tl { 0.125 em plus 0.5 em } } - \l_roya_tl { \tl_set:Nn \l_hskip_default_tl { 0.142 em plus 0.5 em } } - \l_shafigh_tl { \tl_set:Nn \l_hskip_default_tl { 0.143 em plus 0.5 em } } - \l_shafighKurd_tl { \tl_set:Nn \l_hskip_default_tl { 0.126 em plus 0.5 em } } - \l_shafighUzbek_tl { \tl_set:Nn \l_hskip_default_tl { 0.123 em plus 0.5 em } } - \l_shiraz_tl { \tl_set:Nn \l_hskip_default_tl { 0.122 em plus 0.5 em } } - \l_sols_tl { \tl_set:Nn \l_hskip_default_tl { 0.124 em plus 0.5 em } } - \l_tabriz_tl { \tl_set:Nn \l_hskip_default_tl { 0.119 em plus 0.5 em } } - \l_titr_tl { \tl_set:Nn \l_hskip_default_tl { 0.12 em plus 0.5 em } } - \l_titre_tl { \tl_set:Nn \l_hskip_default_tl { 0.121 em plus 0.5 em } } - \l_traffic_tl { \tl_set:Nn \l_hskip_default_tl { 0.124 em plus 0.5 em } } - \l_vahid_tl { \tl_set:Nn \l_hskip_default_tl { 0.134 em plus 0.5 em } } - \l_vosta_tl { \tl_set:Nn \l_hskip_default_tl { 0.136 em plus 0.5 em } } - \l_yaghut_tl { \tl_set:Nn \l_hskip_default_tl { 0.138 em plus 0.5 em } } - \l_yagut_tl { \tl_set:Nn \l_hskip_default_tl { 0.137 em plus 0.5 em } } - \l_yas_tl { \tl_set:Nn \l_hskip_default_tl { 0.126 em plus 0.5 em } } - \l_yekan_tl { \tl_set:Nn \l_hskip_default_tl { 0.141 em plus 0.5 em } } - \l_yermook_tl { \tl_set:Nn \l_hskip_default_tl { 0.139 em plus 0.5 em } } - \l_zar_tl { \tl_set:Nn \l_hskip_default_tl { 0.116 em plus 0.5 em } } - \l_ziba_tl { \tl_set:Nn \l_hskip_default_tl { 0.119 em plus 0.5 em } } - \l_default_tl { \tl_set:Nn \l_hskip_default_tl { 0.14 em plus 0.5 em } } - \l_noskip_tl { \tl_set:Nn \l_hskip_default_tl { 0 em plus 0.5 em } } - } { } { \tl_set:Nn \l_hskip_default_tl { #1 } } + \l_xephm_stretch_glyph_tl { \tl_set:Nn \l_xephm_gap_filler_tl { \l_xephm_stretch_glyph_tl } } + \l_xephm_stretch_hrule_tl { \tl_set:Nn \l_xephm_gap_filler_tl { \l_xephm_stretch_hrule_tl } } + } { } { \tl_set:Nn \l_xephm_filler_default_tl { #1 } } + \bool_set_true:N \l_xephm_kashida_hm_fix_bool + \tex_input:D { kashida-xepersian-hm.def } + } , + + linebreakpenalty .code:n = + { + \int_set:Nn \l_tmpa_int { #1 } + \int_case:nnTF \l_tmpa_int + { + \l_xephm_min_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_min_penalty_int } } + \l_xephm_low_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_low_penalty_int } } + \l_xephm_med_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_med_penalty_int } } + \l_xephm_high_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_high_penalty_int } } + \l_xephm_max_penalty_int { \int_set:Nn \l_xephm_line_break_penalty_int { \l_xephm_max_penalty_int } } + } { } { \int_set:Nn \l_xephm_line_break_penalty_int { #1 } } + \bool_set_true:N \l_xephm_linebreakpenalty_bool + } , + + kashidastretch .code:n = + { + \tl_set:Nn \l_tmpb_tl { #1 } + \tl_case:NnTF \l_tmpb_tl + { + \l_xephm_kayhan_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.14 em plus 0.5 em } } + \l_xephm_khorramshahr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.131 em plus 0.5 em } } + \l_xephm_kayhannavaar_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.129 em plus 0.5 em } } + \l_xephm_kayhanpook_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.133 em plus 0.5 em } } + \l_xephm_kayhansayeh_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.135 em plus 0.5 em } } + \l_xephm_khoramshahr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.128 em plus 0.5 em } } + \l_xephm_khorramshahr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.13 em plus 0.5 em } } + \l_xephm_niloofar_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.132 em plus 0.5 em } } + \l_xephm_paatch_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.127 em plus 0.5 em } } + \l_xephm_riyaz_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.125 em plus 0.5 em } } + \l_xephm_roya_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.142 em plus 0.5 em } } + \l_xephm_shafigh_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.143 em plus 0.5 em } } + \l_xephm_shafighKurd_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.126 em plus 0.5 em } } + \l_xephm_shafighUzbek_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.123 em plus 0.5 em } } + \l_xephm_shiraz_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.122 em plus 0.5 em } } + \l_xephm_sols_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.124 em plus 0.5 em } } + \l_xephm_tabriz_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.119 em plus 0.5 em } } + \l_xephm_titr_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.12 em plus 0.5 em } } + \l_xephm_titre_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.121 em plus 0.5 em } } + \l_xephm_traffic_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.124 em plus 0.5 em } } + \l_xephm_vahid_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.134 em plus 0.5 em } } + \l_xephm_vosta_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.136 em plus 0.5 em } } + \l_xephm_yaghut_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.138 em plus 0.5 em } } + \l_xephm_yagut_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.137 em plus 0.5 em } } + \l_xephm_yas_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.126 em plus 0.5 em } } + \l_xephm_yekan_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.141 em plus 0.5 em } } + \l_xephm_yermook_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.139 em plus 0.5 em } } + \l_xephm_zar_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.116 em plus 0.5 em } } + \l_xephm_ziba_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.119 em plus 0.5 em } } + \l_xephm_default_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0.14 em plus 0.5 em } } + \l_xephm_noskip_tl { \tl_set:Nn \l_xephm_hskip_default_tl { 0 em plus 0.5 em } } + } { } { \tl_set:Nn \l_xephm_hskip_default_tl { #1 } } } , - kashidastretch .default:n = \tl_set:Nn \l_hskip_default_tl { 0 em plus 0.5 em } , + kashidastretch .default:n = \tl_set:Nn \l_xephm_hskip_default_tl { 0 em plus 0.5 em } , } \ProcessKeysOptions { xepersian-hm } |