diff options
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty | 171 |
1 files changed, 109 insertions, 62 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty b/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty index 9b147193c61..3711c5bd7b1 100644 --- a/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty +++ b/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty @@ -17,7 +17,7 @@ %% by Vafa Khalighi. %% %% -%% \CheckSum{10207} +%% \CheckSum{10291} %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z @@ -35,8 +35,8 @@ %% Right brace \} Tilde \~} %% \NeedsTeXFormat{LaTeX2e} -\def\xepersianversion{v17.2} -\def\xepersiandate{2017/01/16} +\def\xepersianversion{v17.3} +\def\xepersiandate{2017/02/04} \ProvidesPackage{xepersian}[\xepersiandate\space \xepersianversion\space Persian typesetting in XeLaTeX] \RequirePackage{fontspec} @@ -116,74 +116,72 @@ Persian typesetting in XeLaTeX] \newfontscript{Parsi}{arab} \newfontlanguage{Parsi}{FAR} \ExplSyntaxOn -\DeclareDocumentCommand \settextfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_settextfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_settextfont:nn +\DeclareDocumentCommand \settextfont { O{} m O{} } { - \fontspec_set_family:cnn { g__fontspec_ \cs_to_str:N \persianfont _family } {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1} {#2} - \use:x + \fontspec_set_family:Nnn \g__xepersian_persianfont_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \rmdefault \g__xepersian_persianfont_family + \use:x { \exp_not:n { \DeclareRobustCommand \persianfont } { - \exp_not:N \DeclareRobustCommand \exp_not:N \persianfont - { - \exp_not:N \fontfamily { \use:c {g__fontspec_ \cs_to_str:N \persianfont _family} } - \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } - \exp_not:N \selectfont - } + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_persianfont_family } + \exp_not:N \selectfont } - \cs_set_eq:NN \rmdefault \l_fontspec_family_tl + } + \str_if_eq_x:nnT {\familydefault} {\rmdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont + \ignorespaces } -\DeclareDocumentCommand \setlatintextfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setlatintextfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setlatintextfont:nn +\DeclareDocumentCommand \setlatintextfont { O{} m O{} } { - \fontspec_set_family:cnn { g__fontspec_ \cs_to_str:N \latinfont _family } {Mapping=tex-text,#1} {#2} - \use:x + \fontspec_set_family:Nnn \g__xepersian_latinfont_family {Mapping=tex-text,#1,#3} {#2} + \tl_set_eq:NN \rmdefault \g__xepersian_latinfont_family + \use:x { \exp_not:n { \DeclareRobustCommand \latinfont } { - \exp_not:N \DeclareRobustCommand \exp_not:N \latinfont - { - \exp_not:N \fontfamily { \use:c {g__fontspec_ \cs_to_str:N \latinfont _family} } - \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } - \exp_not:N \selectfont - } + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_latinfont_family } + \exp_not:N \selectfont } + } + \str_if_eq_x:nnT {\familydefault} {\rmdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } + \normalfont + \ignorespaces } -\cs_set_eq:NN \setlatinsansfont \setsansfont -\cs_set_eq:NN \setlatinmonofont \setmonofont -\DeclareDocumentCommand \defpersianfont { m o m } - { \__fontspec_pass_args:nnn { \__xepersian_defpersianfont:Nnn #1 } {#2} {#3} } -\cs_new:Nn \__xepersian_defpersianfont:Nnn +\tl_set_eq:NN \setlatinsansfont \setsansfont +\tl_set_eq:NN \setlatinmonofont \setmonofont + +\DeclareDocumentCommand \defpersianfont { m O{} m O{} } { - \fontspec_set_family:cnn { g__fontspec_ \cs_to_str:N #1 _family } {Script=Parsi,Language=Parsi,Mapping=parsidigits,#2} {#3} + \fontspec_set_family:cnn { g__xepersian_ \cs_to_str:N #1 _family } {Script=Parsi,Language=Parsi,Mapping=parsidigits,#2,#4} {#3} \use:x { \exp_not:N \DeclareRobustCommand \exp_not:N #1 { - \exp_not:N \fontfamily { \use:c {g__fontspec_ \cs_to_str:N #1 _family} } + \exp_not:N \fontfamily { \use:c {g__xepersian_ \cs_to_str:N #1 _family} } \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } \exp_not:N \selectfont } } } -\DeclareDocumentCommand \deflatinfont { m o m } - { \__fontspec_pass_args:nnn { \__xepersian_deflatinfont:Nnn #1 } {#2} {#3} } -\cs_new:Nn \__xepersian_deflatinfont:Nnn +\DeclareDocumentCommand \deflatinfont { m O{} m O{} } { - \fontspec_set_family:cnn { g__fontspec_ \cs_to_str:N #1 _family } {Mapping=tex-text,#2} {#3} + \fontspec_set_family:cnn { g__xepersian_ \cs_to_str:N #1 _family } {Mapping=tex-text,#2,#4} {#3} \use:x { \exp_not:N \DeclareRobustCommand \exp_not:N #1 { - \exp_not:N \fontfamily { \use:c {g__fontspec_ \cs_to_str:N #1 _family} } + \exp_not:N \fontfamily { \use:c {g__xepersian_ \cs_to_str:N #1 _family} } \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } \exp_not:N \selectfont } } } + \newcommand\persiansfdefault{} \newcommand\persianttdefault{} \newcommand\iranicdefault{} @@ -214,60 +212,109 @@ Persian typesetting in XeLaTeX] \DeclareTextFontCommand{\textnavar}{\navarfamily} \DeclareTextFontCommand{\textpook}{\pookfamily} \DeclareTextFontCommand{\textsayeh}{\sayehfamily} -\DeclareDocumentCommand \setpersiansansfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setpersiansansfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setpersiansansfont:nn +\DeclareDocumentCommand \setpersiansansfont { O{} m O{} } { - \fontspec_set_family:Nnn \persiansfdefault {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2} + \fontspec_set_family:Nnn \g__xepersian_persiansffamily_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \persiansfdefault \g__xepersian_persiansffamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \persiansffamily } + { + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_persiansffamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\persiansfdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont \ignorespaces } -\DeclareDocumentCommand \setpersianmonofont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setpersianmonofont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setpersianmonofont:nn +\DeclareDocumentCommand \setpersianmonofont { O{} m O{} } { - \fontspec_set_family:Nnn \persianttdefault {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2} + \fontspec_set_family:Nnn \g__xepersian_persianttfamily_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \persianttdefault \g__xepersian_persianttfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \persianttfamily } + { + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_persianttfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\persianttdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont \ignorespaces } -\DeclareDocumentCommand \setnavarfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setnavarfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setnavarfont:nn +\DeclareDocumentCommand \setnavarfont { O{} m O{} } { - \fontspec_set_family:Nnn \navardefault {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2} + \fontspec_set_family:Nnn \g__xepersian_navarfamily_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \navardefault \g__xepersian_navarfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \navarfamily } + { + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_navarfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\navardefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont \ignorespaces } -\DeclareDocumentCommand \setpookfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setpookfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setpookfont:nn +\DeclareDocumentCommand \setpookfont { O{} m O{} } { - \fontspec_set_family:Nnn \pookdefault {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2} + \fontspec_set_family:Nnn \g__xepersian_pookfamily_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \pookdefault \g__xepersian_pookfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \pookfamily } + { + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_pookfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\pookdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont \ignorespaces } -\DeclareDocumentCommand \setsayehfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setsayehfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setsayehfont:nn +\DeclareDocumentCommand \setsayehfont { O{} m O{} } { - \fontspec_set_family:Nnn \sayehdefault {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2} + \fontspec_set_family:Nnn \g__xepersian_sayehfamily_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \sayehdefault \g__xepersian_sayehfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \sayehfamily } + { + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_sayehfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\sayehdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont \ignorespaces } -\DeclareDocumentCommand \setiranicfont { o m } - { \__fontspec_pass_args:nnn \__xepersian_setiranicfont:nn {#1} {#2} } -\cs_new:Nn \__xepersian_setiranicfont:nn +\DeclareDocumentCommand \setiranicfont { O{} m O{} } { - \fontspec_set_family:Nnn \iranicdefault {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2} + \fontspec_set_family:Nnn \g__xepersian_iranicfamily_family {Script=Parsi,Language=Parsi,Mapping=parsidigits,#1,#3} {#2} + \tl_set_eq:NN \iranicdefault \g__xepersian_iranicfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \iranicfamily } + { + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__xepersian_iranicfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\iranicdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } \normalfont \ignorespaces } + \ExplSyntaxOff \def\resetlatinfont{% \let\normalfont\latinfont% |