Can I share predefined fonts from theme_support with a gutenberg component?

I have a few fonts defined in my functions.php:

        add_theme_support('editor-font-sizes', array(
            array(
                'name' => esc_attr__('Small', 'moderna'),
                'size' => 13,
                'slug' => 'small'
            ),
            ......
            array(
                'name' => esc_attr__('Headline', 'moderna'),
                'size' => 40,
                'slug' => 'headline'
            )
        ));

I want to use these defined fonts now in a FontSizePicker Component from Gutenberg. However I do not want to define these two times. Is there any way to get these fonts from php to the wordpress block?

<InspectorControls>
  <FontSizePicker
    fontSizes={GET_FONTS_FROM_THEME_SUPPORT()}
    value={26}
    fallbackFontSize={12}
    onChange={(newFontSize) => console.log(newFontSize)}
    withSlider
  />
</InspectorControls>;

0

Leave a Comment