How To Use Custom Font

The fonts on our themes are pulled from google fonts. In older themes we just enqueued them like this in your functions.php:


The url that you see with fonts is the same one that you get from google fonts. This is one way of using them in our themes. The second way of adding them is by adding this piece of code in your functions.php

 * Google Fonts URL function
 * Enqueues the google font that the site will use
 * @since       1.0.0
if ( ! function_exists( 'theme_name_fonts_url' ) ){
    function theme_name_fonts_url() {
        $fonts_url = '';
        // Translators: If there are characters in your language that are not supported by Google font, translate it to 'off'. Do not translate into your own language.
        $catamaran = _x( 'on', 'Roboto Text font: on or off', 'theme_name' );

        if ( 'off' !== $catamaran ) {
            $font_families = array();

            if ( 'off' !== $catamaran ) {
                $font_families[] = 'Roboto:400,300,700';

            $query_args = array(
                'family' => urlencode( implode( '|', $font_families ) ),
                'subset' => urlencode( 'latin' ),

            $fonts_url = add_query_arg( $query_args, '//' );

        return esc_url_raw( $fonts_url );

Or you can try to install¬†Easy Google Fonts plugin. This plugin hasn’t been tested with our themes, so use it on your own risk.

Next article