• Hi there,

    I’d like to change a font set for a whole theme, entirely. Someone pointed me at Easy Google Fonts plugin but I’m not very enthusiastic about the idea.

    I could still get along with changing fonts in the CSS rule sets but to link them from outside – I cannot make my mind how to do thta (PHP is not my favourite subject absolutely). Where are all these <link>s and @import’s in .php-files? I don’t see them.

    The developer of the theme has offered to buy a premium version. Ha-ha!

    Thank you all, you are my last straw! ??

    P.S. I suppose it’s a generic question so that wasn’t a mistake to post it here?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m not sure I fully understand your question.

    So, let me start with the topic of Google Fonts. Google Fonts are available HERE. Click on any font, click the plus sign, and then open the tab at the bottom. Google’s preferred method of using their fonts is for you to link to them externally. Easy Google Fonts most likely just creates those links for you. You could look for the links in your theme’s ‘functions.php’ file, or as @imports in your style.css. Or more likely, they’re buried in a file inside the Easy Google Fonts plugin. You should see them if you do a view-source:<url> on your page (where <url> is your page’s url without the angle brackets.)

    Instead of using Easy Google Fonts, you could download the fonts into your theme.
    However:
    1) If your user doesn’t have the font installed on their device, then they’ll have to download the font from Google, if it’s a <link> or @import, or from your web server if you’ve downloaded rather than linked to it. Google’s servers are most likely faster.

    2) Your localized fonts won’t get updated. Google suggests using SkyFont Manager to manage your localized fonts. This keeps your local, downloaded copy, up-to-date by downloading updated fonts as they’re updated. Unless you’re running your own web server, or are renting a dedicated server, you won’t be able to install the SkyFont manager on the webserver.

    Thread Starter ecoduma

    (@ecoduma)

    Thank you.

    From my point of view there is a complete medley with fonts used in a theme – Google Fonts, Font Awesome, plugins installed have their own reservations.

    The theme I am talking about is not localised, so instead of some fonts for which other subsets except Latin don’t exist browsers fall back to generic ones and that’s also not OK.

    I’ve just wanted to bring an order to the code and layout, reduce a number of fonts used, substitute some fonts…

    Of course, first of all I went to view page sources of the site but the thing you know is that pages are generated by a server and the resulting code of pages is just nonexistent. And the problem (for me) is that I don’t know where from all those strokes of code come.

    So as for me it’s a challenge to find all that links littered all around the theme, remove them and substitute for the new ones that I want to. And again as for me in this case editing of style.css file is the least obstacle in the way.

    For your purpose, you should create a child theme.
    Look in the parent theme for enqueue_script or enqueue_style and if you don’t find it, try register_style. If the theme has a filter on the font name, it is easier. You would add_filter() for the name in your child theme.
    But most do not, so you would need to dequeue the original with wp_dequeue_style().
    https://developer.www.ads-software.com/reference/functions/wp_dequeue_style/
    You can copy the parent code into your child theme, and enqueue the font you prefer.
    That is just to get the correct font loaded. You still have to change the CSS in the theme to use the new font name. Those styles should be in your child theme. It would be easier if you could load a different font using the original name used in the CSS, but if it is Google Fonts, you don’t have that option.

    Font Awesome is just for icons.

    Thread Starter ecoduma

    (@ecoduma)

    Thank you. I forsee it won’t be easy. In any case I’ll give a try and then tell if something goes wrong.
    It also would be nice if you point out what files I should look up exactly, just to narrow my task a bit.

    BTW, there is already a child theme but it has only slightest modifications as far as I have been able to comprehend it for the moment.

    It also would be nice if you point out what files I should look up exactly

    But then you wouldn’t learn anything! Actually, the theme can organize its files any way it wants, so I can’t really say what file or folder it will be in.

    Thread Starter ecoduma

    (@ecoduma)

    Thank you.
    I tried to look into details yesterday. Yes, all ‘enqueue_style’s are in the theme’s functions.php file. I think as they say me what fonts they’ve chosen I’ll be able to rewrite them.

    On the other hand, if there is a need some time in the future to update a theme the functions.php will also be updated and all changes will be defaulted, right?

    Wouldn’t it be better to place new fonts into a child theme’s style.css via @import? Will that repeal functions.php’s rules regarding font sets used?

    I love to learn but you know: ‘Work done, have your fun’.

    I’m not sure what you are saying.
    Now that you have found where the current fonts are loaded in the parent theme, you know which to dequeue in the child. Then load the ones you want in the child. Using @import is okay, but especially for a Google Font, it’s easier to enqueue it.
    And then add your styles using the new font name.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to change set of fonts for a whole theme?’ is closed to new replies.