I know the question is pretty broad, but after reading all the previous discussions about custom fonts I still find issues making them work correctly locally and in production.
Using ~@fonts would make the path to the font not correct, while using ../resources/fonts/ would create issues building styles.
The only way I was able to display the fonts in production was by changing how .setPublicPath is set, which I think it’s not a good idea.
Thus, any hint would be incredibly welcome. Thank you for all the great work!
Hi @ben that is indeed how my path is set.
At some point, just for testing, I tried to edit the path by making it match to the built font assets path (e.g. wp-content/<redacted-theme-name>/...). In this way in the production environemnt the fonts were showing, but I guess this is definitely not the way to go.
I get the following error in my console: GET http://<my-local-url>/fonts/SourceSansPro-Regular.woff2 net::ERR_ABORTED 404 (Not Found). What I don’t understand is what step I’m missing or what I’m overlooking.
You provided example code for a font face named Oswald but your 404 is for a different font entirely
It’s very difficult to piece this all together by the small bits of code that you’re providing on here. If you’d like to push up a git repo that has a minimal reproduction of your issue, then please share it.
I’m sorry, my mistake, it’s the same with the Oswald font though: GET http://<my-local-url>/fonts/Oswald-Bold.woff2 net::ERR_ABORTED 404 (Not Found)
The custom fonts are placed in /resources/fonts folder, so I’m just trying to understand what I’m doing wrong and if there’s some knowledge I’m missing.