-
AuthorPosts
-
June 19, 2020 at 11:55 am #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
June 19, 2020 at 8:37 pm #1224151June 19, 2020 at 11:28 pm #1224182Hi 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,
RobJune 24, 2020 at 12:54 pm #1225167Hi Rob,
I will forward this to our devs. This needs to be discussed further. Thank you for bringing this up.
Best regards,
VictoriaJune 24, 2020 at 1:50 pm #1225194Hi Victoria,
Thanks, I will wait for their answer.
Kind regards,
RobJune 24, 2020 at 3:18 pm #1225248Hi 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!
VictoriaJune 25, 2020 at 4:31 pm #1225578Hi 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,
RobJune 25, 2020 at 5:25 pm #1225618Hi 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,
VictoriaJune 25, 2020 at 6:26 pm #1225636Hi 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,
RobJune 26, 2020 at 6:49 am #1225727 -
AuthorPosts
- The topic ‘entypo-fontello and custom fonts add font-display’ is closed to new replies.