gadenbuie / xaringanthemer

😎 Give your xaringan slides some style

Home Page:https://pkg.garrickadenbuie.com/xaringanthemer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Be more strict on what "extra_fonts" arg accepts

pat-s opened this issue · comments

Help page

A list of additional fonts to import, each list element can be either a URL as a character string or a call to google_font()

However, other font arguments such as "text_font_google" and friends accept a single font only (which makes sense).
Though if one specifies a single font only for "extra_fonts", not

@import url(https://fonts.googleapis.com/css?family=Crimson+Text);

is parsed into the resulting CSS but only

@import url(Crimson Text);

The latter results in the font not being available.

Suggestion: Either support only a list for extra_fonts or also support single google_font() calls.

(I know these are the ugly details of a package that comes with functions that have so many args... 😄 )

Thanks @pat-s ... You're right, a single google_font() wasn't handled properly by extra_fonts and I fixed this in xaringanthemer@dev. In that branch you should be able to use

  • extra_fonts = c(font_url1, font_url2)
  • extra_fonts = list(google_font(font_name1), google_font(font_name2))
  • extra_fonts = list(font_url1, google_font(font_name1))

I don't think I handled the edge case of accidentally concatenating a URL and a google_font() -- e.g. extra_fonts = c(font_url, google_font(font_name)) -- and I'll look into adding that.

extra_fonts = c(font_url, google_font(font_name))

so many edge cases - I guess no one would expect that to work OOB. But great effort as always 🚀

so many edge cases

So true! So many that I realized I mistyped in my answer, google_font() only takes one font, but you can put multiple google fonts into a list().