Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Catalan hyphenations at geminated L #1964

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions core/hyphenator-liang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 114,44 @@ local hyphenateNode = function (node)
local hyphen = SILE.shaper:createNnodes(SILE.settings:get("font.hyphenchar"), node.options)
local newnodes = {}
for j, segment in ipairs(segments) do
local leadingApostrophe
local specificDiscretionary
if segment == "" then
SU.dump({ j, segments })
SU.error("No hyphenation segment should ever be empty", true)
end
if node.options.language == "tr" then
Omikhleia marked this conversation as resolved.
Show resolved Hide resolved
-- leading apostrophe (on next segment) cancels when hyphenated
local nextApostrophe = j < #segments and luautf8.match(segments[j 1], "^['’]")
if nextApostrophe then
segments[j 1] = luautf8.gsub(segments[j 1], "^['’]", "")
local replacement = SILE.shaper:createNnodes(nextApostrophe, node.options)
leadingApostrophe = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = hyphen })
leadingApostrophe.parent = node
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = hyphen })
end
elseif node.options.language == "ca" then
Omikhleia marked this conversation as resolved.
Show resolved Hide resolved
-- punt volat (middle dot) cancels when hyphenated
-- Catalan typists may use a punt volat or precomposed characters.
-- The shaper might behave differently depending on the font, so we need to
-- be consistent here with the typist's choice.
if luautf8.find(segment, "ŀ$") then -- U 0140
segment = luautf8.sub(segment, 1, -2)
local ldot = SILE.shaper:createNnodes("ŀ", node.options)
local lhyp = SILE.shaper:createNnodes("l" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
elseif luautf8.find(segment, "Ŀ$") then -- U 013F
segment = luautf8.sub(segment, 1, -2)
local ldot = SILE.shaper:createNnodes("Ŀ", node.options)
local lhyp = SILE.shaper:createNnodes("L" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
elseif luautf8.find(segment, "l·$") then -- l U 00B7
segment = luautf8.sub(segment, 1, -3)
local ldot = SILE.shaper:createNnodes("l·", node.options)
local lhyp = SILE.shaper:createNnodes("l" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
elseif luautf8.find(segment, "L·$") then -- L U 00B7
segment = luautf8.sub(segment, 1, -3)
local ldot = SILE.shaper:createNnodes("L·", node.options)
local lhyp = SILE.shaper:createNnodes("L" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
end
end
for _, newNode in ipairs(SILE.shaper:createNnodes(segment, node.options)) do
Expand All @@ -135,8 161,9 @@ local hyphenateNode = function (node)
end
end
if j < #segments then
if leadingApostrophe then
table.insert(newnodes, leadingApostrophe)
if specificDiscretionary then
specificDiscretionary.parent = node
table.insert(newnodes, specificDiscretionary)
else
local newNode = SILE.nodefactory.discretionary({ prebreak = hyphen })
newNode.parent = node
Expand Down
93 changes: 93 additions & 0 deletions tests/fix-catalan-punt-volat.expected
Original file line number Diff line number Diff line change
@@ -0,0 1,93 @@
Set paper size 209.7637818 297.6377985
Begin page
Mx 185.4882
My 25.4756
Set font Gentium Plus;16;400;;normal;;;LTR
T 76 81 w=13.1641 (in)
Mx 198.6523
T 16 w=5.3906 (-)
Mx 10.4882
My 44.6756
T 87 72 w=12.8984 (te)
Mx 23.3866
T 79 w=4.3359 (l)
Mx 27.7226
T 195 w=2.3438 (·)
Mx 30.0663
T 79 76 w=8.6719 (li)
Mx 38.7382
T 74 72 81 87 w=29.5313 (gent)
Mx 185.4882
My 63.8756
T 76 81 w=13.1641 (in)
Mx 198.6523
T 16 w=5.3906 (-)
Mx 10.4882
My 83.0756
T 87 72 w=12.8984 (te)
Mx 23.3866
T 1138 w=6.6797 (ŀ)
Mx 30.0663
T 79 76 w=8.6719 (li)
Mx 38.7382
T 74 72 81 87 w=29.5313 (gent)
Mx 170.4882
My 102.2756
T 76 81 w=13.1641 (in)
Mx 183.6523
T 87 72 w=12.8984 (te)
Mx 196.5507
T 79 w=4.3359 (l)
Mx 200.8866
T 16 w=5.3906 (-)
Mx 10.4882
My 121.4756
T 79 76 w=8.6719 (li)
Mx 19.1601
T 74 72 81 87 w=29.5313 (gent)
Mx 170.4882
My 140.6756
T 76 81 w=13.1641 (in)
Mx 183.6523
T 87 72 w=12.8984 (te)
Mx 196.5507
T 79 w=4.3359 (l)
Mx 200.8866
T 16 w=5.3906 (-)
Mx 10.4882
My 159.8756
T 79 76 w=8.6719 (li)
Mx 19.1601
T 74 72 81 87 w=29.5313 (gent)
Mx 160.4882
My 179.0756
T 76 81 w=13.1641 (in)
Mx 173.6523
T 87 72 w=12.8984 (te)
Mx 186.5507
T 79 w=4.3359 (l)
Mx 190.8866
T 195 w=2.3438 (·)
Mx 193.2304
T 79 76 w=8.6719 (li)
Mx 201.9023
T 16 w=5.3906 (-)
Mx 10.4882
My 198.2756
T 74 72 81 87 w=29.5313 (gent)
Mx 160.4882
My 217.4756
T 76 81 w=13.1641 (in)
Mx 173.6523
T 87 72 w=12.8984 (te)
Mx 186.5507
T 1138 w=6.6797 (ŀ)
Mx 193.2304
T 79 76 w=8.6719 (li)
Mx 201.9023
T 16 w=5.3906 (-)
Mx 10.4882
My 236.6756
T 74 72 81 87 w=29.5313 (gent)
End page
Finish
21 changes: 21 additions & 0 deletions tests/fix-catalan-punt-volat.sil
Original file line number Diff line number Diff line change
@@ -0,0 1,21 @@
\begin[papersize=a7]{document}
\nofolios
\neverindent
\language[main=ca]
\font[size=16]

% Demonstrate break points before, at, and after a geminated L
% using both separate and precomposed glyphs.
\kern[width=175pt]intel·ligent

\kern[width=175pt]inteŀligent

\kern[width=160pt]intel·ligent

\kern[width=160pt]inteŀligent

\kern[width=150pt]intel·ligent

\kern[width=150pt]inteŀligent

\end{document}
Loading