• Resolved Zougou

    (@zougou)


    Hi,

    I’m using only one font (Montserrat), and I’d like to avoid loading all font-weight styles for this font (100,200…900 + italics versions).
    I already disable italics fonts loading with this custom hook :

    add_filter( 'ocean_google_font_enqueue_italics', '__return_false');

    It’s working fine.
    Now i’d like to load only 300,400,500 and 600 font-weight.
    Is it possible ?

    Thanks for your help

    • This topic was modified 3 years, 10 months ago by Zougou.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    For the wight filter, You can try this filter to achieve it – ocean_google_font_enqueue_weights

    • This reply was modified 3 years, 9 months ago by Abhishek.
    Thread Starter Zougou

    (@zougou)

    Hi,
    Thanks for the tip.
    Unfortunately, this filter removes absolutely all font-weights.
    And I just want to avoid loading 200, 700 , 800 and 900

    (I’d like to keep 100, 300, 400, 500 and 600 font-weight)

    Someone got an idea ?

    Hello,

    Please try to add the below code in the functions.php file of your child theme and check.

    add_filter( 'ocean_google_font_enqueue_weights', 'oceanwp_child_font_weight', 10, 2 );
    function oceanwp_child_font_weight($weights, $font){
        $weights = array('600', '700');
        return $weights;
    }
    
    Thread Starter Zougou

    (@zougou)

    Awesome, that works !
    Thanks a lot Abhishek ??

    You are most welcome and glad to hear that issue has been fixed ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Google Font : How to Avoid loading all font-weight’ is closed to new replies.