Search Docs
Loading...
Skip to content

Function: createVariableFontCombinations

function createVariableFontCombinations(
uri,
variantWeight,
variantItalic): Font[];

Generates an array of Font entries for a variable font file.

Variable fonts pack multiple weight/style variants into a single file. This helper builds every combination of weight and style that the font supports so you can pass the result straight into a Typeface.

Parameters#

ParameterTypeDescription
uristringThe URI of the variable font file.
variantWeightbooleanWhen true, generates entries for all nine standard weights (Thin through Heavy). When false, only Normal (400) is used.
variantItalicbooleanWhen true, generates italic variants in addition to normal style variants. When false, only normal style is used.

Returns#

Font[]

An array of Font objects covering every requested combination.

Example#

const fonts = createVariableFontCombinations(
'https://example.com/font.woff2',
true, // weight variants
true // italic variants
);
// → 18 entries: 9 weights × 2 styles
engine.block.setTypeface(block, {
name: 'My Variable Font',
fonts
});