• Resolved Guillaume G.

    (@g4ll4is)


    Hi,

    I’d like to replace the default Google font by another one.

    Is there any way to do this properly when using a child theme ?

    The jgtstork_font_url() function that gets the font url doesn’t seem pluggable, and I don’t know how to replace it.

    function jgtstork_font_url() {
    	$font_url = add_query_arg( 'family', urlencode( 'Karla:400,400i,700,700i' ), "https://fonts.googleapis.com/css" );
    	return $font_url;
    }

    (from functions.php, line 104)

    Thanks for making Stork,
    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author justgoodthemes

    (@justgoodthemes)

    Hi there,

    I will make the fonts function pluggable in the next theme update. For now you could dequeue parent theme’s fonts stylesheet:

    function jgtstork_child_remove_parent_fonts() {
    	wp_dequeue_style( 'jgtstork-fonts' );
    	wp_deregister_style( 'jgtstork-fonts' );
    }
    add_action( 'wp_enqueue_scripts', 'jgtstork_child_remove_parent_fonts', 20 );

    Then enqueue your desired Google fonts:

    function jgtstork_child_font_styles() {
    	wp_enqueue_style( 'jgtstork-child-fonts', jgtstork_child_font_url(), array(), null );
    }
    add_action( 'wp_enqueue_scripts', 'jgtstork_child_font_styles' );
    
    function jgtstork_child_font_url() {
    	$font_url = add_query_arg( 'family', urlencode( 'Droid Serif:400,400i,700,700i' ), "https://fonts.googleapis.com/css" );
    	return $font_url;
    }

    Hope this helps.

    Regards,
    Asta

    Thread Starter Guillaume G.

    (@g4ll4is)

    Thanks for the quick reply ! It did help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Replace default font when using a child theme’ is closed to new replies.