[latex3-commits] [git/LaTeX3-latex3-babel] master: mapdigits. box dir in math. (f68dbfc)

Javier jbezos at dante.de
Mon Apr 8 16:40:33 CEST 2019


Repository : https://github.com/latex3/babel
On branch  : master
Link       : https://github.com/latex3/babel/commit/f68dbfc3c4668c35196b8816ad3d11f28a9e4aa7

>---------------------------------------------------------------

commit f68dbfc3c4668c35196b8816ad3d11f28a9e4aa7
Author: Javier <jbezos at localhost>
Date:   Mon Apr 8 16:40:33 2019 +0200

    mapdigits. box dir in math.
    
    * Conversion of digits with lua. First steps (only global) for testing.
    * New attempt to set the box dir in math (which requires a patch bacause of a bug in luatex <1.10).
    * Bidi can be disabled.


>---------------------------------------------------------------

f68dbfc3c4668c35196b8816ad3d11f28a9e4aa7
 README.md    |    4 +-
 babel.dtx    |  154 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 babel.ins    |    2 +-
 babel.pdf    |  Bin 674167 -> 678923 bytes
 bbcompat.dtx |    2 +-
 5 files changed, 131 insertions(+), 31 deletions(-)

diff --git a/README.md b/README.md
index 912b1bb..4460cb3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.29
+## Babel 3.29.1605
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages.  Many
@@ -128,5 +128,5 @@ respective authors.
 ```
 
 Javier Bezos
-2019/04/03
+2019/04/08
 
diff --git a/babel.dtx b/babel.dtx
index f182740..994ec88 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2019/04/03 v3.29 The Babel package]
+\ProvidesFile{babel.dtx}[2019/04/08 v3.29.1605 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -1099,7 +1099,8 @@ can take the following values:
 \end{description}
 
 \Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
-  $\string|$ \texttt{basic-r}}
+  $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+  \texttt{bidi-r}}
 
 \New{3.14} Selects the bidi algorithm to be used in \luatex{} and
 \xetex{}. See sec.~\ref{bidi}.
@@ -1936,6 +1937,18 @@ to select fonts in addition to the three basic families.
   for that matter).
 \end{warning}
 
+\begin{troubleshooting}
+\trouble{Package fontspec Warning: 'Language 'LANG' not available for
+font 'FONT' with script 'SCRIPT' 'Default' language used instead'}
+\textit{Package fontspec Warning: 'Language 'LANG' not available for
+font 'FONT' with script 'SCRIPT' 'Default' language used instead'}.
+This warning is shown by \textsf{fontspec}, not by \babel. It could be
+irrelevant for English, but not for many other languages, including
+Urdu and Turkish. This is a useful and harmless warning, and if
+everything is fine with your document the best thing you can do is just
+to ignore it altogether.
+\end{troubleshooting}
+
 \subsection{Modifying a language}
 
 Modifying the behavior of a language (say, the chapter “caption”), is
@@ -2105,10 +2118,10 @@ inconsistent, this makes setting a language up easier in most typical
 cases.
 
 \Describe{mapfont=}{\texttt{direction}}
-Assigns the font for the writing direction of this
-language.\footnote{There will be another value, \texttt{language}, not
-yet implemented.} More precisely, what |mapfont=direction| means is,
-‘when a character has the same direction as the script for the
+Assigns the font for the writing direction of this language (only with
+|bidi=basic|).\footnote{There will be another value, \texttt{language},
+not yet implemented.} More precisely, what |mapfont=direction| means
+is, ‘when a character has the same direction as the script for the
 “provided” language, then change its font to that set for this
 language’. There are 3 directions, following the bidi Unicode
 algorithm, namely, Arabic-like, Hebrew-like and left to
@@ -2375,17 +2388,25 @@ differ in the way `weak' numeric characters are ordered (eg, Arabic
 There are some package options controlling bidi writing.
 
 \Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
-  $\string|$ \texttt{basic-r}}
+  $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+  \texttt{bidi-l}}
 
 \New{3.14} Selects the bidi algorithm to be used. With |default| the
 bidi mechanism is just activated (by default it is not), but every
 change must by marked up. In \xetex{} and \pdftex{} this is the only
-option. In \luatex, |basic-r| provides a simple and fast method for R
+option.
+
+In \luatex, |basic-r| provides a simple and fast method for R
 text, which handles numbers and unmarked L text within an R context in
-typical cases. \New{3.19} Finally, |basic| supports both L and R text.
+typical cases. \New{3.19} Finally, |basic| supports both L and R text
+and it is the preferred method (support for |basic-r| is now limited).
 (They are named \texttt{basic} mainly because they only consider the
 intrinsic direction of scripts and weak directionality.)
 
