Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #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;
    }

    #943105

    Hello. 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);

    #943121

    and 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;
    }
    #943128

    by 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.

    #943132

    My 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.

    #943437

    Hi,

    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,
    Rikard

    #943493

    Hello 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

    #943647

    The 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
    });
    #943863

    Hi,

    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,
    Rikard

    #944050

    Hi 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.
    #944447

    Hi 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,
    Rikard

    #944483

    Yes, 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.

    #944810

    Hi Günter,

    That might be so yes, but I think that is more a lack of understanding of how importing fonts actually works.

    Best regards,
    Rikard

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.