Skip to content

Commit

Permalink
Merge pull request #152 from notgull/justify-font
Browse files Browse the repository at this point in the history
Add Align::End for end-based alignment
  • Loading branch information
jackpot51 authored Jul 8, 2023
2 parents 7d50d17 + aa1b37a commit 9d2f7a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub enum Align {
Right,
Center,
Justified,
End,
}

impl Display for Align {
Expand All @@ -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"),
}
}
}
1 change: 1 addition & 0 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9d2f7a4

Please sign in to comment.