From 788fcfc57037c4c25d9c6136eca5ef7600847f98 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 28 Oct 2019 20:55:00 +0000 Subject: luabidi (28oct19) git-svn-id: svn://tug.org/texlive/trunk@52549 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/lualatex/luabidi/arabmaths.tex | 2 - .../tex/lualatex/luabidi/autofootnoterule.tex | 116 --------------------- .../tex/lualatex/luabidi/luabidi-arabmaths.def | 11 ++ .../lualatex/luabidi/luabidi-autofootnoterule.def | 72 +++++++++++++ .../tex/lualatex/luabidi/luabidi-footnotes.def | 76 ++++++++++++++ .../lualatex/luabidi/luabidi-test-arabmaths.tex | 13 +++ Master/texmf-dist/tex/lualatex/luabidi/luabidi.sty | 52 ++++++--- .../tex/lualatex/luabidi/textwidthfootnoterule.tex | 2 - 8 files changed, 210 insertions(+), 134 deletions(-) delete mode 100644 Master/texmf-dist/tex/lualatex/luabidi/arabmaths.tex delete mode 100644 Master/texmf-dist/tex/lualatex/luabidi/autofootnoterule.tex create mode 100644 Master/texmf-dist/tex/lualatex/luabidi/luabidi-arabmaths.def create mode 100644 Master/texmf-dist/tex/lualatex/luabidi/luabidi-autofootnoterule.def create mode 100644 Master/texmf-dist/tex/lualatex/luabidi/luabidi-footnotes.def create mode 100644 Master/texmf-dist/tex/lualatex/luabidi/luabidi-test-arabmaths.tex delete mode 100644 Master/texmf-dist/tex/lualatex/luabidi/textwidthfootnoterule.tex (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/lualatex/luabidi/arabmaths.tex b/Master/texmf-dist/tex/lualatex/luabidi/arabmaths.tex deleted file mode 100644 index e125dce795e..00000000000 --- a/Master/texmf-dist/tex/lualatex/luabidi/arabmaths.tex +++ /dev/null @@ -1,2 +0,0 @@ -\mathdir TRT -\def\@eqnnum{{\normalfont \normalcolor \textdir TLT ({\textdir TRT\theequation})}} diff --git a/Master/texmf-dist/tex/lualatex/luabidi/autofootnoterule.tex b/Master/texmf-dist/tex/lualatex/luabidi/autofootnoterule.tex deleted file mode 100644 index f7706946522..00000000000 --- a/Master/texmf-dist/tex/lualatex/luabidi/autofootnoterule.tex +++ /dev/null @@ -1,116 +0,0 @@ -\ifx \CatEscape\undefined - \chardef\CatEscape=0 - \chardef\CatOpen=1 - \chardef\CatClose=2 - \chardef\CatIgnore=9 - \chardef\CatLetter=11 - \chardef\CatOther=12 - \chardef\CatActive=13 % is defined in Plain already - - \chardef\CatUsCode=\catcode`\_ -\fi - -\catcode`\_=\CatLetter % top level macro file - - -\def\l@fn{% - \hbox to \columnwidth - {\pagedir TLT\vbox{\kern -3\p@ - \hrule width .4\columnwidth \kern2.6\p@}\hfil}} -\def\r@fn{% - \hrule width .4\columnwidth\kern 2.6\p@} - - -\def\@makefnmark{\hbox{$^{\hbox{\scriptsize\@thefnmark}}\m@th$}} - - -\def\leftfootnoterule{\global\def\footnoterule{\l@fn}} -\def\rightfootnoterule{\global\def\footnoterule{\r@fn}} -\leftfootnoterule - -%%% \beginprog -\newread\old_foot_file -\newwrite\foot_file -\def\foot_file_name{\jobname.fot\relax} -\def\init_footnote{% - \openin\old_foot_file\foot_file_name - \ifeof\old_foot_file \closein\old_foot_file - \else \closein\old_foot_file - \read_foot_file - \fi - \immediate\openout\foot_file\foot_file_name - \immediate\write\foot_file{\relax}% - \global\let\init_footnote\relax - } - -\newcount\foot_name_no % for generating footnote mark names - - - - - -\newcount\autofootnote -\def\fnpp_next_footnote{% - \init_footnote - \global\advance\foot_name_no\@ne - \global\advance\c@footnote\@ne - \edef\do_write{% - \immediate\write\foot_file{% - \string\advance\autofootnote\@ne - \string\expandafter\xdef - \string\csname\space f@\number\foot_name_no \endcsname{% - \string\number\autofootnote - }% - }% - }% - \do_write - \global\autofootnote 0\csname f@\number\foot_name_no \endcsname \relax - } - -\def\read_foot_file{% - \begingroup - \catcode`\@\CatLetter \catcode`\^^M\CatIgnore - \input \foot_file_name - \endgroup - } - -\let\fnpp_orig_outputpage=\@outputpage -\def\@outputpage{% - \ifx \init_footnote\relax - \immediate\write\foot_file{\autofootnote\z@}% - \fi - \fnpp_orig_outputpage - } - -\let\FnppOrigFootnote=\footnote % save original bindings -\let\FnppOrigFootnotemark=\footnotemark - -\def\footnote{% - \@ifnextchar[% % ] (Emacs) - \@xfootnote - {\fnpp_next_footnote \ifnum\autofootnote=1\rightfootnoterule\fi \@xfootnote[\the\c@footnote] % -}% - } -\def\footnotemark{% - \@ifnextchar[% % ] (Emacs) - \@xfootnotemark - {\fnpp_next_footnote \ifnum\autofootnote=1\rightfootnoterule\fi \@xfootnotemark[\the\c@footnote]}% - } - - - - -\def\footnotemarkLR{% - \@ifnextchar[% % ] (Emacs) - \@xfootnotemark - {\fnpp_next_footnote \ifnum\autofootnote=1\leftfootnoterule\fi\@xfootnotemark[\the\c@footnote]}% - } - - -\def\Footnote#1{% -\begingroup -\footnotemarkLR% -\renewcommand{\thefootnote}{\@arabic\c@footnote}% -\pardir TLT \textdir TLT\footnotetext{#1}% -\endgroup -} diff --git a/Master/texmf-dist/tex/lualatex/luabidi/luabidi-arabmaths.def b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-arabmaths.def new file mode 100644 index 00000000000..8e2eaf30284 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-arabmaths.def @@ -0,0 +1,11 @@ +%% This file is luabidi-arabmaths.def +%% This is part of the luabidi package +%% +%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller +%% +%%%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. + +\mathdir TRT +\def\@eqnnum{{\normalfont \normalcolor \textdir TLT ({\textdir TRT\theequation})}} diff --git a/Master/texmf-dist/tex/lualatex/luabidi/luabidi-autofootnoterule.def b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-autofootnoterule.def new file mode 100644 index 00000000000..a9f0cbe21fc --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-autofootnoterule.def @@ -0,0 +1,72 @@ +%% This file is luabidi-autofootnoterule.def +%% This is part of the luabidi package +%% +%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller +%% +%%%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. + + +% +% Determine first footnote on current page +% + +\RequirePackage{perpage} +\newcounter{pagefnt} +\setcounter{pagefnt}{0} +\MakePerPage[0]{pagefnt} + + +% +% Footnote redefinitions +% + +% Save original definitions +\let\FnppOrigFootnote=\footnote +\let\FnppOrigFootnotemark=\footnotemark + +% Default: left-aligned rule +\leftfootnoterule + +% \footnote +\def\footnote{% + \@ifnextchar[% % ] (Editor) + \@xfootnote + {\stepcounter\@mpfn\stepcounter{pagefnt}% + \ifnum\value{pagefnt}=0% + \if@RTL% + \rightfootnoterule% + \else% + \leftfootnoterule% + \fi% + \fi% + \@xfootnote[\the\c@footnote]% + }% +} + +% \RTLfootnote +\def\footnotemarkRL{% + \@ifnextchar[% % ] (Editor) + \@xfootnotemark + {\stepcounter\@mpfn\stepcounter{pagefnt}% + \ifnum\value{pagefnt}=0% + \rightfootnoterule% + \fi% + \@xfootnotemark[\the\c@footnote]% + }% +} + +% \LTRfootnote +\def\footnotemarkLR{% + \@ifnextchar[% % ] (Editor) + \@xfootnotemark + {\stepcounter\@mpfn\stepcounter{pagefnt}% + \ifnum\value{pagefnt}=0% + \leftfootnoterule% + \fi% + \@xfootnotemark[\the\c@footnote]% + }% +} + +% Finis diff --git a/Master/texmf-dist/tex/lualatex/luabidi/luabidi-footnotes.def b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-footnotes.def new file mode 100644 index 00000000000..db185e2578d --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-footnotes.def @@ -0,0 +1,76 @@ +%% This file is luabidi-footnotes.def +%% This is part of the luabidi package +%% +%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller +%% +%%%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. + +% +% Footnotes +% + +% These are defined in polyglossia. Provide simple fallbacks +\providecommand*\localnumeral{\@ifstar\@@localnumeral\@localnumeral} + +\providecommand*\@localnumeral[1]{#1} +\providecommand*\@@localnumeral[1]{% + \protect\@arabic\csuse{c@#1}% +} + +\let\footnotemarkLR\footnotemark +\let\footnotemarkRL\footnotemark + +\providecommand\LTRfootnote[2][]{% + \begingroup + \ifx#1\\\\\footnotemarkLR + \renewcommand{\thefootnote}{\localnumeral*{footnote}}% + \else% + \footnotemarkLR[#1]% + \renewcommand{\thefootnote}{\localnumeral{#1}}% + \fi + \pardir TLT \textdir TLT\footnotetext{#2}% + \endgroup +} + +\providecommand\RTLfootnote[2][]{% + \begingroup + \ifx#1\\\\\footnotemarkRL% + \renewcommand{\thefootnote}{\localnumeral*{footnote}}% + \else% + \footnotemarkRL[#1]% + \renewcommand{\thefootnote}{\localnumeral{#1}}% + \fi + \pardir TRT \textdir TRT\footnotetext{#2}% + \endgroup +} + +% backwards compatibility +\def\Footnote#1{\LTRfootnote{#1}} + +% +% Footnote rules +% + +% adjustable rule length +\newlength\footnoterulewidth +\setlength\footnoterulewidth{.4\columnwidth} + +% The left, right and full width rules +\def\luabidi@left@fn{% + \hbox to \columnwidth + {\pagedir TLT\textdir TLT\vbox{\kern -3\p@ + \hrule\@width\footnoterulewidth\kern2.6\p@}\hfil}} +\def\luabidi@right@fn{% + \pagedir TRT\textdir TRT\hrule\@width\footnoterulewidth\kern2.6\p@} +\def\luabidi@textwidth@fn{% + \kern-3\p@\hrule\@width\textwidth\kern2.6\p@} + +% switches for the rule position +\def\leftfootnoterule{\global\def\footnoterule{\luabidi@left@fn}} +\def\rightfootnoterule{\global\def\footnoterule{\luabidi@right@fn}} +\def\textwidthfootnoterule{\global\def\footnoterule{\luabidi@textwidth@fn}} +\def\autofootnoterule{\luabidi@autofootnoteruletrue} + +% Finis diff --git a/Master/texmf-dist/tex/lualatex/luabidi/luabidi-test-arabmaths.tex b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-test-arabmaths.tex new file mode 100644 index 00000000000..1b51109ad46 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luabidi/luabidi-test-arabmaths.tex @@ -0,0 +1,13 @@ +\documentclass[12pt]{article} +\usepackage[arabmaths]{luabidi} +\begin{document} +\setRTLmain +\section{ghesmate 1} + +in yek ghesmat ast ke an ra dar inja minevisam + +\begin{equation} +1+2=3 +\end{equation} +in ham dobare masalei ast ke man minevisam va shoma an ra mibinid. +\end{document} diff --git a/Master/texmf-dist/tex/lualatex/luabidi/luabidi.sty b/Master/texmf-dist/tex/lualatex/luabidi/luabidi.sty index abc1d2a9367..4277a1f1738 100644 --- a/Master/texmf-dist/tex/lualatex/luabidi/luabidi.sty +++ b/Master/texmf-dist/tex/lualatex/luabidi/luabidi.sty @@ -1,4 +1,5 @@ %% This file is luabidi.sty +%% This is part of the luabidi package %% %% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller %% @@ -6,11 +7,30 @@ %% conditions of the LaTeX Project Public License, either version 1.3c %% of this license or (at your option) any later version. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luabidi}[2019/08/24 v0.4 +\ProvidesPackage{luabidi}[2019/10/27 v0.5 Bidirectional typesetting in LuaTeX] + +\RequirePackage{etoolbox} + +% +% Package options +% + +\DeclareOption{arabmaths}{\input{luabidi-arabmaths.def}} +\newif\ifluabidi@autofootnoterule +\DeclareOption{autofootnoterule}{\luabidi@autofootnoteruletrue} +\newif\ifluabidi@textwidthfootnoterule +\DeclareOption{textwidthfootnoterule}{\luabidi@textwidthfootnoteruletrue} +\ProcessOptions + +% +% General command and switches +% + \newif\if@RTL \newif\if@RTLmain -\def\setRTLmain{\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT} +\@RTLmainfalse +\def\setRTLmain{\@RTLmaintrue\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT} \def\setRTL{\@RTLtrue\pardir TRT \textdir TRT} \let\setRL=\setRTL \def\setLTR{\@RTLfalse\pardir TLT \textdir TLT} @@ -25,9 +45,6 @@ \def\@ensure@LTR#1{\if@RTL\LRE{#1}\else{#1}\fi} \def\@ensure@dir#1{\if@RTL\RLE{#1}\else{#1}\fi} \let\@ensure@maindir=\@ensuredir -\@RTLmainfalse -\DeclareOption{arabmaths}{\input{arabmaths}} -\DeclareOption{textwidthfootnoterule}{\input{textwidthfootnoterule}} \let\n@xt=\ \DeclareRobustCommand*\LRE{\protect\pLRE} \def\pLRE{\protect\afterassignment\moreLRE \let\n@xt= } @@ -39,18 +56,25 @@ \def\moreRLE{\bracetext \aftergroup\unsetRTL \setRTL\@RTLtrue} \let\LR=\LRE \let\RL=\RLE +\def\hboxR#1{\hbox{\RL{#1}}} -\def\Footnote#1{% -\begingroup -\footnotemark -\renewcommand{\thefootnote}{\@arabic\c@footnote}% -\pardir TLT \textdir TLT\footnotetext{#1}% -\endgroup -} +% +% Footnotes +% -\DeclareOption{autofootnoterule}{\input{autofootnoterule}} +\input{luabidi-footnotes.def} +\ifluabidi@textwidthfootnoterule + \textwidthfootnoterule +\fi +% This needs to be loaded late because of the switch +\AtEndPreamble{% + \makeatletter + \ifluabidi@autofootnoterule + \input{luabidi-autofootnoterule.def} + \fi + \makeatother +} -\ProcessOptions \endinput diff --git a/Master/texmf-dist/tex/lualatex/luabidi/textwidthfootnoterule.tex b/Master/texmf-dist/tex/lualatex/luabidi/textwidthfootnoterule.tex deleted file mode 100644 index 7fc71e0cefc..00000000000 --- a/Master/texmf-dist/tex/lualatex/luabidi/textwidthfootnoterule.tex +++ /dev/null @@ -1,2 +0,0 @@ -\def\footnoterule{\kern-3\p@ - \hrule \@width \textwidth \kern 2.6\p@} -- cgit v1.2.3