Load Google fonts with latin-ext

Hi,

I need load google fonts with latin extended subset. I made quick hack to core file class-fl-theme.php. Is there any right way how to do it?

Thanks
Marek

	/**
	 * Renders the <link> tag for all fonts in the $fonts array.
	 *
	 * @since 1.0
	 * @return void
	 */
	static public function render_fonts()
	{
		foreach(self::$fonts as $font) {
			if(!empty($font['url'])) {
				echo '<link rel="stylesheet" href="'. $font['url'] . ':'. implode(',', $font['variants']) .'&subset=latin,latin-ext" />' . "\n";
			}
		}
	}

Hey Marek,

Welcome to the BB forums! :slight_smile:

I don’t think doing it that way will do since it will get overwritten when you update the theme. I’ve already assigned another member of the team to assist you with your concern.

Ben

Thanks for help,

I know, its just temporary solution

Hey Marek,

I think the easiest solution would be for us to add a filter. Go ahead and change that function to this…

static public function render_fonts()
{
    foreach(self::$fonts as $name => $font) {
        if(!empty($font['url'])) {
            $subset = apply_filters( 'fl_font_subset', '', $name );
            echo '<link rel="stylesheet" href="'. $font['url'] . ':'. implode(',', $font['variants']) . $subset .'" />' . "\n";
        }
    }
}

and then add this filter to your functions.php file…

function my_font_subset( $subset, $name )
{
    if ( $name == 'Acme' ) {
        $subset = '&subset=latin,latin-ext';
    }
    
    return $subset;
}

add_filter( 'fl_font_subset', 'my_font_subset', 10, 2 );

You’ll need to change $name == ‘Acme’ to the name of your font. I’ll go ahead and get that filter in the next release.

Justin

Thanks,

works like a charm!

Marek

You’re welcome!

Justin