Okay
  Public Ticket #2052089
Adding custom fonts using @font-face
Closed

Comments

  • s1980 started the conversation

    I followed the instructions on https://themenectar.ticksy.com/article/9773/ to addd custom @font-face fonts to my site.

    The problem I am finding is when the site renders the css it ads the font in like this 

    h1 {font-family:  "IndustryIncW00-Base ";  } 
    
    note - reference the screen shots, it turns the " into & quot ; (the hex for ") 

    The code in my functions.php is as follows

    function salient_redux_custom_fonts( $custom_fonts ) {
        return array(
            'Custom Fonts' => array(
                 'IndustryIncW00-Base' => "IndustryIncW00-Base"
            )
        );
    }
    add_filter( "redux/salient_redux/field/typography/custom_fonts", "salient_redux_custom_fonts" );
    
  •  3,023
    Andrew replied

    Hi there,

    That article has not been update in a while and might not fully work.
    If you are trying to add a custom font you can instead use a plugin specific for that or use the @font-face method to add the font to the pages then target the specific areas you want to change the font to the  one you imported all with custom CSS.

    Am referring to the manual method shown here - https://www.wpbeginner.com/wp-themes/how-to-add-custom-fonts-in-wordpress/

    Try that.
    Cheers. 

  • reganmcgregor replied

    Hi There,


    Currently I'm working on a project and my design calls for a custom font. I have added in my custom font using the "salient_redux_custom_fonts" function. This works well however has a one issue.

    The font I use has multiple weights, however, the Salient Options Panel only provides Normal 400, Bold 700, Normal 400 Italic and Bold 700 Italic. Unfortunately, for example the design uses Black 900 for main titles and 100 thin for somethings as well. So far I just use Custom CSS to override these, but, I would prefer it be done at the theme level to save outputting extra code for no reason.

    I was wondering if I could could provide the extra font weights using the function somehow or if you would consider adding the ability in a later release.

    Here is my code for reference:


    function salient_redux_custom_fonts( $custom_fonts ) { return array( 'Custom Fonts' => array( 'Font Name, Helvetica, Arial, sans-serif' => "Font Name" ) );
    }
    add_filter( "redux/salient_redux/field/typography/custom_fonts", "salient_redux_custom_fonts" );


    I tried to use the plugin "Use Any Font" and no luck, not to mention it seems pretty untrustworthy and slow. I would prefer to stick to this method and make a slight adjustment to my code.



    Thanks,
    Regan

  •  8,992
    Tahir replied

    @reganmcgregor, 

    Unfortunately there is no such option available at the moment. Best would be to use the Any Font Plugin .

    Best


    ThemeNectar Support Team