Used to gate font-dependent code paths and tests, and by ct_theme()
to walk its font_fallback chain.
Arguments
- name
Font family name, as it appears in the
familycolumn ofsystemfonts::system_fonts()orsystemfonts::registry_fonts().
Details
Checks both font tables systemfonts maintains: families installed on
the operating system (systemfonts::system_fonts()) and families
registered for the current session with
systemfonts::register_font() (systemfonts::registry_fonts()).
Registered fonts do not appear in the system table, so checking only
that one would silently reject a corporate font a user had registered
from a file rather than installed.
Examples
has_font("Arial")
#> [1] FALSE
# Registered fonts count as available, so a client brand font you
# register from a file can be used by name:
if (FALSE) { # \dontrun{
systemfonts::register_font("ClientSans", plain = "~/fonts/ClientSans.ttf")
has_font("ClientSans")
ct_theme(font = "ClientSans")
} # }
