From 8e6ac44784f98602caf4984610ee6176cd29eb1f Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 3 Apr 2018 17:44:45 -0500 Subject: [PATCH] default to Helvetica --- R/ggplotly.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/ggplotly.R b/R/ggplotly.R index 9895d97c88..ee2f296a7d 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -438,6 +438,15 @@ gg2list <- function(p, width = NULL, height = NULL, for (i in elements) { theme[[i]] <- ggplot2::calc_element(i, theme) } + # ensure element_text() sizes are interpreted as "points" and defaults to + # "Helvetica" familyfont + isTextElement <- vapply(theme, inherits, logical(1), "element_text") + textElements <- names(isTextElement)[isTextElement] + for (i in textElements) { + theme[[i]]$size <- grid::unit(theme[[i]]$size, "points") + if (identical(theme[[i]]$family, "")) theme[[i]]$family <- "Helvetica" + } + # Translate plot wide theme elements to plotly.js layout pm <- unitConvert(theme$plot.margin, "pixels") gglayout <- list(