-
AuthorPosts
-
August 3, 2018 at 9:31 pm #993357
Hi,
I want to add in 400 and 600 font weights for open sans to enfold. I know I can just do an @import in my CSS file and have them but im trying to avoid loading Google Fonts two times. Doing that way loads once for 300 and 700 (what enfold comes with) and then loads again for the ones I added 400 and 600.
This is bring my score down in GT Metrix.
Hoping you have a function i can load that will add in the 400 and 600 to the code enfold is calling to grab those fonts.
Thanks
August 5, 2018 at 4:05 pm #993700Hey acscreativenew,
Try adding this code to the end of your functions.php file in Appearance > Editor:add_filter( 'avf_google_heading_font', 'avia_add_heading_font'); function avia_add_heading_font($fonts) { $fonts['Open Sans'] = 'Open Sans:300,400,600,700'; return $fonts; } add_filter( 'avf_google_content_font', 'avia_add_content_font'); function avia_add_content_font($fonts) { $fonts['Open Sans'] = 'Open Sans:300,400,600,700'; return $fonts; }
Best regards,
MikeAugust 6, 2018 at 8:50 pm #994082Mike,
I added this to my functions file and it does not seem to load the extra fonts. Now the site is just loading the 400 and the 600 weights like it does by default.
Does this add it in so I can use it everywhere can call it out via CSS?
Thanks
-DanAugust 7, 2018 at 8:02 pm #994548Hi,
The goal was to register the additional font weights, I tested this on my local by adding the code to my functions.php and then going to Enfold Theme Options > Advanced Styling where I set “All Headings (H1-H6)” to “Open Sans”, font weight “bold”
Then I checked a heading on my frontpage, which has the font-weight “700”Which element are you trying to add the font weight to?
Please ensure you have cleared your page cache.Best regards,
MikeAugust 7, 2018 at 8:42 pm #994559Hi,
Im not necessarily trying to add it to any element. I just wanted it loaded so I can call it out in the CSS.
I can load them just fine if i do a @import in the CCS file but i was hoping there was a way to append them to whats already being loading by enfold so the theme does not have to load google fonts two times one for the 400 and 600 and another for the 300 and 700. Its brining my score down in GTMetrix.
Thanks
-DanAugust 7, 2018 at 9:26 pm #994576Hi,
Yes I understand, if you follow the same steps I did above do you get the same result?
Another option is to try adding the font weight in directly at: enfold\framework\php\font-management\class-avia-type-fonts.php
on line 726, look for:'Open Sans' => 'Open Sans:400,600',
and change to:
'Open Sans' => 'Open Sans:300,400,600,700',
Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.