From 5c29332ace48d8c34ad415ffcdce2641526938b8 Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Wed, 16 Sep 2020 08:10:06 -0700 Subject: Make graphviz font configurable Alternative to PR ##76776. To change the graphviz output to use an alternative `fontname` value, add a command line option like: `rustc --graphviz-font=monospace`. --- compiler/rustc_graphviz/src/lib.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'compiler/rustc_graphviz/src') diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index 29ec3572016..58db81bc1dc 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -591,14 +591,14 @@ pub trait GraphWalk<'a> { fn target(&'a self, edge: &Self::Edge) -> Self::Node; } -#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum RenderOption { NoEdgeLabels, NoNodeLabels, NoEdgeStyles, NoNodeStyles, - Monospace, + Fontname(String), DarkTheme, } @@ -633,11 +633,14 @@ where // Global graph properties let mut graph_attrs = Vec::new(); let mut content_attrs = Vec::new(); - if options.contains(&RenderOption::Monospace) { - let font = r#"fontname="Courier, monospace""#; - graph_attrs.push(font); - content_attrs.push(font); - }; + let font; + if let Some(fontname) = options.iter().find_map(|option| { + if let RenderOption::Fontname(fontname) = option { Some(fontname) } else { None } + }) { + font = format!(r#"fontname="{}""#, fontname); + graph_attrs.push(&font[..]); + content_attrs.push(&font[..]); + } if options.contains(&RenderOption::DarkTheme) { graph_attrs.push(r#"bgcolor="black""#); content_attrs.push(r#"color="white""#); -- cgit 1.4.1-3-g733a5