USAID-OHA-SI / glitr

SI graphics package to adorn your ggplots
https://usaid-oha-si.github.io/glitr/
Other
27 stars 4 forks source link

Issues on mac with default font #75

Closed achafetz closed 1 year ago

achafetz commented 1 year ago

glitr sets up the default font to be SSP if it exists on the machine and if not, got with the OS default sans serif font. The default has changed on Apples from Helvetica to San Francisco. As a result, this is causing errors on newer Apple machines.

image

Need to adjust the utility function to be San Francisco.

https://github.com/USAID-OHA-SI/glitr/blob/0ed30aa9c39e863fc3ef52111057686f30878914/R/utils.R#L59-L61

achafetz commented 1 year ago

Tested with Joe. No San Francisco but we got the default to work by changing the default to Arial. This fixed the install, but we still ran into errors when running ggplot with si_sytles on a mac.

library(tidyverse)
library(glitr)
library(extrafont)    

iris %>%     
    ggplot(aes(Sepal.Length, Sepal.Width)) +
    geom_point() 

iris %>%     
    ggplot(aes(Sepal.Length, Sepal.Width)) +
    geom_point() +
    si_style()

Ideally, we could use a similar setup for the default typeface that works on PC https://github.com/USAID-OHA-SI/glitr/blob/0ed30aa9c39e863fc3ef52111057686f30878914/R/utils.R#L50

However neither of these options seem to work on a Mac, so we had to specify the default manually. grDevices::quartzFonts(glitr_font_default = grDevices::X11Fonts()$sans) grDevices::quartzFonts(glitr_font_default = grDevices::quartzFont(rep(grDevices::X11Fonts()$sans, 4)))