Paint monospace paragraphs with the embedded mono face
This commit is contained in:
1 parent
6dd4f6bf83
commit
1633e441de
4 files changed
+19
-2
No files matched your search
@@ -1939,6 +1939,21 @@ mod tests {
|
||||
assert!(text.trim_end().ends_with("%%EOF"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mono_paragraph_paints_with_a_mono_face() {
|
||||
let unit = Unit::paragraph_with_face(1, "code 123", ParagraphFont::Mono);
|
||||
let page = Page {
|
||||
items: unit.items,
|
||||
insertions: Vec::new(),
|
||||
marks: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
sources: Vec::new(),
|
||||
hash: 0,
|
||||
};
|
||||
let svg = page.display_list().to_svg();
|
||||
assert!(svg.contains("font-family=\"monospace\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bold_paragraph_paints_with_a_bold_face() {
|
||||
let document = Document::new(
|
||||
|
||||
@@ -72,6 +72,7 @@ pub enum ParagraphFont {
|
||||
Roman,
|
||||
Bold,
|
||||
Italic,
|
||||
Mono,
|
||||
}
|
||||
|
||||
impl Default for ParagraphFont {
|
||||
|
||||
@@ -367,6 +367,7 @@ impl Page {
|
||||
ParagraphFont::Roman => FontFace::Roman,
|
||||
ParagraphFont::Bold => FontFace::Bold,
|
||||
ParagraphFont::Italic => FontFace::Italic,
|
||||
ParagraphFont::Mono => FontFace::Mono,
|
||||
};
|
||||
let lines = paragraph.lines.len().max(1) as i64;
|
||||
let line_height = (paragraph.height / lines).max(1);
|
||||
|
||||
Reference in new issue
Block a user