From 14a474d3938a000b58ddd4c440338dc727bdc830 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 15 Jan 2020 21:50:07 +0000
Subject: babel (15jan20)

git-svn-id: svn://tug.org/texlive/trunk@53415 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/generic/babel/babel.def | 103 +++++++++++++++++++++++---
 1 file changed, 91 insertions(+), 12 deletions(-)

(limited to 'Master/texmf-dist/tex/generic/babel/babel.def')

diff --git a/Master/texmf-dist/tex/generic/babel/babel.def b/Master/texmf-dist/tex/generic/babel/babel.def
index ad0e6d9a70a..9f8352bbac9 100644
--- a/Master/texmf-dist/tex/generic/babel/babel.def
+++ b/Master/texmf-dist/tex/generic/babel/babel.def
@@ -41,7 +41,7 @@
     \wlog{File: #1 #4 #3 <#2>}%
     \let\ProvidesFile\@undefined}
 \fi
-\ProvidesFile{babel.def}[2019/12/08 3.37 Babel common definitions]
+\ProvidesFile{babel.def}[2020/01/15 3.38 Babel common definitions]
 \ifx\AtBeginDocument\@undefined
   \input plain.def\relax
 \fi
@@ -1374,6 +1374,7 @@
   \edef\bbl@savelocaleid{\the\localeid}%
   % Set name and locale id
   \def\languagename{#2}%
+  % \global\@namedef{bbl@lcname@#2}{#2}%
   \bbl@id@assign
   \let\bbl@KVP@captions\@nil
   \let\bbl@KVP@import\@nil
@@ -1386,6 +1387,8 @@
   \let\bbl@KVP@mapdigits\@nil
   \let\bbl@KVP@intraspace\@nil
   \let\bbl@KVP@intrapenalty\@nil
+  \let\bbl@KVP@onchar\@nil
+  \let\bbl@KVP@chargroups\@nil
   \bbl@forkv{#1}{%  TODO - error handling
     \in@{..}{##1}%
     \ifin@
@@ -1449,6 +1452,56 @@
   \fi
   \ifx\bbl@KVP@language\@nil\else
     \bbl@csarg\edef{lname@#2}{\bbl@KVP@language}%
+  \fi
+   % == onchar ==
+  \ifx\bbl@KVP@onchar\@nil\else
+    \bbl@luahyphenate
+    \directlua{
+      if Babel.locale_mapped == nil then
+        Babel.locale_mapped = true
+        Babel.linebreaking.add_before(Babel.locale_map)
+        Babel.loc_to_scr = {}
+        Babel.chr_to_loc = {}
+      end}%
+    \bbl@xin@{ ids }{ \bbl@KVP@onchar\space}%
+    \ifin@
+      % TODO - error/warning if no script
+      \directlua{
+        if Babel.script_blocks['\bbl@cs{sbcp@\languagename}'] then
+          Babel.loc_to_scr[\the\localeid] =
+            Babel.script_blocks['\bbl@cs{sbcp@\languagename}']
+          Babel.locale_props[\the\localeid].lc = \the\localeid\space
+          Babel.locale_props[\the\localeid].lg = \the\@nameuse{l@\languagename}\space
+        end
+      }%
+    \fi
+    \bbl@xin@{ fonts }{ \bbl@KVP@onchar\space}%
+    \ifin@
+      \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+      \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+      \directlua{
+        if Babel.script_blocks['\bbl@cs{sbcp@\languagename}'] then
+          Babel.loc_to_scr[\the\localeid] =
+            Babel.script_blocks['\bbl@cs{sbcp@\languagename}']
+        end}
+      \ifx\bbl@mapselect\@undefined
+        \AtBeginDocument{%
+          \expandafter\bbl@add\csname selectfont \endcsname{{\bbl@mapselect}}%
+          {\selectfont}}%
+        \def\bbl@mapselect{%
+          \let\bbl@mapselect\relax
+          \edef\bbl@prefontid{\fontid\font}}%
+        \def\bbl@mapdir##1{%
+          {\def\languagename{##1}%
+           \let\bbl@ifrestoring\@firstoftwo % To avoid font warning
+           \bbl@switchfont
+           \directlua{
+             Babel.locale_props[\the\csname bbl@id@@##1\endcsname]%
+                     ['/\bbl@prefontid'] = \fontid\font\space}}}%
+      \fi
+      \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}%
+    \fi
+    % TODO - catch non-valid values
   \fi
   % == mapfont ==
   % For bidi texts, to switch the font based on direction
@@ -1670,9 +1723,13 @@
          {\\\AddBabelHook[\languagename]{babel-prehc-\languagename}{patterns}%
            {\prehyphenchar=\@nameuse{bbl@prehc@\languagename}\relax}}}%
      \fi}}
+\ifx\bbl@readstream\@undefined
+  \csname newread\endcsname\bbl@readstream
+\fi
 \def\bbl@read@ini#1#2{%
-  \openin1=babel-#1.ini        % FIXME - number must not be hardcoded
-  \ifeof1
+  \global\@namedef{bbl@lini@\languagename}{#1}%
+  \openin\bbl@readstream=babel-#1.ini
+  \ifeof\bbl@readstream
     \bbl@error
       {There is no ini file for the requested language\\%
        (#1). Perhaps you misspelled it or your installation\\%
@@ -1693,9 +1750,9 @@
     \bbl@info{Importing #2 for \languagename\\%
              from babel-#1.ini. Reported}%
     \loop
-    \if T\ifeof1F\fi T\relax % Trick, because inside \loop
+    \if T\ifeof\bbl@readstream F\fi T\relax % Trick, because inside \loop
       \endlinechar\m@ne
-      \read1 to \bbl@line
+      \read\bbl@readstream to \bbl@line
       \endlinechar`\^^M
       \ifx\bbl@line\@empty\else
         \expandafter\bbl@iniline\bbl@line\bbl@iniline
@@ -1746,14 +1803,14 @@
      \fi}}
 \let\bbl@inikv@identification\bbl@inikv
 \def\bbl@secpost@identification{%
-  \bbl@ifunset{bbl@@kv@identification.name.opentype}%
-    {\bbl@exportkey{lname}{identification.name.english}{}}%
-    {\bbl@exportkey{lname}{identification.name.opentype}{}}%
+  \bbl@exportkey{elname}{identification.name.english}{}%
+  \bbl@exp{\\\bbl@exportkey{lname}{identification.name.opentype}%
+    {\csname bbl@elname@\languagename\endcsname}}%
   \bbl@exportkey{lbcp}{identification.tag.bcp47}{}%
   \bbl@exportkey{lotf}{identification.tag.opentype}{dflt}%
-  \bbl@ifunset{bbl@@kv@identification.script.name.opentype}%
-    {\bbl@exportkey{sname}{identification.script.name}{}}%
-    {\bbl@exportkey{sname}{identification.script.name.opentype}{}}%
+  \bbl@exportkey{esname}{identification.script.name}{}%
+  \bbl@exp{\\\bbl@exportkey{sname}{identification.script.name.opentype}%
+    {\csname bbl@esname@\languagename\endcsname}}%
   \bbl@exportkey{sbcp}{identification.script.tag.bcp47}{}%
   \bbl@exportkey{sotf}{identification.script.tag.opentype}{DFLT}}
 \let\bbl@inikv@typography\bbl@inikv
@@ -1889,12 +1946,34 @@
 \def\bbl@ini@basic#1{%
   \def\BabelBeforeIni##1##2{%
     \begingroup
-      \bbl@add\bbl@secpost@identification{\closein1 }%
+      \bbl@add\bbl@secpost@identification{\closein\bbl@readstream }%
       \catcode`\[=12 \catcode`\]=12 \catcode`\==12 %
       \bbl@read@ini{##1}{font and identification data}%
       \endinput          % babel- .tex may contain onlypreamble's
     \endgroup}%            boxed, to avoid extra spaces:
   {\setbox\z@\hbox{\InputIfFileExists{babel-#1.tex}{}{}}}}
+\newcommand\localeinfo[1]{%
+  \bbl@ifunset{bbl@\csname bbl@info@#1\endcsname @\languagename}%
+    {\bbl@error{I've found no info for the current locale.\\%
+                The corresponding ini file has not been loaded\\%
+                Perhaps it doesn't exist}%
+               {See the manual for details.}}%
+    {\@nameuse{bbl@\csname bbl@info@#1\endcsname @\languagename}}}
+\@namedef{bbl@info@tag.ini}{lini}
+\@namedef{bbl@info@name.english}{elname}
+\@namedef{bbl@info@name.opentype}{lname}
+\@namedef{bbl@info@tag.bcp47}{lbcp}
+\@namedef{bbl@info@tag.opentype}{lotf}
+\@namedef{bbl@info@script.name}{esname}
+\@namedef{bbl@info@script.name.opentype}{sname}
+\@namedef{bbl@info@script.tag.bcp47}{sbcp}
+\@namedef{bbl@info@script.tag.opentype}{sotf}
+\let\bbl@ensureinfo\@gobble
+\newcommand\BabelEnsureInfo{%
+  \def\bbl@ensureinfo##1{%
+    \ifx\InputIfFileExists\@undefined\else  % not in plain
+      \bbl@ifunset{bbl@lname@##1}{\bbl@ini@basic{##1}}{}%
+    \fi}}
 \newcommand\babeladjust[1]{%  TODO. Error handling.
   \bbl@forkv{#1}{\@nameuse{bbl@ADJ@##1@##2}}}
 \def\bbl@adjust@lua#1#2{%
-- 
cgit v1.2.3

