From f7aee330c70ef787d2224adb49804343978dd145 Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Wed, 9 Sep 2020 14:49:32 -0700 Subject: [PATCH] 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. --- compiler/rustc_graphviz/src/lib.rs | 2 +- compiler/rustc_mir/src/util/graphviz.rs | 2 +- src/test/mir-opt/graphviz.main.mir_map.0.dot | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index 252e3416865..29ec3572016 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -634,7 +634,7 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G, w: &mut W, options: &[RenderOption] let mut graph_attrs = Vec::new(); let mut content_attrs = Vec::new(); if options.contains(&RenderOption::Monospace) { - let font = r#"fontname="monospace""#; + let font = r#"fontname="Courier, monospace""#; graph_attrs.push(font); content_attrs.push(font); }; diff --git a/compiler/rustc_mir/src/util/graphviz.rs b/compiler/rustc_mir/src/util/graphviz.rs index bc1e3fa8b29..e89c9437706 100644 --- a/compiler/rustc_mir/src/util/graphviz.rs +++ b/compiler/rustc_mir/src/util/graphviz.rs @@ -55,7 +55,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>( writeln!(w, "{} {}Mir_{} {{", kind, cluster, def_name)?; // Global graph properties - let font = r#"fontname="monospace""#; + let font = r#"fontname="Courier, monospace""#; let mut graph_attrs = vec![font]; let mut content_attrs = vec![font]; diff --git a/src/test/mir-opt/graphviz.main.mir_map.0.dot b/src/test/mir-opt/graphviz.main.mir_map.0.dot index f5d8b84812a..df4f11f0f21 100644 --- a/src/test/mir-opt/graphviz.main.mir_map.0.dot +++ b/src/test/mir-opt/graphviz.main.mir_map.0.dot @@ -1,7 +1,7 @@ digraph Mir_0_3 { - graph [fontname="monospace"]; - node [fontname="monospace"]; - edge [fontname="monospace"]; + graph [fontname="Courier, monospace"]; + node [fontname="Courier, monospace"]; + edge [fontname="Courier, monospace"]; label=>; bb0__0_3 [shape="none", label=<
0
_0 = const ()
goto
>]; bb1__0_3 [shape="none", label=<
1
resume
>]; -- 2.44.0