Skip to content

Commit f7aee33

Browse files
committed
Also fixed monospace font for d3-graphviz engine
VS code graphviz extensions use d3-graphviz, which supports `Courier` fontname but does not support `monospace`. This caused graphs to render poorly because the text sizes were wrong.
1 parent c19b237 commit f7aee33

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compiler/rustc_graphviz/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ where
634634
let mut graph_attrs = Vec::new();
635635
let mut content_attrs = Vec::new();
636636
if options.contains(&RenderOption::Monospace) {
637-
let font = r#"fontname="monospace""#;
637+
let font = r#"fontname="Courier, monospace""#;
638638
graph_attrs.push(font);
639639
content_attrs.push(font);
640640
};

compiler/rustc_mir/src/util/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
writeln!(w, "{} {}Mir_{} {{", kind, cluster, def_name)?;
5656

5757
// Global graph properties
58-
let font = r#"fontname="monospace""#;
58+
let font = r#"fontname="Courier, monospace""#;
5959
let mut graph_attrs = vec![font];
6060
let mut content_attrs = vec![font];
6161

src/test/mir-opt/graphviz.main.mir_map.0.dot

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
digraph Mir_0_3 {
2-
graph [fontname="monospace"];
3-
node [fontname="monospace"];
4-
edge [fontname="monospace"];
2+
graph [fontname="Courier, monospace"];
3+
node [fontname="Courier, monospace"];
4+
edge [fontname="Courier, monospace"];
55
label=<fn main() -&gt; ()<br align="left"/>>;
66
bb0__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">0</td></tr><tr><td align="left" balign="left">_0 = const ()<br/></td></tr><tr><td align="left">goto</td></tr></table>>];
77
bb1__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">1</td></tr><tr><td align="left">resume</td></tr></table>>];

0 commit comments

Comments
 (0)