+In \xetex, |bidi-r| and |bidi-l| resort to the package \textsf{bidi}
+(by Vafa Khalighi). Integration is still somewhat tentative, but mostly
+works. For RL documents use the former, and for LR ones use the latter.
+
 There are samples on GitHub, under \texttt{/required/babel/samples}.
 See particularly |lua-bidibasic.tex| and |lua-secenum.tex|.
 
@@ -3917,8 +3938,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.29>>
-%<<date=2019/04/03>>
+%<<version=3.29.1605>>
+%<<date=2019/04/08>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -7801,6 +7822,7 @@ help from Bernd Raichle, for which I am grateful.
   \let\bbl at KVP@hyphenrules\@nil
   \let\bbl at KVP@mapfont\@nil
   \let\bbl at KVP@maparabic\@nil
+  \let\bbl at KVP@mapdigits\@nil
   \let\bbl at KVP@intraspace\@nil
   \let\bbl at KVP@intrapenalty\@nil
   \bbl at forkv{#1}{\bbl at csarg\def{KVP@##1}{##2}}%  TODO - error handling
@@ -7917,7 +7939,7 @@ help from Bernd Raichle, for which I am grateful.
         \fi}%
     \fi
   \fi
-  % Native digits, if provided in ini
+  % Native digits, if provided in ini (TeX level, xe and lua)
   \ifcase\bbl at engine\else
     \bbl at ifunset{bbl at dgnat@\languagename}{}%
       {\expandafter\ifx\csname bbl at dgnat@\languagename\endcsname\@empty\else
@@ -7934,6 +7956,28 @@ help from Bernd Raichle, for which I am grateful.
         \fi
       \fi}%
   \fi
+  % Native digits (lua level). First steps only, for testing
+  \ifodd\bbl at engine
+    \ifx\bbl at KVP@mapdigits\@nil\else
+      \bbl at tentative{mapdigits}%
+      \bbl at ifunset{bbl at dgnat@\languagename}{}%
+        {\directlua{
+           Babel = Babel or {}
+           Babel.digits_mapped = true
+           Babel.digits =
+             table.pack(string.utfvalue('\bbl at cs{dgnat@\languagename}'))
+           function Babel.numbers(head)
+             for item in node.traverse_id(node.id'glyph',head) do
+               local chr = item.char
+               if chr > 47 and chr < 58 then
+                 item.char = Babel.digits[chr-47]
+               end
+             end
+             return head
+           end
+         }}
+    \fi
+  \fi
   % To load or reaload the babel-*.tex, if require.babel in ini
   \bbl at ifunset{bbl at rqtex@\languagename}{}%
     {\expandafter\ifx\csname bbl at rqtex@\languagename\endcsname\@empty\else
@@ -9285,7 +9329,7 @@ help from Bernd Raichle, for which I am grateful.
       \fi
     \fi}
   \def\bbl at textdir#1{%
