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,
|
NoNodeLabels,
|
||||||
NoEdgeStyles,
|
NoEdgeStyles,
|
||||||
NoNodeStyles,
|
NoNodeStyles,
|
||||||
|
|
||||||
|
Monospace,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns vec holding all the default render options.
|
/// Returns vec holding all the default render options.
|
||||||
|
@ -626,6 +628,14 @@ where
|
||||||
W: Write,
|
W: Write,
|
||||||
{
|
{
|
||||||
writeln!(w, "digraph {} {{", g.graph_id().as_slice())?;
|
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() {
|
for n in g.nodes().iter() {
|
||||||
write!(w, " ")?;
|
write!(w, " ")?;
|
||||||
let id = g.node_id(n);
|
let id = g.node_id(n);
|
||||||
|
|
|
@ -331,7 +331,7 @@ where
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
||||||
let graphviz = graphviz::Formatter::new(body, def_id, results, &mut *formatter);
|
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)?;
|
fs::write(&path, buf)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue