Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RC font not rendering in shiny #19

Open
PaulC91 opened this issue May 19, 2017 · 7 comments
Open

RC font not rendering in shiny #19

PaulC91 opened this issue May 19, 2017 · 7 comments

Comments

@PaulC91
Copy link

PaulC91 commented May 19, 2017

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!

@oneryalcin
Copy link

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');

@ciflikli
Copy link

@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.

@PaulC91
Copy link
Author

PaulC91 commented Dec 22, 2017

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?

@ciflikli
Copy link

ciflikli commented Dec 22, 2017

@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

@hrbrmstr
Copy link
Owner

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.

@ciflikli
Copy link

Oh nice - is it going to be something along the lines of #5? That sounds like a neat trick.

@ciflikli
Copy link

ciflikli commented Dec 22, 2017

Found a workaround! Blog post

Add this to global.R

require(showtext)
font_add_google(name = "Roboto Condensed", family = "Roboto Condensed",
regular.wt = 400, bold.wt = 700)
showtext_auto()
showtext_opts(dpi = 112)

Link to app

TlaskalV pushed a commit to TlaskalV/Soil_flux_app that referenced this issue Jun 3, 2019
inspiration for hrbrthemes from this great blog chichacha.netlify.com
implementation based on GH issue github.com/hrbrmstr/hrbrthemes/issues/19#issuecomment-353544955
TlaskalV pushed a commit to TlaskalV/Soil_flux_app that referenced this issue Jun 3, 2019
    inspiration for hrbrthemes from this great blog chichacha.netlify.com
    implementation based on GH issue github.com/hrbrmstr/hrbrthemes/issues/19#issuecomment-353544955
TlaskalV pushed a commit to TlaskalV/TMS_visualization that referenced this issue Jun 4, 2019
inspiration for hrbrthemes from this great blog chichacha.netlify.com
implementation based on GH issue github.com/hrbrmstr/hrbrthemes/issues/19#issuecomment-353544955
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants