themeum / kirki

Extending the customizer
https://kirki.org
MIT License
1.26k stars 328 forks source link

Fonts are not properly loaded #2475

Open DeoThemes opened 2 years ago

DeoThemes commented 2 years ago

Issue description:

I'm having difficulties loading fonts properly. Every time, it's either loading a different weight or a different family. For example: in customizer, I select Montserrat 700 for buttons, but on the front-end I'm getting only font-weight property.

_220406075037 _220406074310

Version used:

4.0.23

Code to reproduce the issue (config + field(s))


$heading_font = 'Montserrat';

// Buttons typography
Kirki::add_field( 'nokke_settings_config', array(
    'type'        => 'typography',
    'settings'    => 'nokke_settings_buttons_typography',
    'label'       => esc_html__( 'Buttons', 'nokke' ),
    'section'     => 'nokke_settings_typography',
    'default'     => array(
        'font-family'    => $heading_font,
        'variant'        => '700',
        'letter-spacing' => 'normal',
        'text-transform' => 'none'
    ),
    'choices'  => nokke_add_custom_choice(),
    'output' => array(
        array(
            'element' => $selectors['buttons'],
        ),
        array(
            'element' => '.wp-block-button .wp-block-button__link',
            'context' => array( 'editor' ),         
        )
    ),
    'transport' => 'auto',
));
DeoThemes commented 2 years ago

Is there any update on this? There is also an issue with the Outfit font, it's simply not loading and the folder outfit in the fonts directory does not exist.

mapsteps commented 2 years ago

Hi @DeoThemes,

can you share the nokke_add_custom_choice() with me?

Thanks.

mapsteps commented 2 years ago

Also, what's in your nokke_settings_config?

DeoThemes commented 2 years ago

Config:

Kirki::add_config( 'nokke_settings_config', array(
    'capability'    => 'edit_theme_options',
    'option_type'   => 'theme_mod',
    'option_name'   => 'nokke_settings_config'
) );

This is used as a filter to add custom fonts from Adobe Typekit:

function nokke_add_custom_choice() {
    return array(
        'fonts' => apply_filters( 'nokke_kirki_font_choices', array() ),
        'variant' => array( 'regular', 'italic' )
    );
}