Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #948671

    Hi,

    due to the current privacy policy issue I am forced to disable Google Fonts and loading them from my own server instead. I searched the Enfold forum and found out to use this code in functions.php:

    add_action( 'init', 'enfold_customization_switch_fonts' );
    function enfold_customization_switch_fonts() {
        global $avia;
        $avia->style->print_extra_output = false;
    }
    

    In addition to that I added the following code for fonts (among others) to the style.css in my Child theme:

    /* chelsea-market-regular - latin */
    @font-face {
      font-family: 'Chelsea Market';
      font-style: normal;
      font-weight: 400;
      src: url('../fonts/chelsea-market-v5-latin-regular.eot'); /* IE9 Compat Modes */
      src: local('Chelsea Market'), local('ChelseaMarket-Regular'),
           url('../fonts/chelsea-market-v5-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('../fonts/chelsea-market-v5-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
           url('../fonts/chelsea-market-v5-latin-regular.woff') format('woff'), /* Modern Browsers */
           url('../fonts/chelsea-market-v5-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
           url('../fonts/chelsea-market-v5-latin-regular.svg#ChelseaMarket') format('svg'); /* Legacy iOS */
    }
    

    and created a new folder named „fonts“ in Child theme and put the corresponding fonts in it.

    In Settings > General Settings > Fonts I chose my favored font for heading and body text; in advanced settings > Slideshow titles I chose my favored font as well.

    Until now I added the following code in functions to use the Google Fonts, but now I removed this code:

    add_filter( 'avf_google_heading_font', 'avia_add_heading_font');
    function avia_add_heading_font($fonts)
    {
    $fonts['Chelsea Market'] = 'Chelsea Market';
    $fonts['Amatic SC'] = 'Amatic SC:400,700';
    return $fonts;
    }
    
    add_filter( 'avf_google_content_font', 'avia_add_content_font');
    function avia_add_content_font($fonts)
    {
    $fonts['Chelsea Market'] = 'Chelsea Market';
    $fonts['Amatic SC'] = 'Amatic SC:400,700';
    return $fonts;
    }
    

    But it is not working somehow. Any idea how to prevent my website loading Google fonts from Google server and loading Google fonts from my own server instead?

    Thank you for your kind help in advance.

    Kind regards,
    Sophie

    #948688

    first- have a look here.
    i put the infos and a short plugin together: https://kriesi.at/support/topic/disable-google-font-loading-via-google/
    You can downlaod a whole zip file with all fonts included in Enfold https://webers-testseite.de/local-google-fonts.zip – or you visit https://google-webfonts-helper.herokuapp.com/fonts to get your font you like

    you don’t need that plugin – but it makes things easier to handle

    #949122

    Hi Guenni007,

    thank you for your message. I already found this topic with your link https://kriesi.at/support/topic/disable-google-font-loading-via-google/, but I found this not helpful for me since I do not want to use another plugin (having the privacy policy in mind). Also, my a/m solution is supposed to work. Any idea?

    Thank you for all your kind help in advance.

    Kind regards,
    Sophie

    #949166

    @Guenni007: thanks a lot!!!

    #949239

    if you look into that plugin ( it is only the thing on that link google fonts helper) you will see that it is only an activation of the fonts.
    But i think it makes it a bit more clearer what happend – the content of that plugin will look like this:

    function local_google_fonts() {
    	wp_enqueue_style( 'chelsea-fonts', plugin_dir_url( __FILE__ ) . 'assets/css/chelsea.css' );
    }
    add_action( 'wp_enqueue_scripts', 'local_google_fonts' );
    ?>

    this is the chelsea.css what you got on the helper site:

    /* chelsea-market-regular - latin */
    @font-face {
      font-family: 'Chelsea Market';
      font-style: normal;
      font-weight: 400;
      src: url('../fonts/chelsea-market-v5-latin-regular.eot'); /* IE9 Compat Modes */
      src: local('Chelsea Market'), local('ChelseaMarket-Regular'),
           url('../fonts/chelsea-market-v5-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('../fonts/chelsea-market-v5-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
           url('../fonts/chelsea-market-v5-latin-regular.woff') format('woff'), /* Modern Browsers */
           url('../fonts/chelsea-market-v5-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
           url('../fonts/chelsea-market-v5-latin-regular.svg#ChelseaMarket') format('svg'); /* Legacy iOS */
    }

    the only thing now is to locate the correct relative path!
    if you are not shure if that was the correct path to it use first the absolute path ( https:// url /wp-content/themes/enfold-child/fonts) – you know what i mean.
    the ../fonts/ on your css code means that from the css it is one level higher in the fonts folder.
    if you did that into child-themes/style.css the fonts-folder has to be a level higher.
    but i think that your folder structure is more like

    /* chelsea-market-regular - latin */
    @font-face {
      font-family: 'Chelsea Market';
      font-style: normal;
      font-weight: 400;
      src: url('/fonts/chelsea-market-v5-latin-regular.eot'); /* IE9 Compat Modes */
      src: local('Chelsea Market'), local('ChelseaMarket-Regular'),
           url('/fonts/chelsea-market-v5-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('/fonts/chelsea-market-v5-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
           url('/fonts/chelsea-market-v5-latin-regular.woff') format('woff'), /* Modern Browsers */
           url('/fonts/chelsea-market-v5-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
           url('/fonts/chelsea-market-v5-latin-regular.svg#ChelseaMarket') format('svg'); /* Legacy iOS */
    }

    that means your folder fonts is on the same level as your style.css in which the css from above is integrated

    #949241

    so you see that on my folder structure of that plugin will be in that way the css is generated on that helper-page from groogle.
    the css code comes to the css folder as f.e. chelsea.css the fonts itself comes to the fonts-folder.
    so than the relative path is as yours: ../fonts/

    so if you don’t like to use that little plugin i would preserve the structure of the page above
    1) make (as you did it) a fonts folder on child-themes folder
    2) and make a folder css.
    3) name that whole @import-rule like your fonts name f.e. chelsea.css
    4) include the css via your functions.php of your child theme by:

    function local_google_fonts() {
      wp_enqueue_style( 'chelsea-fonts', get_stylesheet_directory_uri().'/css/chelsea.css' );
    }
    add_action( 'wp_enqueue_scripts', 'local_google_fonts' );
    ?>

    5) Every added Font like this you can do it by semicolon separated line wp_enqueue_style
    6) Now everything should work
    7) you can add those fonts via that shortcode as body and content font – but they were loaded from local place now because of:

    add_action( 'init', 'enfold_customization_switch_fonts' );
    function enfold_customization_switch_fonts() {
        global $avia;
        $avia->style->print_extra_output = false;
    }
    #949368

    Hi,

    Thanks for helping out @guenni007, much appreciated :-)

    Best regards,
    Rikard

    #950059

    Hi Guenni007,
    sorry to say but there is one big problem left – if my observation is right:
    – If you install the plugin with all its subfolders the right way
    AND
    – all path strings in the .css files are correct
    AND
    – all fonts are placed in the right directories
    THEN
    everything seems to be fine and the site pulls the fonts from local dirs.
    (At this point I’m not sure but as far as I can see the site doesn’t connect to fonts.gstatic.com)

    BUT if there is any mistake made – folder missing, wrong path, font file missing – all fonts will still be loaded from fonts.gstatic.com … no error message, no fall back to browser standard fonts …
    I think we should hint at this …
    Maybe the best way would be to have an option in Enfold prefs to choose between loading fonts from local server (and specify a path) OR loading from Google …

    But anyway, as I already mentioned above: thanks again for your efforts!

    #950338

    Hi Guenni007,
    Hi LarryLayouter,
    Hi Enfold team,

    same with me. I did it as per Guenni007’s manual and still there is a connection to fonts.gstatic.com. I think there really should be an easier way to disable the Google Fonts via Enfold options like LarryLayouter noted.

    Any solution on how to solve this? Really appreciate all your efforts and help. Thank you.

    Kind regards,
    Sophie

    #950635

    Dear Sophie,
    how do you check if there really exists a connect to fonts.gstatic.com?
    I’m asking because I would like to review my workflow.
    I take 2 ways to monitor the website:
    1. developer tools of Firefox and Chrome > Network > Fonts (with cache disabled)
    Result: Font host = local server
    2. Firefox extension Lightbeam (older version 1.3.2)
    Result: the graph view shows fonts.googleapis.com as third party site …
    So I’m sure if there is a connect or not …

    How do you check it out? Can you recommend other tools (I’m working on a Mac)?
    Maybe a member of the Enfold team takes part in the discussion and suggest tools?

    Best
    LL

    #951584

    Hi,

    Thanks for your input! We will include custom font uploader to the theme soon so you will be able to serve fonts from your own server. Currently it is being tested and improved.

    Best regards,
    Yigit

    #951586

    @Yigit: sounds great – thanks a lot!

    #951944

    Hi,

    Glad we could help!
    Please take a moment to review our theme and show your support https://themeforest.net/downloads
    To know more about enfold features please check – http://kriesi.at/documentation/enfold/
    Thank you for using Enfold :)

    Best regards,
    Basilis

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Disabling Google Fonts and loading them from own server instead’ is closed to new replies.