Working with Fonts
Plugins can use typefaces available in the Font Picker to get information about specific fonts or to apply them to Text Styles.
To list all available fonts, use the following code.
Unlike the Font Picker, which groups fonts by typeface, getFonts
will list individual fonts for each weight and style. You can think these as separate font files.
To get a specific font from a family, use getFont
and pass in the family name. This is not case sensitive.
By default, this will return a font in the family that has a normal weight and style.
You can specify a desired weight
or style
by passing in optional attributes.
Make sure to check that a font exists before using it. If a font does not exist, getFont
will return null
.
This may happen if the typeface is not available in Framer or if it lacks a certain weight and style combination.
Note: Custom fonts are not available to plugins.