Skip to content

Commit

Permalink
Merge a0ecbcf into 8fafd57
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia committed Feb 4, 2024
2 parents 8fafd57 + a0ecbcf commit b191b33
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
35 changes: 35 additions & 0 deletions tests/bug-liner-width.expected
@@ -0,0 +1,35 @@
Set paper size 209.7637818 297.6377985
Begin page
Push color 0.5020 0.5020 0.5020
Draw line 10.4882 14.8819 188.7874 34.5868
Pop color
Push color 0.5020 0.5020 0.5020
Draw line 10.4882 53.2819 188.7874 34.5868
Pop color
Push color 0.5020 0.5020 0.5020
Draw line 10.4882 91.6819 116.2969 34.5868
Pop color
Mx 10.4882
My 154.3006
Set font Gentium Plus;32;400;;normal;;;LTR
T 79 82 74 76 16 w=59.8281 (logi-)
Mx 70.3163
T 93 82 87 92 w=56.4688 (zoty)
Mx 139.4475
T 79 82 74 76 16 w=59.8281 (logi-)
Mx 10.4882
My 192.7006
T 16 w=10.7813 (-)
Mx 21.2694
T 93 82 87 92 w=56.4688 (zoty)
Mx 82.9787
T 79 82 74 76 16 w=59.8281 (logi-)
Mx 142.8068
T 93 82 87 92 w=56.4688 (zoty)
Mx 10.4882
My 231.1006
T 79 82 74 76 16 w=59.8281 (logi-)
Mx 70.3163
T 93 82 87 92 w=56.4688 (zoty)
End page
Finish
31 changes: 31 additions & 0 deletions tests/bug-liner-width.sil
@@ -0,0 +1,31 @@
\begin[papersize=a7]{document}
\nofolios
\neverindent
\font[size=32pt,language=pl]
\begin{lua}
-- MVE: Use the box width to advance position, rather than rely on internal content to move it.
SILE.documentState.documentClass:registerCommand("advance-box-width", function (options, content)
local bs = SILE.measurement("0.9bs"):tonumber()
local bsratio = 0.3
SILE.typesetter:liner("advance-box-width", content,
function (box, typesetter, line)
local outputWidth = SU.rationWidth(box.width, box.width, line.ratio)
local height = SU.max(box.height:tonumber(), (1 - bsratio) * bs)
local depth = SU.max(box.depth:tonumber(), bsratio * bs)
local cx, cy = typesetter.frame.state.cursorX, typesetter.frame.state.cursorY
SILE.outputter:pushColor(SILE.color("gray"))
SILE.outputter:drawRule(cx, cy - height, outputWidth, height + depth)
SILE.outputter:popColor()
typesetter.frame:advanceWritingDirection(outputWidth)
end
)
end)
\end{lua}

% In liner
\advance-box-width{logi-zoty logi-zoty logi-zoty logi-zoty}

% Vs. normal
logi-zoty logi-zoty logi-zoty logi-zoty

\end{document}
15 changes: 14 additions & 1 deletion typesetters/base.lua
Expand Up @@ -962,7 +962,20 @@ function linerBox:_init (name, outputMethod)
end
function linerBox:append (node)
self.inner[#self.inner+1] = node
self.width = self.width + node.width
if node.is_discretionary then
-- Discretionary nodes don't have a width of their own.
if node.used then
if node.is_prebreak then
self.width:___add(node:prebreakWidth())
else
self.width:___add(node:postbreakWidth())
end
else
self.width:___add(node:replacementWidth())
end
else
self.width:___add(node.width:absolute())
end
self.height = SU.max(self.height, node.height)
self.depth = SU.max(self.depth, node.depth)
end
Expand Down

0 comments on commit b191b33

Please sign in to comment.