[latex3-commits] [git/LaTeX3-latex3-babel] main: (wip) Font-dependent transforms. (5d581e3)

Javier email at dante.de
Mon Jan 2 18:24:36 CET 2023


Repository : https://github.com/latex3/babel
On branch  : main
Link       : https://github.com/latex3/babel/commit/5d581e30cd08ed87a0b4ffc984afaf12dba15e3d

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

commit 5d581e30cd08ed87a0b4ffc984afaf12dba15e3d
Author: Javier <email at localhost>
Date:   Mon Jan 2 18:24:36 2023 +0100

    (wip) Font-dependent transforms.


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

5d581e30cd08ed87a0b4ffc984afaf12dba15e3d
 README.md    |  11 +++----
 babel.dtx    |  93 +++++++++++++++++++++++++++++++++++++++++++++++------------
 babel.ins    |   2 +-
 babel.pdf    | Bin 904534 -> 906889 bytes
 bbcompat.dtx |   2 +-
 5 files changed, 83 insertions(+), 25 deletions(-)

diff --git a/README.md b/README.md
index 4e5abb7..58bf3d1 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.84.2967
+## Babel 3.84.2970
 
 (dev)
 
@@ -10,9 +10,9 @@ is a set of ini files for about 250 languages.
 
 The latest stable version is available on <https://ctan.org/pkg/babel>.
 
-Changes in version 3.84 are described in:
+Changes in version 3.85 are described in:
 
-https://latex3.github.io/babel/news/whats-new-in-babel-3.84.html
+https://latex3.github.io/babel/news/whats-new-in-babel-3.85.html
 
 Apart from the manual, you can find information on some aspects of babel at:
 
