[latex3-commits] [latex3/babel] main: onchar: check script, optimize. (98c4ecf)

github at latex-project.org github at latex-project.org
Fri Oct 20 18:15:50 CEST 2023


Repository : https://github.com/latex3/babel
On branch  : main
Link       : https://github.com/latex3/babel/commit/98c4ecf2eedc2e3081e3c202ce6f4f31c67db193

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

commit 98c4ecf2eedc2e3081e3c202ce6f4f31c67db193
Author: Javier <email at localhost>
Date:   Fri Oct 20 18:15:50 2023 +0200

    onchar: check script, optimize.


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

98c4ecf2eedc2e3081e3c202ce6f4f31c67db193
 README.md              |   3 ++-
 babel-code.pdf         | Bin 635559 -> 635675 bytes
 babel.dtx              |  66 +++++++++++++++++++++++++++++++------------------
 babel.ins              |   2 +-
 babel.pdf              | Bin 413412 -> 413197 bytes
 bbcompat.dtx           |   2 +-
 locale/pl/babel-pl.ini |   2 +-
 samples/luahb-udhr.pdf | Bin 237706 -> 242749 bytes
 samples/luahb-udhr.tex |   4 +--
 9 files changed, 48 insertions(+), 31 deletions(-)

diff --git a/README.md b/README.md
index 600b45a..441e24f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.95.29149
+s## Babel 3.95.29372
 
 (dev)
 
@@ -52,6 +52,7 @@ respective authors.
      * Add LGI to non-ASCII encodings.
      * New macro: \asciiencoding.
      * Removed OT1 in some ini files.
+     * Improved 'onchar'.
      
 3.95 2023-09-29
      * New locales: Cebuano, Chuvash, Dogri, Northern Frisian,
diff --git a/babel-code.pdf b/babel-code.pdf
index 6a719f3..d14ff5b 100644
Binary files a/babel-code.pdf and b/babel-code.pdf differ
diff --git a/babel.dtx b/babel.dtx
index ac2bd12..dde5c39 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -32,7 +32,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2023/10/18 v3.95.29149 The Babel package]
+\ProvidesFile{babel.dtx}[2023/10/20 v3.95.29372 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -5562,8 +5562,8 @@ wouldn’t exist.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.95.29149>>
-%<<date=2023/10/18>>
+%<<version=3.95.29372>>
+%<<date=2023/10/20>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -10250,6 +10250,11 @@ wouldn’t exist.
          Babel.set_chranges_b('\bbl at cl{sbcp}', '\bbl at cl{chrng}') }}%
   \fi
    % == onchar ==
+  \ifcase\bbl at engine\or
+    \directlua{   %%%%%%%%%%%%%%%% WIP. Move to load ini
+      Babel.locale_props[\the\localeid].script = '\bbl at cl{sbcp}'
+    }%
+  \fi
   \ifx\bbl at KVP@onchar\@nnil\else
     \bbl at luahyphenate
     \bbl at exp{%
@@ -10279,9 +10284,7 @@ wouldn’t exist.
       % TODO - error/warning if no script
       \directlua{
         if Babel.script_blocks['\bbl at cl{sbcp}'] then
-          Babel.loc_to_scr[\the\localeid] =
-            Babel.script_blocks['\bbl at cl{sbcp}']
-          Babel.locale_props[\the\localeid].lc = \the\localeid\space
+          Babel.loc_to_scr[\the\localeid] = Babel.script_blocks['\bbl at cl{sbcp}']
           Babel.locale_props[\the\localeid].lg = \the\@nameuse{l@\languagename}\space
         end
       }%
@@ -14849,15 +14852,17 @@ end
 % \subsection{Automatic fonts and ids switching}
 %
 % After defining the blocks for a number of scripts (must be extended
-% and very likely fine tuned), we define a short function which just
-% traverse the node list to carry out the replacements. The table
-% |loc_to_scr| gets the locale form a script range (note the locale is
-% the key, and that there is an intermediate table built on the fly for
-% optimization). This locale is then used to get the |\language| and
-% the |\localeid| as stored in |locale_props|, as well as the font (as
-% requested). In the latter table a key starting with |/| maps the font
-% from the global one (the key) to the local one (the value). Maths are
-% skipped and discretionaries are handled in a special way.
+% and very likely fine tuned), we define a the function
+% |Babel.locale_map|, which just traverse the node list to carry out
+% the replacements. The table |loc_to_scr| stores the script range for
+% each locale (whose id is the key), copied from this table (so that it
+% can be modified on a locale basis); there is an intermediate table
+% named |chr_to_loc| built on the fly for optimization, which maps a
+% char to the locale. This locale is then used to get the |\language|
+% as stored in |locale_props|, as well as the font (as requested). In
+% the latter table a key starting with |/| maps the font from the
+% global one (the key) to the local one (the value). Maths are skipped
+% and discretionaries are handled in a special way.
 %
 %    \begin{macrocode}
 % TODO - to a lua file
