Skip to content

Commit

Permalink
added an option to turn off kashidas after ligatures as asked in late…
Browse files Browse the repository at this point in the history
…x3#258

Replacing simple characters with ligatures seems to be done before
inserting kashidas. This may result in incorrect kashida insertion.

If we have e.g. letters BEH and YEH where a kashida can be inserted in
between. But we also have an BEH+YEH ligature. Now, the glyph on the
a's position gets a kashida weight, but it has been replaced with the
BEH+YEH ligature. So, the result will be inserted kashidas after the
ligature, i.e. after YEH, which is not what we want.

Test case: {بِيَ} with Arabic Typesetting
  • Loading branch information
lueck committed Aug 21, 2023
1 parent dabf53a commit 6fe9518
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion babel.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -14562,6 +14562,7 @@ Babel.arabic.dest = {}
Babel.arabic.justify_factor = 0.95
Babel.arabic.justify_enabled = true
Babel.arabic.kashida_limit = -1
Babel.arabic.kashida_after_ligature_allowed = false

function Babel.arabic.justify(head)
if not Babel.arabic.justify_enabled then return head end
Expand Down Expand Up @@ -14613,8 +14614,12 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack)
pos_inline = 0 % Not yet used

for n in node.traverse_id(GLYPH, line.head) do
local passes_ligature_test
pos_inline = pos_inline + 1 % To find where it is. Not used.

% ligatures (may) cause deferral of kashidas
passes_ligature_test = Babel.arabic.kashida_after_ligature_allowed or n.subtype & 2 ~= 2

% Elongated glyphs
if elong_map then
local locale = node.get_attribute(n, LOCALE)
Expand All @@ -14628,7 +14633,8 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack)
% Tatwil
if Babel.kashida_wts then
local k_wt = node.get_attribute(n, KASHIDA)
if k_wt > 0 then % todo. parameter for multi inserts
% ligatures (may) cause deferral of the kashida by one or more characters
if k_wt > 0 and passes_ligature_test then % todo. parameter for multi inserts
table.insert(k_list, {node = n, weight = k_wt, pos = pos_inline})
end
end
Expand Down

0 comments on commit 6fe9518

Please sign in to comment.