Skip to content

Commit f421259

Browse files
committed
add default fonts
1 parent 522397c commit f421259

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ansi2/src/css.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ impl Style {
105105
css.push_str(&row_style);
106106

107107
let text_style = format!(
108-
".{}{{margin:0;padding:0;font-family:{font_family};white-space:pre;display:inline-block;font-size:{font_size}px}}",
109-
NodeStyle::Text.class_name()
110-
);
108+
".{}{{margin:0;padding:0;font-family:{font_family};white-space:pre;display:inline-block;font-size:{font_size}px}}",
109+
NodeStyle::Text.class_name()
110+
);
111111
css.push_str(&text_style);
112112
}
113113
}
@@ -267,3 +267,5 @@ impl Style {
267267
css
268268
}
269269
}
270+
271+
pub const DEFAULT_FONTS: &str = "Consolas,Courier New,Monaco,monospace";

ansi2/src/html.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
canvas::Canvas,
3-
css::{CssType, Mode, NodeStyle, Style},
3+
css::{CssType, DEFAULT_FONTS, Mode, NodeStyle, Style},
44
theme::ColorTable,
55
};
66

@@ -24,7 +24,7 @@ pub fn to_html<S: AsRef<str>>(
2424
let mut style = Style::default();
2525

2626
let mut font_style = "".into();
27-
let mut font_family = "Consolas,Courier New,Monaco".into();
27+
let mut font_family = DEFAULT_FONTS.into();
2828

2929
if let Some(url) = font {
3030
if url.starts_with("http") || url.starts_with("data:font;base64") {

ansi2/src/svg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
canvas::Canvas,
3-
css::{CssType, Mode, NodeStyle, Style},
3+
css::{CssType, Mode, NodeStyle, Style,DEFAULT_FONTS},
44
theme::ColorTable,
55
};
66
#[allow(clippy::too_many_arguments)]
@@ -31,7 +31,7 @@ pub fn to_svg<S: AsRef<str>, T: ColorTable>(
3131
let mut cur_y = 0;
3232
let mut style = Style::default();
3333
let mut font_style = "".into();
34-
let mut font_family = "Consolas,Courier New,Monaco".into();
34+
let mut font_family = DEFAULT_FONTS.into();
3535

3636
if let Some(url) = font {
3737
if url.starts_with("http") || url.starts_with("data:font;base64") {

0 commit comments

Comments
 (0)