[latex3-commits] [git/LaTeX3-latex3-babel] main: Experimental Tibetan justification. (9227667)
Javier
email at dante.de
Sat Sep 24 08:17:50 CEST 2022
Repository : https://github.com/latex3/babel
On branch : main
Link : https://github.com/latex3/babel/commit/92276676d2fe0561f1f25e5032d736dba04e49bb
>---------------------------------------------------------------
commit 92276676d2fe0561f1f25e5032d736dba04e49bb
Author: Javier <email at localhost>
Date: Sat Sep 24 08:17:50 2022 +0200
Experimental Tibetan justification.
>---------------------------------------------------------------
92276676d2fe0561f1f25e5032d736dba04e49bb
README.md | 11 +++--
babel.dtx | 6 +--
babel.ins | 2 +-
babel.pdf | Bin 885746 -> 885856 bytes
bbcompat.dtx | 2 +-
locale/bo/babel-bo.ini | 1 +
locale/bo/babel-tibetan.tex | 103 ++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 117 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index ac068b9..347a534 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-## Babel 3.80
+## Babel 3.80.2869
+
+**Development**
This package manages culturally-determined typographical (and other)
rules, and hyphenation patterns for a wide range of languages. Many
@@ -8,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.80 are described in:
+Changes in version 3.81 are described in:
-https://latex3.github.io/babel/news/whats-new-in-babel-3.80.html
+https://latex3.github.io/babel/news/whats-new-in-babel-3.81.html
Apart from the manual, you can find information on some aspects of babel at:
@@ -46,6 +48,9 @@ respective authors.
### Summary of latest changes
```
+3.81 dev
+ * Tibetan line breaking and justification.
+
3.80 2022-09-16
* Ethiopic calendar.
* Hungarian date in the superessive case.
diff --git a/babel.dtx b/babel.dtx
index c633f24..1eee69c 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -32,7 +32,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2022/09/17 v3.80 The Babel package]
+\ProvidesFile{babel.dtx}[2022/09/23 v3.80.2869 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -5176,8 +5176,8 @@ help from Bernd Raichle, for which I am grateful.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.80>>
-%<<date=2022/09/17>>
+%<<version=3.80.2869>>
+%<<date=2022/09/23>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
diff --git a/babel.ins b/babel.ins
index 767fe23..d05700e 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/09/17}
+\def\filedate{2022/09/23}
\def\batchfile{babel.ins}
\input docstrip.tex
diff --git a/babel.pdf b/babel.pdf
index 6741e73..6d28f48 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 53b5f46..7d4b1e6 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
%
% \iffalse
%<*dtx>
-\ProvidesFile{bbcompat.dtx}[2022/09/17 v3.80]
+\ProvidesFile{bbcompat.dtx}[2022/09/23 v3.80.2869]
%</dtx>
%
%% File 'bbcompat.dtx'
diff --git a/locale/bo/babel-bo.ini b/locale/bo/babel-bo.ini
index b471025..ba751ca 100644
--- a/locale/bo/babel-bo.ini
+++ b/locale/bo/babel-bo.ini
@@ -27,6 +27,7 @@ script.tag.opentype = tibt
level = 1
encodings =
derivate = no
+require.babel = tibetan
[captions]
preface = དཔེ་དེབ་ཀྱི་གླེང་བརྗོད།
diff --git a/locale/bo/babel-tibetan.tex b/locale/bo/babel-tibetan.tex
index 726f788..e19387a 100644
--- a/locale/bo/babel-tibetan.tex
+++ b/locale/bo/babel-tibetan.tex
@@ -9,4 +9,107 @@
\fi
\BabelBeforeIni{bo}{%
}
+
+\ifcase\bbl at engine\or
+
+\newcommand\EnableTibetanHJ[1][1 .1 0]{%
+ \babelprehyphenation{tibetan}{ [{a}{p}] | }%
+ { {}, {space=#1, data=1 } }%
+ \babelprehyphenation{tibetan}{ ^^^^0f0d | ^^^^0f0d }%
+ { {}, {insert, penalty=10000}, {}, {} }%
+ \babelprehyphenation{tibetan}{ ^^^^0f0b [^ ^^^^0f0d] }%
+ { {}, {insert, space=0 .0001 0, data=1}, {} }%
+ \directlua{
+ Babel.tibetan = Babel.tibetan or {}
+ %
+ Babel.tibetan.justify_enabled = true
+ Babel.tibetan.justify_factor = 1 % 0.98
+ %
+ function Babel.tibetan.justify(head)
+ if not Babel.tibetan.justify_enabled then return head end
+ for line in node.traverse_id(node.id'hlist', head) do
+ Babel.tibetan.justify_hlist(head, line)
+ end
+ return head
+ end
+ %
+ function Babel.tibetan.justify_hbox(head, gc, size, pack)
+ local has_inf = false
+ if Babel.tibetan.justify_enabled and pack == 'exactly' then
+ for n in node.traverse_id(12, head) do
+ if n.stretch_order > 0 then has_inf = true end
+ end
+ if not has_inf then
+ Babel.tibetan.justify_hlist(head, nil, gc, size, pack)
+ end
+ end
+ return head
+ end
+ %
+ function Babel.tibetan.justify_hlist(head, line, gc, size, pack)
+ local d, new
+ local last_t
+ local width, width_new, full, goal, shift
+ local subst_done = false
+ local GLYPH = node.id'glyph'
+ local LOCALE = Babel.attr_locale
+ %
+ if line == nil then
+ line = {}
+ line.glue_sign = 1
+ line.glue_order = 0
+ line.head = head
+ line.shift = 0
+ line.width = size
+ end
+ %
+ if (line.glue_sign == 1 and line.glue_order == 0) then
+ last_t = nil
+ for n in node.traverse_id(GLYPH, line.head) do
+ if n.char == 0x0f0b then % TSHEG
+ last_t = n
+ else
+ last_t = nil
+ end
+ end
+ %
+ if not last_t then goto next_line end
+ %
+ full = line.width
+ shift = line.shift
+ goal = full * Babel.tibetan.justify_factor % A bit crude
+ width = node.dimensions(line.head) % The 'natural' width
+ %
+ while width < goal do
+ subst_done = true
+ d = node.copy(last_t)
+ line.head, new = node.insert_after(line.head, last_t, d)
+ width_new = node.dimensions(line.head)
+ if width_new > goal or width == width_new then
+ node.remove(line.head, new) % Better compute before
+ break
+ end
+ width = width_new
+ end
+ % Must take into account marks and ins, see luatex manual.
+ % Have to be executed only if there are changes. Investigate
+ % what's going on exactly.
+ if subst_done and not gc then
+ d = node.hpack(line.head, full, 'exactly')
+ d.shift = shift
+ node.insert_before(head, line, d)
+ node.remove(head, line)
+ end
+ ::next_line::
+ end % if process line
+ end
+ %
+ luatexbase.add_to_callback('post_linebreak_filter',
+ Babel.tibetan.justify, 'Babel.tibetan.justify')
+ luatexbase.add_to_callback('hpack_filter',
+ Babel.tibetan.justify_hbox, 'Babel.tibetan.justify_hbox')
+ }}
+
+\fi
+
\endinput
\ No newline at end of file
More information about the latex3-commits
mailing list.