Merge pull request #152 from notgull/justify-font

Add Align::End for end-based alignment
This commit is contained in:
Jeremy Soller 2023-07-08 11:19:09 -06:00 committed by GitHub
commit 9d2f7a443a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -120,6 +120,7 @@ pub enum Align {
Right,
Center,
Justified,
End,
}
impl Display for Align {
@ -129,6 +130,7 @@ impl Display for Align {
Self::Right => write!(f, "Right"),
Self::Center => write!(f, "Center"),
Self::Justified => write!(f, "Justified"),
Self::End => write!(f, "End"),
}
}
}

View file

@ -1001,6 +1001,7 @@ impl ShapeLine {
(Align::Right, true) => 0.,
(Align::Right, false) => line_width - visual_line.w,
(Align::Center, _) => (line_width - visual_line.w) / 2.0,
(Align::End, _) => line_width - visual_line.w,
(Align::Justified, _) => {
// Don't justify the last line in a paragraph.
if visual_line.spaces > 0 && index != number_of_visual_lines - 1 {