I have a local webserver, and I would like to load a local custom font that is not on my project folder
I have checked some tutorials, but for a reason I do not know, I do not manage to load the custom font
Here is what I have done so far
<!DOCTYPE html>
<head>
<title>Font test</title>
</head>
<style>
@font-face
{
font-family: 'TestFont';
src: local('/Users/gomu/Font/testBold.otf');
}
.fontTest
{
font-family: "TestFont";
}
</style>
<body>
<span class="fontTest">Font no jutsu!</span>
</body>
</html>
I have also tried other solutions like
src: local('file:/Users/gomu/Font/testBold.otf');
src: url('file:/Users/gomu/Font/testBold.otf');
But it does not work
I have also disabled the local file restrictions on Safari, but it still does not work.
What I am missing there?
I am currently working on MAC OS Sonoma and can use Safari and Chrome
For your information, "testBold.otf" works if it hosted on a server, but here my goal is to load it locally from my computer
Otherwise, maybe I need to put in the system font folder? (is there something specific to do about that)
Thank you in advance
2
Answers
Make sure your "testbold.otf" file is in a directory within your webserver’s root.
After this update the CSS using the updated source url.
I hope I understood correctly.
Since you mentioned that the fonts were not saved anywhere in the project, I used an external font. However, you could create a folder in your project and place the fonts inside it, allowing you to access them by referencing those fonts, which is a better solution.
In any case, there are three methods for foreign fonts, and I used Google Fonts.
All methods have been written and commented on so that you can study them more easily.
1- import
2- font-face
3- link
You can also refer to the link above for more information on the mentioned topics:
enter link description here
I also added a folder named Fonts to my project and placed my downloaded fonts inside it and referenced them:
I hope you have received my response.