summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-03-27 21:52:39 +0100
committerLaurenz <laurmaedje@gmail.com>2021-03-27 21:52:39 +0100
commit57ca9628c14378e8816a8a1f1530ae69c2269907 (patch)
tree01c4dfa7be25047b3f50fc7a186b03d2cd3394b7 /src/layout
parent76fc4cca62f5b955200b2c62cc85b69eea491ece (diff)
Better space coalescing logic 🌧
This creates a smaller state machine helper type for softness coalescing, which does not own the resulting nodes. While this creates a bit more duplication in stack and par builder, it makes it a lot easier to integrate additional logic into the paragraph builder. Furthermore: - Line breaks are now "hard", that is, not coalesced with each other. - Text nodes with equal style are now merged allowing for example `f{}i` to form a ligature.
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/par.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/layout/par.rs b/src/layout/par.rs
index 02e27cbd..e0b42821 100644
--- a/src/layout/par.rs
+++ b/src/layout/par.rs
@@ -23,6 +23,8 @@ pub enum ParChild {
Text(TextNode, Align),
/// Any child node and how to align it in its line.
Any(AnyNode, Align),
+ /// A forced linebreak.
+ Linebreak,
}
/// A consecutive, styled run of text.
@@ -55,6 +57,7 @@ impl Layout for ParNode {
layouter.push_frame(frame, align);
}
}
+ ParChild::Linebreak => layouter.finish_line(),
}
}
layouter.finish()