changing font in a theme

changing font in a theme

by Mahmood Naderan -
Number of replies: 4
Hi
I see this post in order to change the default font of the boost theme.

My question is, where should I put the font files?

Average of ratings: -
In reply to Mahmood Naderan

Re: changing font in a theme

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

Re: changing font in a theme

by Mahmood Naderan -

So, I have the following structure

root@courseware:/var/www/html/theme/boost# ls fonts/
eot  ttf  woff  woff2
root@courseware:/var/www/html/theme/boost# ls fonts/eot/
MYNEWFONT_Black.eot  MYNEWFONT.eot
root@courseware:/var/www/html/theme/boost# find . -name *.css
./style/moodle.css


Then I commented the font-face in the ./style/moodle.css and replaced that with

@font-face {
        font-family: MYNEWFONT;
        font-style: normal;
        font-weight: normal;
        src: url('../fonts/eot/MYNEWFONT.eot');
        src: url('../fonts/eot/MYNEWFONT.eot?#iefix') format('embedded-opentype'),  /* IE6-8 */
                 url('../fonts/woff2/MYNEWFONT.woff2') format('woff2'),  /* FF39+,Chrome36+, Opera24+*/
                 url('../fonts/woff/MYNEWFONT.woff') format('woff'),  /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
                 url('../fonts/ttf/MYNEWFONT.ttf') format('truetype');
}

After saving and restarting apache2, I don't see any change. The font is still the default one.

I have to say that I am using a non-English font.

In reply to Mahmood Naderan

Re: changing font in a theme

by Mahmood Naderan -
OK I manageی to fix that. Here are the steps I took for boost theme:

Creating a folder for fonts in the theme folder
$ ls /var/www/html/theme/boost/fonts/
eot/  ttf/  woff/  woff2/

Go to  Site administration -> Appearance -> Themes -> Boost and paste something like this into "Raw initial SCSS"



@font-face {
        font-family: IRANSans;
        font-style: normal;
        font-weight: normal;
        src: url('/theme/boost/fonts/eot/IRANSansWeb.eot');
        src: url('/theme/boost/fonts/eot/IRANSansWeb.eot?#iefix') format('embedded-opentype'),  /* IE6-8 */
                 url('/theme/boost/fonts/woff2/IRANSansWeb.woff2') format('woff2'),  /* FF39+,Chrome36+, Opera24+*/
                 url('/theme/boost/fonts/woff/IRANSansWeb.woff') format('woff'),  /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
                 url('/theme/boost/fonts/ttf/IRANSansWeb.ttf') format('truetype');
}
body{ font-family:IRANSans !important;}
In reply to Mahmood Naderan

Re: changing font in a theme

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

Do use the 'url([[font:theme|fontname.eot]]);' syntax, even though it is not standard CSS, it 'will' work if used in a theme CSS / SCSS file such as moodle.scss.