[MOOVE THEME] ŷHow Do I Load Theme Fonts Locally?

[MOOVE THEME] ŷHow Do I Load Theme Fonts Locally?

by John Kalla -
Number of replies: 16

Moodle 3.5.2+

Moove 2018090200

Our site is on an internal network that doesn't connect to the Internet.  Is it possible to load the theme (and moodle) fonts locally?  I know moove uses Poppins, at least. 

I wasn't sure where the CSS is that loads the google fonts.

(Edited by Mary Evans - added theme name to title of  original submission Tuesday, 6 November 2018, 8:40 PM)

Average of ratings: -
In reply to John Kalla

Re: How Do I Load Theme Fonts Locally?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
In reply to Gareth J Barnard

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

Yup. So I've already tried that, but loading the CSS into "Additional HTML" doesn't seem to work, and I can't seem to find the CSS files for the Moove theme or for the site that mention calling the Google Fonts.  I really need to stop Moodle from looking for Google Fonts every time a page loads.

In reply to John Kalla

Re: How Do I Load Theme Fonts Locally?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok, start by reading 'docs.moodle.org/dev/Themes_overview', create a custom CSS file in a new styles folder and add that to the config.php file.  Then look on 'www.fontsquirrel.com' for free similar fonts.  Then follow the previous instructions.  Then look in the code of the Moove theme for the CDN links and remove them.

Average of ratings: Useful (1)
In reply to John Kalla

Re: How Do I Load Theme Fonts Locally?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

HI,

You don't need to add fonts to Moodle as it carries it's own fonts in moodle/lib/fonts, unless of cours if you need to add more.

You can add your bunch of Google fonts as describe by Gareth.

Adding CSS in a <style> </style> tag in the HEAD part of Additional HTML should work OK.

May I ask if you would share a part of, or indeed the whole of the CSS you had problems with, as it may be it was coded wrongly for the theme you are using?

Cheers

Mary


Average of ratings: Useful (1)
In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

Ah, thank you!  It must be the Moove theme that's calling the fonts in that case.  I have to wait for every page to time out searching for Google. 

I just used the CSS on the previously-mentioned page (https://docs.moodle.org/35/en/How_to_add_custom_fonts_in_a_theme), changed for the font I was trying to keep local (Poppins).

In reply to John Kalla

Re: How Do I Load Theme Fonts Locally?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

OK...you really do need help then!

 @font-face { /* where FontName and fontname represents the name of the font you want to add */
     font-family: 'FontName';
     src: url([[font:theme|fontname.eot]]);
     src: url([[font:theme|fontname.eot]]) format('embedded-opentype'),
          url([[font:theme|fontname.woff]]) format('woff'),
          url([[font:theme|fontname.woff2]]) format('woff2'),
          url([[font:theme|fontname.ttf]]) format('truetype'),
          url([[font:theme|fontname.svg]]) format('svg');
     font-weight: normal;
     font-style: normal;
   }
The above needs to be written over and over again substituting the 'fontname' for EVERY new font you have added to the fonts folder found in the Moove theme you are using and will only work when in the theme itself.

It's a mammoth task believe me.

How many fonts do you need anyway? Unless they are Arabic, Chinese,  or some other specific language or icon fonts then you don't really need them do you?. Lets face it, the simpler the theme the faster it works, at least one would hope that is the case!

Hope this helps?

PS: I did a quick scout round the theme and cannot find any Google Font url's in the layout files. What I did see is a setting for Google Analytics which needs turning off if you are inside an enclosed Network!

Mary


Average of ratings: Useful (1)
In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

RE: Adding CSS in a <style> </style> tag in the HEAD part of Additional HTML should work OK.

No it won't as the 'font:theme' needs substituting in the CSS pre-processing.

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: How Do I Load Theme Fonts Locally?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Gareth, 

That's why I asked what CSS the OP had added.  

What I was meaning in my developer mindset related to the fonts and the font CSS. Obviously it is clear now that my meaning did not translate to that when I wrote it has to be in the theme to work.

What's with this Poppins?  Is it me...Mary Poppins...!!!

;)

M


In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

Sry:  Poppins is a google font that (I believe) the theme (Moove) is attempting to load.  smile

In reply to John Kalla

Re: How Do I Load Theme Fonts Locally?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I think that css in the body { font-family: Poppins; }

is an error which needs addressing.

I will contact the Moove theme developer so that he can make a decision if somecode is wrong or missing.

Cheers

Mary

In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

Ah, you're right.  The google fonts calls are in four of his mustache files:

  • inc_start.mustache
  • incourse.mustache
  • login.mustache
  • maintenance.mustache
That's a lot more manageable than I thought it would be.  I think I can simply edit those four.
In reply to John Kalla

Re: How Do I Load Theme Fonts Locally?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Silly me forgot about the templates!!!

Duh!!!


In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

Ahhh!  You're right!  It's the Google Analytics that needs to be switched off.  I'm pretty sure that's it.

If Moove doesn't actually goto Google Fonts, then I'm probably good.  I couldn't find Poppins in any of the fonts folders and the HTML seems to be looking for Poppins, but it's probably in there somewhere, I guess.  I've never used PHP, so am learning how the app is organized bit-by-bit.

In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

PS...  Thank you both for your help!  Is analytics easy to find in admin settings?

--edit--  Ugh.  There's no admin setting to switch off analytics, as far as I can tell.  I'm guessing there's a way to do it in one of the moodle files..?

In reply to Mary Evans

Re: How Do I Load Theme Fonts Locally?

by John Kalla -

I should have checked this before.  The site is trying to load the Poppins font from fonts.googleapis.com.  Sounds like I DO need to figure out how to use the Poppins font I loaded locally.

Looks like Analytics is off by default, so that's not causing a problem.