hrbrthemes
hrbrthemes copied to clipboard
RC font not rendering in shiny
I have a shiny app with Roboto Condensed being the primary font. It links to a CSS stylesheet with the appropriate RC google fonts URL imported in:
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed');
It works on all <h>
and <p>
elements in the app but a ggplot with the ipsum_rc theme set is not rendering the rc font.
You can see the app here. and source code here.
Thanks!
I had a similar issue but I was able to find a workaround by importing CSS in the body element
body <- dashboardBody(tags$head( includeCSS(path = "www/styles.css") ), .... )
and my styles.css
file is as following:
@import url('//fonts.googleapis.com/css?family=Roboto+Condensed:400,700');
@oneryalcin Can you provide code that can reproduce ggplot successfully rendering RC in a Shiny app? I have tried all the CSS tricks and hacks. I have RC displaying correctly without a problem in the app, including body plus other packages (rbokeh, dygraphs etc.), but not in ggplot.
I’m not a CSS or ggplot2 expert but I think the issue is that ggplot2 renders images not html. So we need to figure out how to get the ggplot to use the imported google RC font prior to rendering the image. May need be installed onto the Linux server prior to app loading?
@PaulC91 ggplot definitely seems to produce images that later get embedded, yes. On the Linux server part, I tried the following after seeing Yihui's post somewhere (Google groups?), but it didn't have an effect.
if (Sys.info()[["sysname"]] == "Linux") {
dir.create("~/.fonts")
download.file("https://fonts.googleapis.com/css?family=Roboto+Condensed", "~/.fonts")
system("fc-cache -f ~/.fonts")
}
Edit: Found the link, actually Julia Silge recommended this
I'll be poking at this over the Christmas break, here. I'll embed an example shiny app in the pkg once i get it working.
Oh nice - is it going to be something along the lines of #5? That sounds like a neat trick.