doctorsherlock
doctorsherlock

Reputation: 1374

Using fonts in Jinja2 template?

I am trying to add a google-font to my jinja2 template. I downloaded the google font and put it in the project directory, using this

<link rel='stylesheet' type='text/css' href="{{ url_for('static', filename='fonts/Oswald-Bold.ttf')}}">

i tried to use the font in the template but it is not working. What is the proper way of doing this? The CSS looks like this

body {
  background-color: #ED9121;
  font-family: 'Oswald';
  font-weight: 700;
}

If I use the font directly from google instead of from my server, it works fine. Please help.

Upvotes: 2

Views: 5946

Answers (2)

Ravindra Reddy K
Ravindra Reddy K

Reputation: 1

We can change the font size by using the font tag and customizing the size

for example :

<html>
 <head>
 </head>
 <body>
   <p><font size="6">Font size is 6</font></p>
   <p><font size="24">Font size is 24</font></p>
 </body>
</html>

Upvotes: 0

Bart Bussel
Bart Bussel

Reputation: 176

Try to use this in your CSS

@font-face {
        font-family: Oswald;
        src: url(/static/fonts/Oswald-Bold.ttf);
    }

body {
        font-family:Oswald;
    }

remove href="{{ url_for('static', filename='fonts/Oswald-Bold.ttf')}}"

also make sure your font is inside the folder fonts. I tried it and for me this is working.

Upvotes: 2

Related Questions