Right-align route-D paragraphs and preview flushright blocks
This commit is contained in:
1 parent
6714591704
commit
40ed26e339
5 files changed
+43
-2
No files matched your search
@@ -45,6 +45,8 @@ pub struct ParagraphStyle {
|
||||
/// Center each line in the measure instead of justifying it.
|
||||
#[serde(default)]
|
||||
pub centered: bool,
|
||||
#[serde(default)]
|
||||
pub right_aligned: bool,
|
||||
pub par_indent: i64,
|
||||
pub line_height: i64,
|
||||
pub char_width: i64,
|
||||
@@ -60,6 +62,7 @@ impl Default for ParagraphStyle {
|
||||
left_skip: 0,
|
||||
right_skip: 0,
|
||||
centered: false,
|
||||
right_aligned: false,
|
||||
par_indent: 0,
|
||||
line_height: 12,
|
||||
char_width: 10,
|
||||
@@ -97,6 +100,8 @@ pub struct Paragraph {
|
||||
pub left_skip: i64,
|
||||
#[serde(default)]
|
||||
pub centered: bool,
|
||||
#[serde(default)]
|
||||
pub right_aligned: bool,
|
||||
}
|
||||
|
||||
impl Paragraph {
|
||||
@@ -157,6 +162,7 @@ pub fn layout_items(items: &[HorizontalItem], style: &ParagraphStyle) -> Paragra
|
||||
font: ParagraphFont::Roman,
|
||||
left_skip: style.left_skip,
|
||||
centered: style.centered,
|
||||
right_aligned: style.right_aligned,
|
||||
};
|
||||
}
|
||||
let mut breakpoints = vec![0_usize];
|
||||
@@ -334,6 +340,7 @@ pub fn layout_items(items: &[HorizontalItem], style: &ParagraphStyle) -> Paragra
|
||||
font: ParagraphFont::Roman,
|
||||
left_skip: style.left_skip,
|
||||
centered: style.centered,
|
||||
right_aligned: style.right_aligned,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -389,6 +389,8 @@ impl Page {
|
||||
.sum();
|
||||
let mut x = if paragraph.centered {
|
||||
paragraph.left_skip + ((paragraph.width - natural) / 2).max(0)
|
||||
} else if paragraph.right_aligned {
|
||||
paragraph.left_skip + (paragraph.width - natural).max(0)
|
||||
} else {
|
||||
paragraph.left_skip
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user