Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1224028

    Hi,

    I found code from user ramotzkie to add to my child theme functions.php to add font-display to custom fonts:
    https://kriesi.at/support/topic/add-font-display-to-entypo-fontello-and-custom-fonts/

    
    add_filter('avf_font_display', function($swap) {
        return 'swap';
    }, 10, 1);
    add_filter('avf_google_fontlist', 'add_font_display');
    function add_font_display ($fonts) {
        return $fonts.='&display=swap';
    }

    This works well, but it also sets any additional fontello icons to: font-display: swap;
    but that should be (for icons): font-display: block;

    How can I achieve this? Thanks in advance for your help.

    Rob

    #1224151

    Hey Rob,

    In Enfold 4.7.5 you can set the options needed in the Theme options > Performance > Advanced options.
    Image 2020-06-19 at 21.36.15.png

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1224182

    Hi Victoria,

    Thanks, I had not seen that yet :-)

    However, it doesn’t solve my issue:
    I have 2 Google fonts and an extra fontello font served from local.
    If I set the option to swap for the two normal fonts, the fontello-extra (icons) also gets swap …

    How can I set the exception for the extra fontello icons so that gets block?

    Kind regards,
    Rob

    #1225167

    Hi Rob,

    I will forward this to our devs. This needs to be discussed further. Thank you for bringing this up.

    Best regards,
    Victoria

    #1225194

    Hi Victoria,

    Thanks, I will wait for their answer.

    Kind regards,
    Rob

    #1225248

    Hi Rob!

    Our devs got the solution to the issue.

    Here is the code you can put in your funtions.php

    
    function my_custom_font_display( $font_display, $font_name )
    {
    	//	Check for a font and change the default theme setting
    	if( 'entypo-fontello' == $font_name )
    	{
    		return 'block';
    	}
    	
    	return $font_display;
    }
    	
    add_filter( 'avf_font_display', 'my_custom_font_display', 10, 2 );
    

    If you need further assistance please let us know.

    Cheers!
    Victoria

    #1225578

    Hi Victoria & Devs,

    Thanks for this quick solution, works great.
    I know these settings are only responsible for a little speed improvement compared to images, but still, every little bit helps. And of course the icon fonts don’t have replacement fonts.

    2 questions:
    I have an additional entypo-fontello-extra font (with some additional icons) also served from local, but that still has :swap. How can I add that as well?
    And also, is this something that will be included in the theme interface with an update? That would allow users to select the icon fonts to set font-display:block on.

    Reason is over time the child theme functions.php is starting to look like a christmas tree with all the code changes added… :-))

    Kind regards,
    Rob

    #1225618

    Hi Rob,

    This option will not be added to the interface, as the filter exists to adjust it.

    Please try using this code instead:

    
    
    function my_custom_font_display( $font_display, $font_name )
    {
    	//	Check for a font and change the default theme setting
    	if( 'entypo-fontello' == $font_name || 'entypo-fontello-extra' == $font_name)
    	{
    		return 'block';
    	}
    	
    	return $font_display;
    }
    	
    add_filter( 'avf_font_display', 'my_custom_font_display', 10, 2 );
    

    Best regards,
    Victoria

    #1225636

    Hi Victoria,

    Thanks for the quick solution and answer, it works very well with the filter.
    Thanks to all, and you can close this issue.

    Kind regards,
    Rob

    #1225727

    Hi,

    Glad we could help you.

    Enjoy the theme and have a nice day.

    Best regards,
    Günter

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘entypo-fontello and custom fonts add font-display’ is closed to new replies.