-
AuthorPosts
-
April 17, 2018 at 1:47 pm #943098
Hello, I want to add different font weights of the font Open Sans.
I added the script below in the functions.php but it issn’t working.
Can you tell me why?add_filter( ‘avf_google_heading_font’, ‘avia_add_heading_font’);
function avia_add_heading_font($fonts)
{
$fonts[‘Open Sans 2’] = ‘Open+Sans:300,400,600,700,800&subset=latin,latin-ext’;
return $fonts;
}add_filter( ‘avf_google_content_font’, ‘avia_add_content_font’);
function avia_add_content_font($fonts)
{
$fonts[‘Open Sans 2’] = ‘Open+Sans:300,400,600,700,800&subset=latin,latin-ext’;
return $fonts;
}April 17, 2018 at 2:01 pm #943105Hello. You can add the following line to your CSS. However, if you actually need the fonts to be available from within a “picker”, I would just Google “Enfold google fonts”. There are tons of posts about it.
@import url(https://fonts.googleapis.com/css?family=Open+Sans:600,700, 800);
April 17, 2018 at 2:42 pm #943121and by the way – try it without that plus sign between font name:
(you don’t need the italic fonts ?)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,800&subset=latin-ext'; 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,800&subset=latin-ext'; return $fonts; }
April 17, 2018 at 2:50 pm #943128by the way – think of performance!
and if your are satisfied with only that font – maybe it is a good idea to load it localy from your servers !
https://www.smashingmagazine.com/2014/09/improving-smashing-magazine-performance-case-study/
Smashing Magazine did notice up to 700ms pagespeed on loading fonts localy!
Here is a liitle workaround with a small plugin to load google fonts local.:
https://kriesi.at/support/topic/disable-google-font-loading-via-google/
( maybe this is better for DSGVO – GDPR too ) no google servers at all in that case.April 17, 2018 at 3:04 pm #943132My only suggestion here is that this information should be centralized and simplified, via a checklist. Having people dig through Github and figure out how to get the plugin implemented is not going to be followed. Enfold users are either not on Github, have never heard of it, or simply won’t go there.
What I’d like to see\have is the ability to contribute to a document library or the existing document library. The more we can refer users to documentation, the more we can keep the boards clean for real support issues.
April 18, 2018 at 6:53 am #943437Hi,
Thanks for helping out @guenni007 and Ryan, much appreciated. Please let us know if you should need any further help on the topic @comceptum.
Best regards,
RikardApril 18, 2018 at 8:52 am #943493Hello Rikard, it’s not working yet. It’s like WP said, there are like a thousand topics about this subject but there is not a clear solution. Can you give me the best one so i can use this way in the future for all my projects. Best regards, Comceptum
April 18, 2018 at 3:58 pm #943647The code you have above ( and as i said erase the plus sign like in my code) is only to have on enfold options the possibility to set for body and for content text the font. The font added through this code can be found at the bottom of the list ( not sorted in alphabetical order )
Only if you set the code there the font will be activated.If you do not want to use the setting there – only to use with css and activated do this to functions.php of your child-theme:
(here the plus must be set as given from google font itself)add_action('wp_head', function() { ?> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800&subset=latin-ext" rel="stylesheet"> <?php });
April 19, 2018 at 4:29 am #943863Hi,
We have an article on this, and it’s as clear as it gets: http://kriesi.at/documentation/enfold/register-additional-google-fonts-for-theme-options/
If that is not what you are looking to do then maybe @guenni007 provided an alternative solution for you above?
Best regards,
RikardApril 19, 2018 at 11:36 am #944050Hi Rikard – the thing on this is not really clear in documentation.
The code provided by this link https://kriesi.at/documentation/enfold/register-additional-google-fonts-for-theme-options/
make the font only available for Enfold to choose for headings and content font –
the possiblity of choosing it does not activate it automatically. That would be a performance disaster for the page
So if you dont choose it as heading or content font in Enfold Options page – you can not use it via quick css!The code above activates the fonts – you can directly use it in quick css
add_action('wp_head', function() { ?> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800&subset=latin-ext" rel="stylesheet"> <?php });
- This reply was modified 6 years, 7 months ago by Guenni007.
April 20, 2018 at 6:08 am #944447Hi Günter,
That is correct yes, though most of our customers are the type which want to simply select the font from the list and not worry about anything else. That why the documentation is written this way I guess.
Best regards,
RikardApril 20, 2018 at 8:14 am #944483Yes, you are right, but many of the users run into this misunderstanding here. Then the topics are: “why can i not use the added font for my icon-titles via quick css …” etc. pp.
the quick and dirty solution is to go to advanced styling and set for example for a H6 the added font as font-family – this will activate the font as well.April 21, 2018 at 7:09 am #944810 -
AuthorPosts
- You must be logged in to reply to this topic.