Change font in Moodle

If you have an academy and using moodle as an LMS is your choice, you may want to change default font of pages to a new one. In this article I am going to talk about a method to do so.

First of all you have to choose which theme you wanna use (through Administration > Appearance > Themes > Theme selector). For example I am gonna use boost theme.

Then, you have to copy your font’s files into theme’s directory.

cp FONT_PATH/[font_file].* MOODLE_PATH/theme/[theme_name]

Then you have to open theme’s config.php file:

vi MOODLE_PATH/theme/[theme_name]/config.php

and change the value of $THEME->sheets parameter:

$THEME->sheets = ['FontName'];

After that you have to create a FontName.css file in MOODLE_PATH/theme/[theme_name]/style directory like this:

@font-face {
        font-family: 'IranSans';
        font-style: normal;
        font-weight: normal;
        font-display: auto;

        src: url([[font:theme|font_file.eot]]);
        src: url([[font:theme|font_file.eot]]) format('embedded-opentype'),
          url([[font:theme|font_file.woff]]) format('woff'),
          url([[font:theme|font_file.woff2]]) format('woff2'),
          url([[font:theme|font_file.ttf]]) format('truetype'),
          url([[font:theme|font_file.svg]]) format('svg');
}

and finally, purge your cache through Site Administration > Development > Purge all caches