2

I'm trying to use a custom font in my Django app.

Here are the relevant lines from my base.html:

{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'recipebook/style.css' %}">

Here is my css file:

@font-face {
    font-family: "FiraCode-Retina";
    src: url("fonts/FiraCode-Retina.ttf") format("truetype");
}

body {
    margin: 0px;
    background-color: aliceblue;
}

.banner {
    border: 1px solid rgb(50, 50, 60);
    height: 75px;
}

.headnav {
    border: 1px solid rgb(50, 50, 60);
    height: 50px;
}

main {
    display: flex;
    height: 800px;
}

.navpanel {
    border: 1px solid rgb(50, 50, 60);
    flex-grow: 1;
}

.mainpanel {
    border: 1px solid rgb(50, 50, 60);
    flex-grow: 4;
}

.smartpanel {
    border: 1px solid rgb(50, 50, 60);
    flex-grow: 1;
}

.footerbar {
    border: 1px solid rgb(50, 50, 60);
    height: 50px;
}

Here is my file structure:

enter image description here

My CSS is working except for the font. What steps am I missing to get this working?

Evelyn
  • 99
  • 2
  • 10

2 Answers2

1

The Problem is, that you never assign the loaded Font to any Element. You have to add it like

body {
    font-family: "FiraCode-Retina", sans-serif;
    margin: 0px;
    background-color: aliceblue;
}

Only the @font-face declaration is not enough.

grisuu
  • 189
  • 1
  • 9
0
@font-face {
    font-family: 'GlassGauge';
    src: url({% static 'fonts/GlassGauge.ttf' %}) format('truetype');
}
Dimanjan
  • 563
  • 6
  • 13