Add option to `dot::render` for monospace font
This commit is contained in:
parent
effd52078c
commit
852afa2e88
|
@ -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);
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue