[latex3-commits] [git/LaTeX3-latex3-latex2e] master: 3.20. Native digits and fixes in bidi. (226e5a3)

Javier javier at dante.de
Wed May 2 15:09:23 CEST 2018


Repository : https://github.com/latex3/latex2e
On branch  : master
Link       : https://github.com/latex3/latex2e/commit/226e5a3d82423c9f9d3461a3d244b08c99a3a106

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

commit 226e5a3d82423c9f9d3461a3d244b08c99a3a106
Author: Javier <javier at localhost>
Date:   Wed May 2 15:09:23 2018 +0200

    3.20. Native digits and fixes in bidi.


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

226e5a3d82423c9f9d3461a3d244b08c99a3a106
 required/babel/README.md                 |   14 ++-
 required/babel/babel.dtx                 |  174 +++++++++++++++++++++---------
 required/babel/babel.ins                 |    4 +-
 required/babel/babel.pdf                 |  Bin 659983 -> 647876 bytes
 required/babel/bbcompat.dtx              |    2 +-
 required/babel/samples/lua-arabic.pdf    |  Bin 85558 -> 85557 bytes
 required/babel/samples/lua-bidibasic.pdf |  Bin 43293 -> 43302 bytes
 required/babel/samples/lua-bidibasic.tex |    4 +-
 required/babel/samples/lua-secenum.pdf   |  Bin 57640 -> 57621 bytes
 9 files changed, 144 insertions(+), 54 deletions(-)

diff --git a/required/babel/README.md b/required/babel/README.md
index fd28eef..26ebce5 100644
--- a/required/babel/README.md
+++ b/required/babel/README.md
@@ -1,4 +1,4 @@
-## Babel 3.19
+## Babel 3.20
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages.  Many
@@ -64,6 +64,16 @@ respective authors.
 ### New
 
 ```
+3.20   - ini files with the field digits.native define
+         \<language>digits and \<language>counters. \arabic can be
+         redefined to use native digits.
+       - Fix - mapfont in bidi=basic didn't take into account combining
+         marks (eg, Arabic vowels).
+       - Fix - A bug introduced in 3.19, which sometimes reversed text 
+         in \hbox'es.
+       - Fix for luatex 1.07 - An internal change in luatex broke
+         bidi at 'automatic' hyphens.
+       - Fix for latest latex - babel.ins raised an error.
 3.19   - Most changes are for luatex:
          . The main new feature is a bidi method for both implicit L in
            R text, and implicit R in L text, with the possibility of
@@ -128,5 +138,5 @@ respective authors.
 ```
 
 Javier Bezos
-2018/04/25
+2018/05/02
 
diff --git a/required/babel/babel.dtx b/required/babel/babel.dtx
index 3d4e18d..16acec6 100644
--- a/required/babel/babel.dtx
+++ b/required/babel/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2018/04/25 v3.19 The Babel package]
+\ProvidesFile{babel.dtx}[2018/05/02 v3.20 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -260,7 +260,9 @@ addition, you may want to set the font and input encodings.
   Here is a simple full example for “traditional” \TeX{} engines
   (see below for \xetex{} and \luatex{}). The packages |fontenc| and
   |inputenc| do not belong to \babel, but they are included in the
-  example because typically you will need them:
+  example because typically you will need them (however, the package
+  \textsf{inputenc} may be omitted with \LaTeX{} $\ge$ 2018-04-01 if
+  the encoding is UTF-8):
 \begin{verbatim}
 \documentclass{article}
 
@@ -375,8 +377,9 @@ detail: |\selectlanguage| is used for blocks of text, while
 |\foreignlanguage| is for chunks of text inside paragraphs.
 
 \begin{example}
-A full bilingual document follows. The main language is |french|,
-which is activated when the document begins.
+A full bilingual document follows. The main language is |french|, which
+is activated when the document begins. The package \textsf{inputenc}
+may be omitted with \LaTeX{} $\ge$ 2018-04-01 if the encoding is UTF-8.
 \begin{verbatim}
 \documentclass{article}
 
@@ -1879,8 +1882,8 @@ sometimes necessary, but not always trivial.
   \renewcommand\contentsname{Foo}%
 }
 \end{verbatim}
- As of 3.15, there is no need to hide spaces with \texttt{\%}
-(\babel{} removes them), but it is advisable to do it.
+As of 3.15, there is no need to hide spaces with \texttt{\%%
+} (\babel{} removes them), but it is advisable to do it.
 \item The new way, which is found in |bulgarian|, |azerbaijani|,
   |spanish|, |french|, |turkish|, |icelandic|, |vietnamese| and a few
   more, as well as in languages created with |\babelprovide| and its
