Skip to contents

Text measurement

Compute text width, ascent and descent using Cairo, independently of any graphic device. strings_sizes() is the recommended entry point.

strings_sizes()
Compute strings sizes

Font set

Create a font set that bundles registration, HTML dependencies and family names in one step. Use font_google() or font_liberation() to describe each font role, then pass the result to girafe(), dsvg() or ggplot2 themes. font_set_liberation() is a ready-made set that works offline on any platform.

font_set()
Create a font set
font_set_liberation()
Liberation font set
font_set_auto()
Automatic font set
font_google()
Google Font specification
font_liberation()
Liberation Font specification

Google Fonts

Lower-level helpers to download, cache and register individual fonts from Google Fonts.

register_gfont()
Register a 'Google Font'
gfontHtmlDependency()
'Google Font' HTML dependency
addGFontHtmlDependency()
Use a Font in Shiny or Markdown
installed_gfonts()
List installed 'Google Fonts'
install_gfont_script()
Shell command to install a font from 'Google Fonts'

Liberation Fonts

Lower-level helpers to register and embed the bundled Liberation fonts (Sans, Serif, Mono) individually.

register_liberationsans()
Register font 'Liberation Sans'
register_liberationserif()
Register font 'Liberation Serif'
register_liberationmono()
Register font 'Liberation Mono'
liberationsansHtmlDependency()
'Liberation Sans' Font HTML dependency
liberationserifHtmlDependency()
'Liberation Serif' Font HTML dependency
liberationmonoHtmlDependency()
'Liberation Mono' Font HTML dependency

Font discovery

Query available fonts on the system. font_family_exists() checks whether a font is available, sys_fonts() lists all known fonts, and match_family() finds the best match for a given name.

font_family_exists()
Check if font family exists.
sys_fonts()
List fonts for 'systemfonts'.

Font cache

Manage the local directory where downloaded font files are stored. The cache location can be customised with the GDTOOLS_CACHE_DIR environment variable or R option.

fonts_cache_dir() rm_fonts_cache() init_fonts_cache()
Manage Font Working Directory
dummy_setup()
Set up a temporary font cache

C library versions

Return the runtime version of the Cairo and FreeType libraries linked to the package.

version_freetype() version_cairo()
Version numbers of C libraries