Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

register_variant

Register a font as a variant as an existing one


Description

This function is a wrapper around register_font() that allows you to easily create variants of existing system fonts, e.g. to target different weights and/or widths, or for attaching OpenType features to a font.

Usage

register_variant(
  name,
  family,
  weight = NULL,
  width = NULL,
  features = font_feature()
)

Arguments

name

The new family name the variant should respond to

family

The name of an existing font family that this is a variant of

weight

One or two of "thin", "ultralight", "light", "normal", "medium", "semibold", "bold", "ultrabold", or "heavy". If one is given it sets the weight for the whole variant. If two is given the first one defines the plain weight and the second the bold weight. If NULL then the variants of the given family closest to "normal" and "bold" will be chosen.

width

One of "ultracondensed", "extracondensed", "condensed", "semicondensed", "normal", "semiexpanded", "expanded", "extraexpanded", or "ultraexpanded" giving the width of the variant. If NULL then the width closest to "normal" will be chosen.

features

A font_feature object describing the specific OpenType font features to turn on for the registered font variant.

Examples

# Get the default "sans" family
sans <- match_font("sans")$path
sans <- system_fonts()$family[system_fonts()$path == sans][1]

# Register a variant of it:
register_variant(
  "sans_ligature", 
  sans, 
  features = font_feature(ligatures = "discretionary")
)

registry_fonts()

# clean up
clear_registry()

systemfonts

System Native Font Finding

v1.0.2
MIT + file LICENSE
Authors
Thomas Lin Pedersen [aut, cre] (<https://orcid.org/0000-0002-5147-4711>), Jeroen Ooms [aut] (<https://orcid.org/0000-0002-4035-0289>), Devon Govett [aut] (Author of font-manager), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.