Skip to content

Fonts in user library not detected in MacOS build on Github Actions #58

Closed

Description

@petrbouchal

The problem: on a MacOS build on Github Actions, {systemfonts} does not see fonts installed in user library, reports matching IBM Plex Sans to Helvetica but some other font shows up in the ggplot2 PNG ragg output.

This may well be a limitation of Github Actions (or me doing something wrong in the workflow spec), but logging here in case (a) it can be remedied in {systemfonts} or (b) you have any intuitions as to whether/how it can be handled on the GHA side.

HTML output at https://petrbouchal.xyz/pagetest/ (ignore text...)
Worflow file at https://github.com/petrbouchal/pagetest/blob/master/.github/workflows/website.yml
Workflow output at https://github.com/petrbouchal/pagetest/runs/1400625372?check_suite_focus=true
Rmd code at https://github.com/petrbouchal/pagetest/blob/master/index.Rmd

What I try to do:

  • install a font (IBM Plex Sans via homebrew) on a MacOS run of GHA
  • build a site using rmarkdown::render_site(), containing {ggplot2} graphics using the font
  • rendering via dev = "ragg_png".

What I expect:

  • fonts to be available in user Library
  • {systemfonts}/{ragg} to pick them up
  • correct font or correct fallback font to show up in plot

What I see:

  • homebrew reports installing the fonts into /Users/runner/Library/Fonts;
  • systemfonts::system_fonts() contains only entries with paths starting in /System/Library/Fonts
  • systemfonts::match_font("IBM Plex Sans") returns Helvetica.
  • plot contains odd font, not Helvetica

Feeding the font in manually via systemfonts::register_font() works but that is a bit of a convoluted and long-winded solution - but it confirms that the user font library exists and is accessible to R.

Activity

  1. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    Hi - I just tried installing IBM Plex via brew locally and everything works as it should, so the issue is certainly related to running this in GHA. Maybe the issue is that your R session is not running under the same user as the font installation was? Do you know if it is possible through brew to specify that the font should be installed globally?

  2. petrbouchal commented on Nov 16, 2020

    @petrbouchal
    Author

    Hi,

    many thanks for investigating. System-wide font install is possible but fails on GHA because of permissions.

    I ran Sys.info() and it seems R is running on the same user under which the fonts are installed.

    ##                                                                                              sysname 
    ##                                                                                             "Darwin" 
    ##                                                                                              release 
    ##                                                                                             "19.6.0" 
    ##                                                                                              version 
    ## "Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64" 
    ##                                                                                             nodename 
    ##                                                                            "Mac-1605518904509.local" 
    ##                                                                                              machine 
    ##                                                                                             "x86_64" 
    ##                                                                                                login 
    ##                                                                                               "root" 
    ##                                                                                                 user 
    ##                                                                                             "runner" 
    ##                                                                                       effective_user 
    ##                                                                                             "runner"

    What is odd is that {systemfonts} can access the font files in /Users/runner/Library/Fonts via register_font() (and these are inside the same user home dir as the working directory) but does not see that as a font dir when looking up fonts.

    Also, in case this is helpful, this works:

    systemfonts::register_font("IBM Plex Sans Condensed 2", 
                               plain = '/Users/runner/Library/Fonts/IBMPlexSansCondensed-Regular.otf')

    while this does not

    systemfonts::register_font("IBM Plex Sans Condensed 2", 
                               plain = '~/Library/Fonts/IBMPlexSansCondensed-Regular.otf')

    (It runs without error but the device cannot find the font later.)

    I understand this might not be solvable inside systemfonts but might merit a bit of documentation somewhere, perhaps in a future vignette or in the ragg vignettes.

  3. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    Dang - I had hoped this was a matter of switching user between font install and running R...

    systemfonts is using CoreText from the macOS API to figure out font locations and really don't care where they are located... Since this works locally it is not a matter of CoreText not being able to find user fonts, but must be some interaction between that API and the GHA setup. In any regards this is unsolvable from systemfonts... registration should always work as long as there is sufficient permissions on the system

    Sorry, this was not the answer you were hoping for

  4. petrbouchal commented on Nov 16, 2020

    @petrbouchal
    Author

    Thanks - frankly that was my assumption from the beginning: that there is something opaque around the GHA setup. Happy to use the solution based on import_fonts() unless I figure out what the problem is in the GHA setup.

  5. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    Let me know if you uncover anything

  6. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    Can I get you to run system_profiler SPFontsDataType in the shell after installing the fonts and give me a link to the output?

  7. petrbouchal commented on Nov 16, 2020

    @petrbouchal
    Author
  8. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    Also, can you install globally with sudo? Don't know how permissions are handled in GHA

  9. petrbouchal commented on Nov 16, 2020

    @petrbouchal
    Author
  10. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    yeah

  11. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    anyway, the system_profiler call pretty much confirms that Plex is not being installed properly... The OS is oblivious to its existence

  12. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    You may want to open up an issue in brew? 🤷‍♂️

  13. thomasp85 commented on Nov 16, 2020

    @thomasp85
    Member

    Also, maybe try out with another brew font and see if it is a general issue with brew fonts on GHA, or specific to the Plex formula

  14. petrbouchal commented on Nov 18, 2020

    @petrbouchal
    Author

    Thanks!

    anyway, the system_profiler call pretty much confirms that Plex is not being installed properly... The OS is oblivious to its existence

    Thanks for checking - that was my guess from glancing at the log too.

    Also, maybe try out with another brew font and see if it is a general issue with brew fonts on GHA, or specific to the Plex formula

    Yes, same result with other fonts too.

    You may want to open up an issue in brew?

    I wonder if I can narrow this down between brew, the cask formula, and the GHA runner. When you say that the font is not being installed properly, do you have an idea about what else needs to happen for the font to be installed besides the file landing in the right directory?

  15. thomasp85 commented on Oct 13, 2021

    @thomasp85
    Member

    Have you had any luck with figuring out how to get brew fonts installed correctly on GHA?

  16. petrbouchal commented on Dec 17, 2022

    @petrbouchal
    Author

    This seems to have been resolved - fonts installed using brew now appear in the font listing and are used correctly in plot output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions