Add option to dot::render for monospace font

This commit is contained in:
Dylan MacKenzie 2020-01-21 13:35:17 -08:00
parent effd52078c
commit 852afa2e88
2 changed files with 11 additions and 1 deletions

View File

@ -597,6 +597,8 @@ pub enum RenderOption {
NoNodeLabels,
NoEdgeStyles,
NoNodeStyles,
Monospace,
}
/// Returns vec holding all the default render options.
@ -626,6 +628,14 @@ where
W: Write,
{
writeln!(w, "digraph {} {{", g.graph_id().as_slice())?;
// Global graph properties
if options.contains(&RenderOption::Monospace) {
writeln!(w, r#" graph[fontname="monospace"];"#)?;
writeln!(w, r#" node[fontname="monospace"];"#)?;
writeln!(w, r#" edge[fontname="monospace"];"#)?;
}
for n in g.nodes().iter() {
write!(w, " ")?;
let id = g.node_id(n);

View File

@ -331,7 +331,7 @@ where
let mut buf = Vec::new();
let graphviz = graphviz::Formatter::new(body, def_id, results, &mut *formatter);
dot::render(&graphviz, &mut buf)?;
dot::render_opts(&graphviz, &mut buf, &[dot::RenderOption::Monospace])?;
fs::write(&path, buf)?;
Ok(())
}