@@ -1909,7 +1912,7 @@ unselected: |\noextras|\m{lang}.
 fits your needs? You may then define quickly a language with the
 help of the following macro in the preamble.
 
-\Describe\babelprovide{\oarg{options}\marg{language-name}}
+\Describe{\babelprovide}{\oarg{options}\marg{language-name}}
 
 Defines the internal structure of the language with some defaults: the
 hyphen rules, if not available, are set to the current ones, left and
@@ -2012,9 +2015,32 @@ relevant.
   |ini|-based languages).
 \end{note}
 
+\subsection{Digits}
+
+\New{3.20} A few |ini| files define a field named |digits.native|. When
+it is present, two macros are created: |\<language>digits| and
+|\<language>counter| (only \xetex{} and \luatex{}). With the first, a
+string of ‘Latin’ digits are converted to the native digits of that
+language; the second takes a counter name as argument. With option
+|maparabic| in |\babelprovide|, |\arabic| is redefined to produce the
+native digits (this is done \textit{globally}, to avoid inconsistencies
+in, for example, page numbering).
+
+For example:
+\begin{verbatim}
+\babelprovide[import=te]{telugu}  % Telugu better with XeTeX
+  % Or also, if you want:
+  % \babelprovide[import=te, maparabic]{telugu}
+\babelfont{rm}{Gautami}
+\begin{document}
+\telugudigits{1234}
+\telugucounter{section}
+\end{document}
+\end{verbatim}
+
 \subsection{Getting the current language name}
 
-\Describe\languagename{}
+\Describe{\languagename}{}
 The control sequence |\languagename| contains the name of the
 current language. 
 
@@ -2024,7 +2050,7 @@ current language.
   Heiko Oberdiek.
 \end{warning}
 
-\Describe\iflanguage{\marg{language}\marg{true}\marg{false}}
+\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}}
 
 If more than one language is used, it might be necessary to know which
 language is active at a specific time. This can be checked by a call
@@ -2042,7 +2068,7 @@ respectively.
 
 \subsection{Hyphenation tools}
 
-\Describe\babelhyphen{%
+\Describe{\babelhyphen}{%
   \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{type}}
 \DescribeOther\babelhyphen{%
   \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{text}}
@@ -3737,8 +3763,8 @@ help from Bernd Raichle, for which I am grateful.
 %    little bit of literate programming.
 %
 %    \begin{macrocode}
-%<<version=3.19>>
-%<<date=2018/04/25>>
+%<<version=3.20>>
+%<<date=2018/05/02>>
 %    \end{macrocode}
 %
 % \section{Tools}
@@ -4205,24 +4231,6 @@ help from Bernd Raichle, for which I am grateful.
   \bbl at languages
 \fi
 \ifodd\bbl at engine
-  \def\bbl at loadbidi#1{%
-    \let\bbl at beforeforeign\leavevmode
-    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
-    \RequirePackage{luatexbase}%
-    \directlua{
-      require('babel-bidi.lua')
-      require('babel-bidi-#1.lua')
-      luatexbase.add_to_callback('pre_linebreak_filter',
-        Babel.pre_otfload_v,
-        'Babel.pre_otfload_v',
-        luatexbase.priority_in_callback('pre_linebreak_filter',
-          'luaotfload.node_processor') or nil)
-      luatexbase.add_to_callback('hpack_filter',
-        Babel.pre_otfload_h,
-        'Babel.pre_otfload_h',
-        luatexbase.priority_in_callback('hpack_filter',
-          'luaotfload.node_processor') or nil)
-          }}
   \let\bbl at tempa\relax
   \@ifpackagewith{babel}{bidi=basic}%
     {\def\bbl at tempa{basic}}%
@@ -7613,6 +7621,8 @@ help from Bernd Raichle, for which I am grateful.
 %   the language is selected}
 % \changes{babel~3.19}{2018/04/23}{New option - mapfont. Currently
 %   only with direction}
+% \changes{babel~3.20}{2018/05/01}{Handle native digits (TeX level).
+%   New option - maparabic.}
 %
 %    \begin{macrocode}
 \bbl at trace{Creating languages and reading ini files}
@@ -7627,6 +7637,7 @@ help from Bernd Raichle, for which I am grateful.
   \let\bbl at KVP@dir\@nil
   \let\bbl at KVP@hyphenrules\@nil
   \let\bbl at KVP@mapfont\@nil
