I am trying to add a custom font to my theme but it doesn’t work… I certainly did something wrong but I can’t find where.
- I am developing my own theme that I installed via github.
- In the assets repository, I uploaded my fonts that are not Google fonts :
- In the about.json, I imported the files :
- In my scss repository, I created my font families :
I tried to add : format(‘woff2’) but it doesn’t work neither.
Well, it does not work… Any idea ?
I am not sure what the issue night be. I’d look at Include assets (e.g. images, fonts) in themes and components. Sorry if that’s not helpful.
I’m sure I’m oversimplifying, but I notice in your about.json snippet, the path to the fonts points to an
assets folder, but in your css, the path points to a
fonts folder. Are you sure the css source path is correct?
This is a good catch, but you don’t want to use the path in your CSS like this, you should reference the files using the asset name as a variable:
This is covered in Include assets (e.g. images, fonts) in themes and components
Well I tried but it doesn’t work
It’s hard to guess why. You might put your theme on github and link to it or post your code here.
Did you follow the example provided by @awesomerobot?
I played with this a bit on a fairly new Discourse instance, and had some trouble with the first few fonts I tried. I had converted them to .woff2 using a free, online converter, and I think maybe it didn’t do a good job.
When I tried with an .otf font and again with another .woff2 font converted by a more reputable converter, I was able to add the custom font using the steps in guide @pfaffman and @awesomerobot linked.
It really only took two steps - uploading the file using the Add Upload modal, and adding just the @font-face and body lines of the example SCSS to the theme or component.
I’m sure if you can tell give us more detail and share your code and the fonts, we can help you get this figured out.
Oh Yes, thank you! I tried with the ttf format and it works!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.