• dgywft

    (@dgywft)


    I am using the newer WordPress 6 site editor, and working with the George Lois 1.0 theme. But I have tried multiple ways to add my own web fonts into the functions file, but i cannot get them to show in the site editor in the fonts drop downs options. Does anyone have any experience with getting your own fonts to show in the site editor design options for typefaces? example of my functions I have added, that do not work:


    if ( ! function_exists( 'georgelois_custom_fonts' ) ) :
    function georgelois_custom_fonts() {
    wp_enqueue_style(
    'georgelois-custom-fonts',
    'https://www.example.com/explore/wp-content/themes/fonts/ywft-webfonts.css',
    array(),
    null
    );
    }
    endif;
    add_action( 'wp_enqueue_scripts', 'georgelois_custom_fonts' );
    
    if ( ! function_exists( 'georgelois_editor_custom_fonts' ) ) :
    function georgelois_editor_custom_fonts() {
    
        add_theme_support( 'editor-font-sizes', array(
            array(
                'name' => 'Valid Regular',
                'size' => 20,
                'slug' => 'valid-regular'
            ),
            array(
                'name' => 'Valid Bold',
                'size' => 20,
                'slug' => 'valid-bold'
            ),
            array(
                'name' => 'YWFT Morchin Regular',
                'size' => 20,
                'slug' => 'ywft-morchin-regular'
            ),
            array(
                'name' => 'YWFT Matter Medium',
                'size' => 20,
                'slug' => 'ywft-matter-medium'
            )
        ) );
    
    }
    
    endif
    
    add_action( 'after_setup_theme', 'georgelois_editor_custom_fonts' );
    
    add_action( 'after_setup_theme', function() {
    if ( ! function_exists( 'wp_register_webfonts' ) ) {
    return;
    }
    wp_register_webfonts(
    array(
    array(
    'font-family' => 'Valid-Regular',
    'font-weight' => '400', // Regular weight.
    'font-style' => 'normal',
    'font-stretch' => 'normal',
    'src' => 'https://www.example.com/explore/wp-content/themes/fonts/valid-regular.woff2'
    ),
    array(
    'font-family' => 'Valid-Bold',
    'font-weight' => '700', // Bold weight.
    'font-style' => 'normal',
    'font-stretch' => 'normal',
    'src' => 'https://www.example.com/explore/wp-content/themes/fonts/valid-bold.woff2'
    ),
    array(
    'font-family' => 'YWFTMorchin-Regular',
    'font-weight' => '400', // Assuming regular weight.
    'font-style' => 'normal',
    'font-stretch' => 'normal',
    'src' => 'https://www.example.com/explore/wp-content/themes/fonts/ywft-morchin-regular.woff2'
    ),
    array(
    'font-family' => 'YWFTMatter-Medium',
    'font-weight' => '500', // Medium weight.
    'font-style' => 'normal',
    'font-stretch' => 'normal',
    'src' => 'https://www.example.com/explore/wp-content/themes/fonts/ywft-matter.woff2'
    )
    )
    );
    });
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Web Fonts?’ is closed to new replies.