Skip to content

Commit

Permalink
Fixes linebender#138 - placing inline boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
spirali committed Nov 8, 2024
1 parent 824b9ba commit 0dfda2d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions parley/src/layout/line/greedy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,31 @@ impl<'a, B: Brush> BreakLines<'a, B> {

match item.kind {
LayoutItemKind::InlineBox => {
/* This fixes issue #138
It fixes an inline box that starts at then beginning of a non-first line
We need to check that current cluster_idx (a first cluster of the following run)
does not contain mandatory break (it means that cluster_idx - 1 is \n)
We have to process line breaking right now before processing inline boxes,
otherwise line break will occur in processing of the following run, and it is
too late and inline box will end on the previous line.
*/
if !self.state.line.skip_mandatory_break
&& self
.layout
.data
.clusters
.get(self.state.cluster_idx)
.map(|c| c.info.boundary() == Boundary::Mandatory)
.unwrap_or(false)
{
self.state.prev_boundary = None;
self.state.line.items.end = self.state.item_idx;
self.state.line.clusters.end = self.state.cluster_idx;
self.state.line.skip_mandatory_break = true;
if try_commit_line!(BreakReason::Explicit) {
return self.start_new_line();
}
}
let inline_box = &self.layout.data.inline_boxes[item.index];

// Compute the x position of the content being currently processed
Expand Down

0 comments on commit 0dfda2d

Please sign in to comment.