@@ -14939,22 +14944,35 @@ function Babel.locale_map(head)
             end
           end
         end
+        % Treat composite chars in a different fashion, because they
+        % 'inherit' the previous locale.
+        if (item.char >= 0x0300 and item.char <= 0x036F) or
+           (item.char >= 0x1AB0 and item.char <= 0x1AFF) or
+           (item.char >= 0x1DC0 and item.char <= 0x1DFF) then
+             Babel.chr_to_loc[item.char] = -2000
+             toloc = -2000
+        end
+        if not toloc then
+          Babel.chr_to_loc[item.char] = -1000
+        end
       end
-      % Now, take action, but treat composite chars in a different
-      % fashion, because they 'inherit' the previous locale. Not yet
-      % optimized.
-      if not toloc and 
-          (item.char >= 0x0300 and item.char <= 0x036F) or
-          (item.char >= 0x1AB0 and item.char <= 0x1AFF) or
-          (item.char >= 0x1DC0 and item.char <= 0x1DFF) then
+      if toloc == -2000 then
         toloc = toloc_save
+      elseif toloc == -1000 then
+        toloc = nil
       end
       if toloc and Babel.locale_props[toloc] and
           Babel.locale_props[toloc].letters and
           tex.getcatcode(item.char) \string~= 11 then
         toloc = nil
       end
-      if toloc and toloc > -1 then
+      if toloc and Babel.locale_props[toloc].script
+          and Babel.locale_props[node.get_attribute(item, LOCALE)].script
+          and Babel.locale_props[toloc].script ==
+            Babel.locale_props[node.get_attribute(item, LOCALE)].script then 
+        toloc = nil
+      end
+      if toloc then
         if Babel.locale_props[toloc].lg then
           item.lang = Babel.locale_props[toloc].lg
           node.set_attribute(item, LOCALE, toloc)
@@ -14962,8 +14980,8 @@ function Babel.locale_map(head)
         if Babel.locale_props[toloc]['/'..item.font] then
           item.font = Babel.locale_props[toloc]['/'..item.font]
         end
-        toloc_save = toloc
       end
+      toloc_save = toloc
     elseif not inmath and item.id == 7 then % Apply recursively
       item.replace = item.replace and Babel.locale_map(item.replace)
       item.pre     = item.pre and Babel.locale_map(item.pre)
diff --git a/babel.ins b/babel.ins
index 4b2147f..4b8dbda 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{2023/10/18}
+\def\filedate{2023/10/20}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index 68c56eb..1638571 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 1a1801e..24ef05f 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2023/10/18 v3.95.29149]
+\ProvidesFile{bbcompat.dtx}[2023/10/20 v3.95.29372]
 %</dtx>
 %
 %% File 'bbcompat.dtx'
diff --git a/locale/pl/babel-pl.ini b/locale/pl/babel-pl.ini
index 02e70a8..2bdad3f 100644
--- a/locale/pl/babel-pl.ini
+++ b/locale/pl/babel-pl.ini
@@ -23,7 +23,7 @@ script.name = Latin
 script.tag.bcp47 = Latn
 script.tag.opentype = latn
 level = 1
-encodings = T1 LY1 QX
+encodings = T1 LY1 QX OT4
 derivate = no
 
 [captions]
diff --git a/samples/luahb-udhr.pdf b/samples/luahb-udhr.pdf
index ab2319f..2a3f86c 100644
Binary files a/samples/luahb-udhr.pdf and b/samples/luahb-udhr.pdf differ
diff --git a/samples/luahb-udhr.tex b/samples/luahb-udhr.tex
index ad90e9e..5a64673 100644
--- a/samples/luahb-udhr.tex
+++ b/samples/luahb-udhr.tex
@@ -25,9 +25,7 @@
 
 \begin{document}
 
-Requires at least \textsf{luaotfload} 3.11 and \textsf{babel} 3.39.
-Typeset with \textsf{luahbtex}, the new default engine for
-\textsf{lualatex} in 2020.
+Typeset with \texttt{lualatex} and \texttt{babel} 3.95.
 
 \startlocale{arabic}
 





More information about the latex3-commits mailing list.