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

Possible to export google_font_list? #7

Closed
camille-s opened this issue Jul 3, 2018 · 2 comments
Closed

Possible to export google_font_list? #7

camille-s opened this issue Jul 3, 2018 · 2 comments

Comments

@camille-s
Copy link

First off, I really appreciate this and showtext! I'm trying to test different google fonts for a ggplot theme, and want to see a list of available sans-serif ones. I know I can filter on the Google fonts website, but some fonts there aren't available for showtext because of licensing and other issues (is that correct?)

Looking through the package code, I see that google_font_list returns a data frame that includes categories, so I recreated part of google_font_db in order to get a nested data frame as follows:

library(tidyverse)

fonts <- "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/sysfonts/fonts/webfonts.bz2"
con <- bzfile(fonts, "rb")
font_list <- readLines(con)
close(con)

jsonlite::fromJSON(font_list) %>%
  `[[`("items") %>%
  select(-files) %>%
  filter(category == "sans-serif") %>%
  head(n = 4)
#>               kind   family   category        variants subsets version
#> 1 webfonts#webfont  ABeeZee sans-serif regular, italic   latin     v11
#> 2 webfonts#webfont     Abel sans-serif         regular   latin      v8
#> 3 webfonts#webfont Aclonica sans-serif         regular   latin      v8
#> 4 webfonts#webfont     Acme sans-serif         regular   latin      v7
#>   lastModified
#> 1   2017-10-10
#> 2   2017-10-10
#> 3   2017-10-10
#> 4   2017-10-10

Some of the meta data about the fonts is handy to have, such as filtering for fonts that have more than one variant, or have an italic face, etc.

I could write a function to do this when I need it, but I was wondering if google_font_list could be exported from the package. I don't know if there's a reason why it currently isn't exported, but it might be useful to other users as well.

Thanks in advance!

@yixuan
Copy link
Owner

yixuan commented Jul 7, 2018

Thank you for the comments. I'll think about how to add this feature in the next release.

@yixuan
Copy link
Owner

yixuan commented Jul 11, 2018

I have added a new function font_info_google() in c7b23b4.

@yixuan yixuan closed this as completed Jul 11, 2018
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

2 participants