@@ -49,8 +49,9 @@ respective authors.
 ### Summary of latest changes
 ```
 3.85  (dev)
-      * Spaces allowed as separators in layout =.
-      * A high-level interface to enable and disable transforms.
+      * Spaces allowed as separators in layout=.
+      * A high-level interface to enable and disable transforms (lua).
+      * Font-dependent transforms (lua).
       
 3.84  2022-12-26
       * Automatic selection of encodings with \babelprovide and pdftex.
diff --git a/babel.dtx b/babel.dtx
index f40ad30..716e45f 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -32,7 +32,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2022/12/30 v3.84.2967 The Babel package]
+\ProvidesFile{babel.dtx}[2023/01/02 v3.84.2970 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -5246,8 +5246,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.84.2967>>
-%<<date=2022/12/30>>
+%<<version=3.84.2970>>
+%<<date=2023/01/02>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -10966,27 +10966,44 @@ help from Bernd Raichle, for which I am grateful.
     \directlua{
        local str = [==[#2]==]
        str = str:gsub('%.%d+%.%d+$', '')
-       tex.print([[\def\string\babeltempa{]] .. str .. [[}]])
+       token.set_macro('babeltempa', str)
     }&%
+    \def\babeltempc{}&%
     \bbl at xin@{,\babeltempa,}{,\bbl at KVP@transforms,}&%
+    \ifin@\else
+      \bbl at xin@{:\babeltempa,}{,\bbl at KVP@transforms,}&%
+    \fi
     \ifin@
+      \bbl at foreach\bbl at KVP@transforms{&%
+        \bbl at xin@{:\babeltempa,}{,##1,}&%
+        \ifin@  &% font:font:transform syntax
+          \directlua{
+            local t = {}
+            for m in string.gmatch('##1'..':', '(.-):') do
+              table.insert(t, m)
+            end
+            table.remove(t)
+            token.set_macro('babeltempc', ',fonts=' .. table.concat(t, ' '))
+          }&%
+        \fi}&%
       \in@{.0$}{#2$}&%
       \ifin@
         \directlua{&% (\attribute) syntax
           local str = string.match([[\bbl at KVP@transforms]],
                         '%(([^%(]-)%)[^%)]-\babeltempa')
           if str == nil then
-            tex.print([[\def\string\babeltempb{}]])
+            token.set_macro('babeltempb', '')
           else
-            tex.print([[\def\string\babeltempb{,attribute=]] .. str .. [[}]])
+            token.set_macro('babeltempb', ',attribute=' .. str)
           end
-        }
+        }&%
         \toks@{#3}&%
         \bbl at exp{&%
           \\\g at addto@macro\\\bbl at release@transforms{&%
             \relax  &% Closes previous \bbl at transforms@aux
             \\\bbl at transforms@aux
-              \\#1{label=\babeltempa\babeltempb}{\languagename}{\the\toks@}}}&%
+              \\#1{label=\babeltempa\babeltempb\babeltempc}&%
+                 {\languagename}{\the\toks@}}}&%
       \else
         \g at addto@macro\bbl at release@transforms{, {#3}}&%
       \fi
@@ -12025,8 +12042,7 @@ help from Bernd Raichle, for which I am grateful.
 %
 % For several functions, we need to execute some code with
 % |\selectfont|. With \LaTeX\ 2021-06-01, there is a hook for this
-% purpose, but in older versions the \LaTeX{} command is patched (the
-% latter solution will be eventually removed).
+% purpose.
 %
 %    \begin{macrocode}
 \def\bbl at patchfont#1{\AddToHook{selectfont}{#1}}
@@ -12965,8 +12981,8 @@ help from Bernd Raichle, for which I am grateful.
 % At the time of this writing, \textsf{fontspec} shows a warning about
 % there are languages not available, which some people think refers to
 % \babel{}, even if there is nothing wrong. Here is hack to patch
-% \textsf{fontspec} to avoid the misleading message, which is replaced
-% ba a more explanatory one.
+% \textsf{fontspec} to avoid the misleading (and mostly unuseful)
+% message.
 %
 %    \begin{macrocode}
 %<<*Font selection>>
@@ -14629,15 +14645,30 @@ end
         \fi}}&% 
     \let\bbl at kv@attribute\relax
     \let\bbl at kv@label\relax
-    \let\bbl at kv@font\relax
+    \let\bbl at kv@fonts\relax
     \bbl at forkv{#2}{\bbl at csarg\edef{kv@##1}{##2}}&%
     \ifx\bbl at kv@attribute\relax
       \ifx\bbl at kv@label\relax\else  
-        \bbl at ifunset{bbl at ATR@\bbl at kv@label @#3}&%
-          {\bbl at csarg\newattribute{ATR@\bbl at kv@label @#3}}&%
-          {}&%
         \edef\bbl at kv@attribute{bbl at ATR@\bbl at kv@label @#3}&%
+        \bbl at ifunset{\bbl at kv@attribute}&%
+          {\global\bbl at carg\newattribute{\bbl at kv@attribute}}&%
+          {}&%
         \global\bbl at carg\setattribute{\bbl at kv@attribute}\@ne
+        \ifx\bbl at kv@fonts\relax
+          \bbl at exp{&%
+            \global\\\bbl at add\\\bbl at dotransfont{&%
+              \\\bbl at elt{#3}{}{\bbl at kv@label}}}&%
+        \else
+          \bbl at settransfont
+          \bbl at replace\bbl at kv@fonts{ }{,}&%
+          \bbl at exp{&% TODO. Now redundant entries are created
+            \global\\\bbl at add\\\bbl at untransfont{&%
+              \\\disablelocaletransform{\bbl at kv@label}}}&%
+          \bbl at foreach\bbl at kv@fonts{&%
+            \bbl at exp{&%
+              \global\\\bbl at add\\\bbl at dotransfont{&%
+                \\\bbl at elt{#3}{##1}{\bbl at kv@label}}}}&%
+        \fi
       \fi
     \else
       \edef\bbl at kv@attribute{\expandafter\bbl at stripslash\bbl at kv@attribute}&%
@@ -14685,10 +14716,36 @@ end
     }&%
   \endgroup}
 \endgroup
+\let\bbl at dotransfont\@empty
+\def\bbl at settransfont{%
+  \global\let\bbl at settransfont\relax % Execute only once
+  \global\let\bbl at untransfont\@empty
+  \gdef\bbl at transfont{%
+    \bbl at untransfont
+    \def\bbl at elt####1####2####3{%
+      \bbl at ifsamestring{####1}{\languagename}%
+        {\bbl at ifsamestring{####2}\bbl at transfam
+          {\enablelocaletransform{####3}}%
+          {}%
+        \bbl at ifsamestring{####2}{}%
+          {\enablelocaletransform{####3}}%
+          {}%
+        \bbl at ifsamestring{####2}{\bbl at transfam/\f at series/\f at shape}%
+          {\enablelocaletransform{####3}}%
+          {}}%
+        {}}%
+    \bbl at dotransfont}%
+  \AddToHook{selectfont}{\bbl at transfont}% Hooks are global.
+  \gdef\bbl at transfam{-unknown-}%
+  \bbl at foreach\bbl at font@fams{%
+    \AddToHook{##1family}{\def\bbl at transfam{##1}}%
+    \bbl at ifsamestring{\@nameuse{##1default}}\familydefault
+      {\xdef\bbl at transfam{##1}}%
+      {}}}
 \DeclareRobustCommand\enablelocaletransform[2][\languagename]{%
-  \bbl at csarg\setattribute{ATR@#2@#1}\@ne}
+  \bbl at ifunset{bbl at ATR@#2@#1}{}{\bbl at csarg\setattribute{ATR@#2@#1}\@ne}}
 \DeclareRobustCommand\disablelocaletransform[2][\languagename]{%
-  \bbl at csarg\unsetattribute{ATR@#2@#1}}
+  \bbl at ifunset{bbl at ATR@#2@#1}{}{\bbl at csarg\unsetattribute{ATR@#2@#1}}}
 \def\bbl at activateposthyphen{%
   \let\bbl at activateposthyphen\relax
   \directlua{
diff --git a/babel.ins b/babel.ins
index e3ebe4f..8d71e3a 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{2022/12/30}
+\def\filedate{2023/01/02}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index 186e026..59698e4 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 5e930dc..a4199b1 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2022/12/30 v3.84.2967]
+\ProvidesFile{bbcompat.dtx}[2023/01/02 v3.84.2970]
 %</dtx>
 %
 %% File 'bbcompat.dtx'





More information about the latex3-commits mailing list.