+  \let\bbl at KVP@maparabic\@nil
   \bbl at forkv{#1}{\bbl at csarg\def{KVP@##1}{##2}}%  TODO - error handling
   \ifx\bbl at KVP@captions\@nil
     \let\bbl at KVP@captions\bbl at KVP@import
@@ -7676,7 +7687,48 @@ help from Bernd Raichle, for which I am grateful.
     \fi
     \bbl at exp{\\\bbl at add\\\bbl at mapselect{\\\bbl at mapdir{\languagename}}}%
   \fi
+  \ifcase\bbl at engine\else
+    \bbl at ifunset{bbl at dgnat@\languagename}{}%
+      {\expandafter\ifx\csname bbl at dgnat@\languagename\endcsname\@empty\else
+        \expandafter\expandafter\expandafter
+        \bbl at setdigits\csname bbl at dgnat@\languagename\endcsname
+        \ifx\bbl at KVP@maparabic\@nil\else
+          \expandafter\let\expandafter\@arabic
+            \csname bbl at counter@\languagename\endcsname
+        \fi
+      \fi}%
+  \fi
   \let\languagename\bbl at savelangname}
+\def\bbl at setdigits#1#2#3#4#5{%
+  \bbl at exp{%
+    \def\<\languagename digits>####1{%       ie, \langdigits
+      \<bbl at digits@\languagename>####1\\\@nil}%
+    \def\<\languagename counter>####1{%      ie, \langcounter
+      \\\expandafter\<bbl at counter@\languagename>%
+      \\\csname c@####1\endcsname}%
+    \def\<bbl at counter@\languagename>####1{% ie, \bbl at counter@lang
+      \\\expandafter\<bbl at digits@\languagename>%
+      \\\number####1\\\@nil}}%
+  \def\bbl at tempa##1##2##3##4##5{%
+    \bbl at exp{%    Wow, quite a lot of hashes! :-(
+      \def\<bbl at digits@\languagename>########1{%
+       \\\ifx########1\\\@nil              % ie, \bbl at digits@lang
+       \\\else
+         \\\ifx0########1#1%
+         \\\else\\\ifx1########1#2%
+         \\\else\\\ifx2########1#3%
+         \\\else\\\ifx3########1#4%
+         \\\else\\\ifx4########1#5%
+         \\\else\\\ifx5########1##1%
+         \\\else\\\ifx6########1##2%
+         \\\else\\\ifx7########1##3%
+         \\\else\\\ifx8########1##4%
+         \\\else\\\ifx9########1##5%
+         \\\else########1%
+         \\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi
+         \\\expandafter\<bbl at digits@\languagename>%
+       \\\fi}}}%
+  \bbl at tempa}
 %    \end{macrocode}
 %
 % Depending on whether or not the language exists, we define two macros.
@@ -7858,10 +7910,12 @@ help from Bernd Raichle, for which I am grateful.
   \bbl at exportkey{sbcp}{identification.script.tag.bcp47}{}%
   \bbl at exportkey{sotf}{identification.script.tag.opentype}{DFLT}}
 \let\bbl at secline@typography\bbl at inikv
