Use the @font-face
CSS is a good alternative. Assuming your project has the following structure:
site/
├── css/
│ └── styles.css
├─── fonts/
│ ├── Oxygen-Regular.eot
│ ├── Oxygen-Regular.svg
│ ├── Oxygen-Regular.ttf
│ ├── Oxygen-Regular.woff
│ └── Oxygen-Regular.woff2
└── index.html
To have good compatibility with current browsers, you will need to have at least the files .woff2
and .woff
from its source (I am using as an example the source Oxygen). Copy them to the folder fonts
and in your file styles.css
, do:
@font-face {
font-family: 'Oxygen';
src: url('../fonts/Oxygen-Regular.woff2') format('woff2');
src: url('../fonts/Oxygen-Regular.woff') format('woff');
font-weight: normal;
}
After this, just assign the source to some element, for example to the body
:
body {
font-family: 'Oxygen', sans-serif;
}
For maximum compatibility, including slightly older browsers, you will need the files .eot
, .woff
, .woff2
, .ttf
and .svg
from its source. Hence it would look like this:
@font-face {
font-family: 'Oxygen';
src: url('../fonts/Oxygen-Regular.eot');
src: url('../fonts/Oxygen-Regular.eot?#iefix') format('embedded-opentype'),
url('../fonts/Oxygen-Regular.woff2') format('woff2'),
url('../fonts/Oxygen-Regular.woff') format('woff'),
url('../fonts/Oxygen-Regular.ttf') format('truetype'),
url('../fonts/Oxygen-Regular.svg#oxygen') format('svg');
font-weight: normal;
}
You can please show how you import fonts; that is, you can put html or css where you import fonts
– Cristiano Gilberto João
Is there an error in the Devtools Console? If so, which?
– hugocsl
I was not knowing how to use @font-face so I posted here, I will try the solution proposed in the comments below as soon as I get home and reply back.
– jpbatista