Get access to all lessons in this course.
-
Advanced Data Wrangling
- Downloading and Importing Data
- Overview of Tidy Data
- Tidy Data Rule #1: Every Column is a Variable
- Tidy Data Rule #3: Every Cell is a Single Value
- Tidy Data Rule #2: Every Row is an Observation
- Changing Variable Types
- Dealing with Missing Data
- Advanced Summarizing
- Binding Data Frames
- Functions
- Data Merging
- Exporting Data
- Bring It All Together (Advanced Data Wrangling)
-
Advanced Data Visualization
- Best Practices in Data Visualization
- Tidy Data
- Pipe Data into ggplot
- Reorder Plots to Highlight Findings
- Line Charts
- Use Color to Highlight Findings
- Declutter
- Add Descriptive Labels to Your Plots
- Use Titles to Highlight Findings
- Use Annotations to Explain
- Tweak Spacing
- Create a Custom Theme
- Customize Your Fonts
- Try New Plot Types
- Bring it All Together (Advanced Data Visualization)
-
Quarto
- Advanced Markdown
- Advanced YAML and Code Chunk Options
- Tables
- Inline R Code
- Making Your Reports Shine: Word Edition
- Making Your Reports Shine: PDF Edition
- Making Your Reports Shine: HTML Edition
- Presentations
- Dashboards
- Websites
- Publishing Your Work
- Quarto Extensions
- Parameterized Reporting, Part 1
- Parameterized Reporting, Part 2
- Parameterized Reporting, Part 3
- Wrapping up Going Deeper with R
Going Deeper with R
Customize Your Fonts
This lesson is locked
This lesson is called Customize Your Fonts, part of the Going Deeper with R course. This lesson is called Customize Your Fonts, part of the Going Deeper with R course.
If the video is not playing correctly, you can watch it in a new window
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Heads up! Working with custom fonts changed significantly after I recorded the lessons for this course. I've added an updated video below. The new changes make working with custom fonts much easier than it used to be.
Your Turn
Install the
ragg
andsystemfonts
packageChange your settings in RStudio so you can render with AGG
Change all text in your last plot to use a custom font (you’ll have to do this in a few different places)
Save your plot using
ggsave()
Learn More
If you’re interested in a quite technical blog post on the changes to working with custom fonts, Thomas Lin Pedersen, developer of ragg
and systemfonts
, has written up an explanation of the problem these packages solve.
The best resource for learning more about how to use custom fonts is this article by June Choe.
You need to be signed-in to comment on this post. Login.
Abby Isaacson
May 19, 2021
Just curious if the fonts library changes over time? For example, your Karla font isn't an option among the 158 font choices that show up for me.
Harold Stanislaw
May 26, 2021
This may be peculiar to my setup, but when I run the fonts command I see only 150 fonts, even though my system actually has quite a few more. (Perhaps they're not showing up because when I ran loadfonts I got this error message LOTS of times: "string 4 is invalid in this localeinput".) I tried using Bauhaus 93, which was not listed by the fonts command, and Bauhaus was actually applied to my graph. So, fonts are available to R that don't show up when running the fonts command.
Lucilla Piccari
May 26, 2021
Hello!
When I try to import "Karla" with the following code: font_import(pattern = "Karla") I get the following error message: Scanning ttf files in C:\Windows\Fonts ... Extracting .afm files from .ttf files... Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) : arguments imply differing number of rows: 0, 1
I have already imported other fonts and have verified that 187 are available, but Karla is not among them.
Am I doing something wrong?
Thank you!
Matt M
December 7, 2021
I've tried three things and only Heiss' advice to specifically load Comic Sans works (which is not super helpful since i'll never use that font). I'm on Windows.
I installed extrafont. When I run font_import() I get the following in the Console: > font_import() Importing fonts may take a few minutes, depending on the number of fonts and the speed of the system. Continue? [y/n] y Scanning ttf files in C:\windows\Fonts ... Extracting .afm files from .ttf files... C:\Windows\Fonts\AGENCYB.TTF : No FontName. Skipping. C:\Windows\Fonts\AGENCYR.TTF : No FontName. Skipping. C:\Windows\Fonts\ALGER.TTF : No FontName. Skipping. C:\Windows\Fonts\ANTQUAB.TTF : No FontName. Skipping. .... C:\Windows\Fonts\WINGDNG3.TTF : No FontName. Skipping. C:\Windows\Fonts\ZWAdobeF.TTF : No FontName. Skipping. Found FontName for 0 fonts. Scanning afm files in C:/Users/mmakel1/OneDrive - Johns Hopkins/Documents/R/win-library/4.1/extrafontdb/metrics There were 50 or more warnings (use warnings() to see the first 50)"
When I run windowsFonts() > windowsFonts() $serif [1] "TT Times New Roman" $sans [1] "TT Arial" $mono [1] "TT Courier New" >
following Andrew Heiss' blog, when i run capabilities(), I do get TRUE for Cairo, but don't see it in my list of fonts.
When I run, [from Heiss blog] windowsFonts(
Comic Sans MS
= windowsFont("Comic Sans MS") That increases my fonts to 4. (but not super helpful since I will never use Comic Sans). It's fine if I have to load them one at a time, but I don't know the official font names in Windows. ...The above errors aren't as the closest toComic Sans MS
are: C:\Windows\Fonts\comic.ttf : No FontName. Skipping. C:\Windows\Fonts\comicbd.ttf : No FontName. Skipping. C:\Windows\Fonts\comici.ttf : No FontName. Skipping.JULIO VERA DE LEON
May 7, 2022
I couldn't make it work. I installed the package, ran font import (I get a No Font Name error) and then with fonts I get a "NULL".
Mychal Davis
June 2, 2022
Hello,
I am not able to load any fonts into R. I am using Windows. I tried using the code that was submitted below "library(extrafont) library(remotes) remotes::install_version(“Rttf2pt1”, version = “1.3.8”) extrafont::font_import()", but that did not work for me.
Also, I'm not certain that I am loading the fonts correctly in showtext. When I followed the directions listed on https://cran.rstudio.com/web/packages/showtext/vignettes/introduction.html, I got the following error: > showtext::font_add_google Error: 'font_add_google' is not an exported object from 'namespace:showtext'
Hannah Ridenour LaFrance
December 3, 2022
I'm getting an unused argument error on (base_family = "Ariel"), regardless of what font family I try. I had no problem viewing my list of available fonts, but none of them want to work with theme_minimal.