+\let\bbl at secline@numbers\bbl at inikv
 \def\bbl at after@ini{%
   \bbl at exportkey{lfthm}{typography.lefthyphenmin}{2}%
   \bbl at exportkey{rgthm}{typography.righthyphenmin}{3}%
   \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
+  \bbl at exportkey{dgnat}{numbers.digits.native}{}%
   \bbl at xin@{0.9}{\@nameuse{bbl@@kv at identification.version}}%
   \ifin@
     \bbl at warning{%
@@ -17594,6 +17648,9 @@ Babel.characters={
 %
 % TODO: math mode (as weak L?)
 %
+% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >= 
+%   1.07. Fix - now attr at dir is mod 3.}
+%
 %    \begin{macrocode}
 %<*basic-r>
 Babel = Babel or {}
@@ -17655,15 +17712,22 @@ function Babel.bidi(head, ispar)
   for item in node.traverse(head) do
 
     -- three cases: glyph, dir, otherwise
-    if item.id == node.id'glyph' then
+    if item.id == node.id'glyph'
+      or (item.id == 7 and item.subtype == 2) then
 
-      local chardata = characters[item.char]
+      local itemchar
+      if item.id == 7 and item.subtype == 2 then
+        itemchar = item.replace.char
+      else
+        itemchar = item.char
+      end
+      local chardata = characters[itemchar]
       dir = chardata and chardata.d or nil
       if not dir then
         for nn, et in ipairs(ranges) do
-          if item.char < et[1] then
+          if itemchar < et[1] then
             break
-          elseif item.char <= et[2] then
+          elseif itemchar <= et[2] then
             dir = et[3]
             break
           end
@@ -17683,7 +17747,7 @@ function Babel.bidi(head, ispar)
         attr_dir = 0
         for at in node.traverse(item.attr) do
           if at.number == luatexbase.registernumber'bbl at attr@dir' then
-            attr_dir = at.value
+            attr_dir = at.value % 3
           end
         end
         if attr_dir == 1 then
@@ -17856,6 +17920,8 @@ end
 %    \end{macrocode}
 %
 % And here the Lua code for |bidi=basic|:
+% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >= 
+%   1.07. Fix - nsm in mapfont (eg, Arabic vowels)}
 %
 %    \begin{macrocode}
 %<*basic>
@@ -17959,28 +18025,40 @@ function Babel.bidi(head, ispar, hdir)
     -- current one is not added until we start processing the neutrals.
 
     -- three cases: glyph, dir, otherwise  
-    if item.id == GLYPH then
+    if item.id == GLYPH 
+       or (item.id == 7 and item.subtype == 2) then
 
-      local chardata = characters[item.char]
+      local d_font = nil
+      local item_r
+      if item.id == 7 and item.subtype == 2 then
+        item_r = item.replace    -- automatic discs have just 1 glyph
+      else
+        item_r = item
+      end
+      local chardata = characters[item_r.char]
       d = chardata and chardata.d or nil
-      if not d then
+      if not d or d == 'nsm' then
         for nn, et in ipairs(ranges) do
-          if item.char < et[1] then
+          if item_r.char < et[1] then
             break
-          elseif item.char <= et[2] then
-            d = et[3]
+          elseif item_r.char <= et[2] then
+            if not d then d = et[3] 
+            elseif d == 'nsm' then d_font = et[3]
+            end
             break
           end
         end
       end
       d = d or 'l'
-
-      local temp = (d == 'l' and 0) or
-                   (d == 'r' and 1) or
-                   (d == 'al' and 2) or
-                   (d == 'an' and 2) or nil
-      if temp and fontmap and fontmap[temp][item.font] then
-        item.font = fontmap[temp][item.font]
+      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
+               (d_font == 'al' and 2) or
+               (d_font == 'an' and 2) or nil
+      if d_font and fontmap and fontmap[d_font][item_r.font] then
+        item_r.font = fontmap[d_font][item_r.font]
       end
 
       if new_d then
diff --git a/required/babel/babel.ins b/required/babel/babel.ins
index 1131035..263fe3f 100644
--- a/required/babel/babel.ins
+++ b/required/babel/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{2018/04/25}
+\def\filedate{2018/05/02}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
@@ -122,6 +122,8 @@
 
 \usepreamble\mainpreamble
 
+\csname UseRawInputEncoding\endcsname
+
 % Dummy, it just read "modules" to be used when generating
 % the actual file. There must be a better way.
 \savingtrue
diff --git a/required/babel/babel.pdf b/required/babel/babel.pdf
index 0f7b58c..84e1efd 100644
Binary files a/required/babel/babel.pdf and b/required/babel/babel.pdf differ
diff --git a/required/babel/bbcompat.dtx b/required/babel/bbcompat.dtx
index 1922daa..5d0621e 100644
--- a/required/babel/bbcompat.dtx
+++ b/required/babel/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2018/04/25 v3.19]
+\ProvidesFile{bbcompat.dtx}[2018/05/02 v3.20]
 %</dtx>
 %
 %% File 'bbcompat.dtx'
diff --git a/required/babel/samples/lua-arabic.pdf b/required/babel/samples/lua-arabic.pdf
index b2c74c2..7cc4f0f 100644
Binary files a/required/babel/samples/lua-arabic.pdf and b/required/babel/samples/lua-arabic.pdf differ
diff --git a/required/babel/samples/lua-bidibasic.pdf b/required/babel/samples/lua-bidibasic.pdf
index 33c3354..e8339fc 100644
Binary files a/required/babel/samples/lua-bidibasic.pdf and b/required/babel/samples/lua-bidibasic.pdf differ
diff --git a/required/babel/samples/lua-bidibasic.tex b/required/babel/samples/lua-bidibasic.tex
index 291d316..ae1e3f9 100644
--- a/required/babel/samples/lua-bidibasic.tex
+++ b/required/babel/samples/lua-bidibasic.tex
@@ -9,8 +9,8 @@
 % Define two new languages:
 
 % \babelprovide[mapfont=direction]{english}   % 
-\babelprovide[mapfont=direction]{arabic}
-\babelprovide[mapfont=direction]{hebrew}
+\babelprovide[import=ar,mapfont=direction]{arabic}
+\babelprovide[import=he,mapfont=direction]{hebrew}
 
 \babelfont{rm}{Crimson}
 \babelfont[*arabic]{rm}
diff --git a/required/babel/samples/lua-secenum.pdf b/required/babel/samples/lua-secenum.pdf
index 475efd4..ea22170 100644
Binary files a/required/babel/samples/lua-secenum.pdf and b/required/babel/samples/lua-secenum.pdf differ





More information about the latex3-commits mailing list