summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/babel/luababel.def
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-06-26 20:20:23 +0000
committerKarl Berry <karl@freefriends.org>2023-06-26 20:20:23 +0000
commit134e380f56751b8fd3be6a5646ad906ba4f2b550 (patch)
tree1a6579cf1bf8f1c1c5c6aa1d938fd83bdf1862d5 /Master/texmf-dist/tex/generic/babel/luababel.def
parentc85ad0f14d77bd654bfa06eec8e8b02cd0fb5482 (diff)
babel (26jun23)
git-svn-id: svn://tug.org/texlive/trunk@67485 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/babel/luababel.def')
-rw-r--r--Master/texmf-dist/tex/generic/babel/luababel.def40
1 files changed, 32 insertions, 8 deletions
diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def
index fd06001fb0b..befca370e79 100644
--- a/Master/texmf-dist/tex/generic/babel/luababel.def
+++ b/Master/texmf-dist/tex/generic/babel/luababel.def
@@ -604,8 +604,13 @@ end
\gdef\bbl@arabicjust{%
\let\bbl@arabicjust\relax
\newattribute\bblar@kashida
- \directlua{ Babel.attr_kashida = luatexbase.registernumber'bblar@kashida' }%
+ \newattribute\bblar@kashida@aux % 0, 1=tatweel, 2=diacritics
+ \directlua{% WIP
+ Babel.attr_kashida = luatexbase.registernumber'bblar@kashida'
+ Babel.attr_kashida_aux = luatexbase.registernumber'bblar@kashida@aux'
+ }%
\bblar@kashida=\z@
+ \bblar@kashida@aux=\z@
\bbl@patchfont{{\bbl@parsejalt}}%
\directlua{
Babel.arabic.elong_map = Babel.arabic.elong_map or {}
@@ -675,6 +680,7 @@ Babel.arabic.from = {}
Babel.arabic.dest = {}
Babel.arabic.justify_factor = 0.95
Babel.arabic.justify_enabled = true
+Babel.arabic.kashida_limit = -1
function Babel.arabic.justify(head)
if not Babel.arabic.justify_enabled then return head end
@@ -703,6 +709,7 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack)
local width, width_new, full, k_curr, wt_pos, goal, shift
local subst_done = false
local elong_map = Babel.arabic.elong_map
+ local cnt
local last_line
local GLYPH = node.id'glyph'
local KASHIDA = Babel.attr_kashida
@@ -775,7 +782,7 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack)
if #k_list == 0 then goto next_line end
width = node.dimensions(line.head) % The 'natural' width
- k_curr = #k_list
+ k_curr = #k_list % Traverse backwards, from the end
wt_pos = 1
while width < goal do
@@ -800,6 +807,22 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack)
end
end
+ % Limit the number of tatweel by removing them. Not very efficient,
+ % but it does the job in a quite predictable way.
+ if Babel.arabic.kashida_limit > -1 then
+ cnt = 0
+ for n in node.traverse_id(GLYPH, line.head) do
+ if n.char == 0x0640 then
+ cnt = cnt + 1
+ if cnt > Babel.arabic.kashida_limit then
+ node.remove(line.head, n)
+ end
+ else
+ cnt = 0
+ end
+ end
+ end
+
::next_line::
% Must take into account marks and ins, see luatex manual.
@@ -1368,7 +1391,8 @@ end
luatexbase.priority_in_callback('hpack_filter',
'luaotfload.node_processor') or nil)
}}
-\ifnum\bbl@bidimode>\@ne % Excludes default=1
+\breakafterdirmode=1
+\ifnum\bbl@bidimode>\@ne % Any bidi= except default=1
\let\bbl@beforeforeign\leavevmode
\AtEndOfPackage{\EnableBabelHook{babel-bidi}}
\RequirePackage{luatexbase}
@@ -1415,7 +1439,7 @@ end
\def\bbl@bodydir{\bbl@setluadir{body}\bodydir}% Used once
\def\bbl@pagedir{\bbl@setluadir{page}\pagedir}% Unused
\def\bbl@dirparastext{\pardir\the\textdir\relax}% Used once
-\ifnum\bbl@bidimode>\z@
+\ifnum\bbl@bidimode>\z@ % Any bidi=
\def\bbl@insidemath{0}%
\def\bbl@everymath{\def\bbl@insidemath{1}}
\def\bbl@everydisplay{\def\bbl@insidemath{2}}
@@ -1444,7 +1468,7 @@ end
}}%
\fi
\bbl@trace{Redefinitions for bidi layout}
-\ifnum\bbl@bidimode>\z@
+\ifnum\bbl@bidimode>\z@ % Any bidi=
\ifx\matheqdirmode\@undefined\else
\matheqdirmode\@ne % A luatex primitive
\fi
@@ -1641,7 +1665,7 @@ end
{\IfBabelLayout{notabular}%
{\chardef\bbl@tabular@mode\z@}%
{\chardef\bbl@tabular@mode\@ne}}% Mixed, with LTR cols
-\ifnum\bbl@bidimode>\@ne
+\ifnum\bbl@bidimode>\@ne % Any bidi= except default=1
\ifnum\bbl@tabular@mode=\@ne
\let\bbl@parabefore\relax
\AddToHook{para/before}{\bbl@parabefore}
@@ -1675,7 +1699,7 @@ end
{}}
\fi
\ifx\bbl@opt@layout\@nnil\endinput\fi % if no layout
-\ifnum\bbl@bidimode>\z@
+\ifnum\bbl@bidimode>\z@ % Any bidi=
\def\bbl@nextfake#1{% non-local changes, use always inside a group!
\bbl@exp{%
\def\\\bbl@insidemath{0}%
@@ -1831,7 +1855,7 @@ end
\let\bbl@OL@p@enumiii\p@enumiii
\def\p@enumiii{\p@enumii)\theenumii(}}{}}{}
\bbl@trace{Bidi footnotes}
-\ifnum\bbl@bidimode>\z@
+\ifnum\bbl@bidimode>\z@ % Any bidi=
\def\bbl@footnote#1#2#3{%
\@ifnextchar[%
{\bbl@footnote@o{#1}{#2}{#3}}%