-    \bbl at setluadir{text}\textdir{#1}% TODO - ?\linedir
+    \bbl at setluadir{text}\textdir{#1}%
     \chardef\bbl at thetextdir#1\relax
     \setattribute\bbl at attr@dir{\numexpr\bbl at thepardir*3+#1}}
   \def\bbl at pardir#1{%
@@ -9298,9 +9342,9 @@ help from Bernd Raichle, for which I am grateful.
   % Activated every math with the package option bidi=:
   \def\bbl at mathboxdir{%
     \ifcase\bbl at thetextdir\relax
-      \everyhbox{\bgroup\aftergroup\egroup\textdir TLT\relax}%
+      \everyhbox{\textdir TLT\relax}%
     \else
-      \everyhbox{\bgroup\aftergroup\egroup\textdir TRT\relax}%
+      \everyhbox{\textdir TRT\relax}%
     \fi}
 \else % pdftex=0, xetex=2
   \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
@@ -10803,9 +10847,9 @@ help from Bernd Raichle, for which I am grateful.
   \DeclareOption{bidi=basic}%
     {\let\bbl at beforeforeign\leavevmode
      \newattribute\bbl at attr@dir
-     % TODO - the same trick as bbl at severypar
-     % \everymath{\bbl at mathboxdir}%
-     % \everydisplay{\bbl at mathboxdir}%
+     % TODO - the same trick as bbl at severypar? Or too strong?
+     \everymath{\bbl at mathboxdir}%
+     \everydisplay{\bbl at mathboxdir}%
      \bbl at exp{\output{\bodydir\pagedir\the\output}}%
      \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
 \else
@@ -11836,6 +11880,33 @@ help from Bernd Raichle, for which I am grateful.
 <@Font selection@>
 %    \end{macrocode}
 %
+% \textbf{Temporary} fix for luatex $<$1.10, which sometimes inserted a
+% spurious closing dir node with a |\textdir| within |\hbox|es. This
+% will be eventually removed.
+%
+%    \begin{macrocode}
+\def\bbl at luafixboxdir{%
+  \setbox\z@\hbox{\textdir TLT}%
+  \directlua{
+    function Babel.first_dir(head)
+      for item in node.traverse_id(node.id'dir', head) do
+        return item
+      end
+      return nil
+    end
+    if Babel.first_dir(tex.box[0].head) then
+      function Babel.fixboxdirs(head)
+        local fd = Babel.first_dir(head)
+        if fd and fd.dir:sub(1,1) == '-' then
+          head = node.remove(head, fd)
+        end
+        return head
+      end
+    end
+  }}
+\AtBeginDocument{\bbl at luafixboxdir}
+%    \end{macrocode}
+%
 % \subsection{Layout}
 %
 % \textbf{Work in progress}.
@@ -18122,6 +18193,8 @@ Babel.characters={
 %<*basic-r>
 Babel = Babel or {}
 
+Babel.bidi_enabled = true
+
 require('babel-bidi.lua')
 
 local characters = Babel.characters
@@ -18140,14 +18213,25 @@ local function dir_mark(head, from, to, outer)
 end
 
 function Babel.pre_otfload_v(head)
-  -- head = Babel.numbers(head)
-  head = Babel.bidi(head, true)
+  if Babel.numbers and Babel.digits_mapped then
+    head = Babel.numbers(head)
+  end
+  if Babel.bidi_enabled then
+    head = Babel.bidi(head, false, dir)
+  end
   return head
 end
 
 function Babel.pre_otfload_h(head)
-  -- head = Babel.numbers(head)
-  head = Babel.bidi(head, false)
+  if Babel.numbers and Babel.digits_mapped then
+    head = Babel.numbers(head)
+  end
+  if Babel.fixboxdirs then          -- Temporary!
+    head = Babel.fixboxdirs(head)
+  end
+  if Babel.bidi_enabled then
+    head = Babel.bidi(head, false, dir)
+  end
   return head
 end
 
@@ -18398,20 +18482,35 @@ end
 %<*basic>
 Babel = Babel or {}
 
+-- eg, Babel.fontmap[1][<prefontid>]=<dirfontid>
+
 Babel.fontmap = Babel.fontmap or {}
 Babel.fontmap[0] = {}      -- l
 Babel.fontmap[1] = {}      -- r
 Babel.fontmap[2] = {}      -- al/an
 
+Babel.bidi_enabled = true
+
 function Babel.pre_otfload_v(head)
-  -- head = Babel.numbers(head)
-  head = Babel.bidi(head, true)
+  if Babel.numbers and Babel.digits_mapped then
+    head = Babel.numbers(head)
+  end
+  if Babel.bidi_enabled then
+    head = Babel.bidi(head, false, dir)
+  end
   return head
 end
 
 function Babel.pre_otfload_h(head, gc, sz, pt, dir)
-  -- head = Babel.numbers(head)
-  head = Babel.bidi(head, false, dir)
+  if Babel.numbers and Babel.digits_mapped then
+    head = Babel.numbers(head)
+  end
+  if Babel.fixboxdirs then          -- Temporary!
+    head = Babel.fixboxdirs(head)
+  end
+  if Babel.bidi_enabled then
+    head = Babel.bidi(head, false, dir)
+  end
   return head
 end
 
@@ -18534,8 +18633,9 @@ function Babel.bidi(head, ispar, hdir)
       end
       d = d or 'l'
       if inmath then d = ('TRT' == tex.mathdir) and 'r' or 'l' end
-      d_font = d_font or d
       
+      -- A short 'pause' in bidi for mapfont
+      d_font = d_font or d
       d_font = (d_font == 'l' and 0) or
                (d_font == 'nsm' and 0) or
                (d_font == 'r' and 1) or
diff --git a/babel.ins b/babel.ins
index 2d3b5d0..835e099 100644
--- a/babel.ins
+++ b/babel.ins
@@ -26,7 +26,7 @@
 %% and covered by LPPL is defined by the unpacking scripts (with
 %% extension .ins) which are part of the distribution.
 %%
-\def\filedate{2019/04/03}
+\def\filedate{2019/04/08}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index d74872d..f52a4ab 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 73f6bbc..fe2b0f3 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2019/04/03 v3.29]
+\ProvidesFile{bbcompat.dtx}[2019/04/08 v3.29.1605]
 %</dtx>
 %
 %% File 'bbcompat.dtx'





More information about the latex3-commits mailing list