self-hosting font won't work

I've been trying to apply Roboto Black as self-hosted font (@font-face) downloaded from Google Fonts in all three formats - .ttf, .woff2, and .woff but it is displaying nothing like Roboto Black on Google Fonts and as compared to importing it with @import tag. I have been trying to debug but I've run out of options. Actually, I even checked the woff2 files as they come with HTML/CSS samples - and they look nothing like Roboto Black on Google fonts. That's why I tried .ttf, which is on screenshot - yet it too does not look as it has to be. Is it possible that downloads from Google Fonts are originally of worse quality than @import fonts from the same Google Fonts? Because that is the only conclusion I came to. #front-end
No description
No description
75 Replies
luca
lucathis hour
@Inna Bulatova may I ask, why download fonts instead off using the embed code? or import? Am just curious
Mannix
Mannix23h ago
so google won't track your users 🙂 is the path correct?? any errors in console? is font file being listed in the network tab when you load the page ?
Alex
Alex23h ago
Impossible to know without seeing your file structure, but also, why are you renaming the font to 'main'? Is the other text on the page also roboto? Are you able to import the other font files?
ἔρως
ἔρως23h ago
not just that, but google fonts breaks the gdpr, which means that a website won't be compliant in eu have you tried setting the path to start with /?
StfBauer
StfBauer21h ago
Have you check in the browser what the rendered font say? At least in chrome you should see exactly the font that get's rendered there.
No description
StfBauer
StfBauer20h ago
It's under the computed tab. What do you see under the network tab. Will the fonts be downloaded there?
No description
Inna Bulatova
Inna Bulatova15h ago
It seems to be better for performance reasons, I've watched it in the video of Kevin Powell (here it is https://www.youtube.com/watch?v=zK-yy6C2Nck&t=411s) and I also saw it as a requirement on commercial projects
Kevin Powell
YouTube
Self-hosting fonts explained (including Google fonts) // @font-face...
Google fonts are great, but often self-hosting them is a better choice, or if you’re in parts of Europe, it might be your only choice, so in this video I take a look at the basics of how to self-host fonts. 🔗 Links ✅ Font Squirrel Webfont Generator: https://www.fontsquirrel.com/tools/webfont-generator ⌚ Timestamps 00:00 - Introduction 01:05 -...
Inna Bulatova
Inna Bulatova15h ago
it is listed, and font-family is listed in the computed styles
No description
No description
Inna Bulatova
Inna Bulatova15h ago
it was suggested in the video for debugging purposes so that Google Chrome or computer might have Roboto preinstalled and it would use it instead of the one in the project
ἔρως
ἔρως15h ago
that doesn't mean anything
Inna Bulatova
Inna Bulatova15h ago
thank you! I found it, and it seems somehow that it renders everything in Times New Roman, even though it is not specified anywhere
No description
Mannix
Mannix15h ago
that is css file not a font file
ἔρως
ἔρως15h ago
that's because the font wasn't loaded did you try what i said?
Inna Bulatova
Inna Bulatova15h ago
and it does not show up in the font tab
No description
ἔρως
ἔρως15h ago
404 doesn't show there: it shows in "doc"
Inna Bulatova
Inna Bulatova15h ago
did that - didn't work
No description
ἔρως
ἔρως15h ago
and 404 is what happens when it can't find the font that's not what i said i said /
Inna Bulatova
Inna Bulatova15h ago
console is clean
No description
Inna Bulatova
Inna Bulatova15h ago
did only / - still no change
ἔρως
ἔρως15h ago
then show us the file structure
Mannix
Mannix15h ago
what you directory structure looks like
ἔρως
ἔρως15h ago
you can use vscode for it
Inna Bulatova
Inna Bulatova15h ago
it works for the button - the 700 setup - all correct
No description
No description
Inna Bulatova
Inna Bulatova15h ago
No description
ἔρως
ἔρως15h ago
the assets too
Inna Bulatova
Inna Bulatova15h ago
No description
ἔρως
ἔρως15h ago
🤔
Inna Bulatova
Inna Bulatova15h ago
the other folder is just all the files with css, html samples and stuff.
No description
Inna Bulatova
Inna Bulatova15h ago
just kept it for references and checking
Mannix
Mannix15h ago
seems like the ttf is the issue for some reason
ἔρως
ἔρως15h ago
let me see how are you using the font?
Inna Bulatova
Inna Bulatova15h ago
it is just when I checked out the Roboto Black (which must be 900) in the samples - it was still 400
No description
Inna Bulatova
Inna Bulatova15h ago
I apply it (Roboto Black) only to the h1 as in the code above. For button it is a different file - Roboto Bold. and for the text <p> - Roboto Regular
ἔρως
ἔρως15h ago
can you show the code?
Inna Bulatova
Inna Bulatova15h ago
button works, paragraph works, heading doesn't
Inna Bulatova
Inna Bulatova15h ago
sent
ἔρως
ἔρως15h ago
no, thanks im not downloading a zip
Inna Bulatova
Inna Bulatova15h ago
so how do you want me to show code?
ἔρως
ἔρως15h ago
you can send the html, css and font file
Inna Bulatova
Inna Bulatova15h ago
as a file or paste as code?
ἔρως
ἔρως15h ago
just drag-drop the files it would be better if you could send in a codepen or something
ἔρως
ἔρως15h ago
but fonts and stuff is a pain there
Inna Bulatova
Inna Bulatova15h ago
but you'll need to put it into assets folder or change the path
ἔρως
ἔρως15h ago
it's not even trying to load the font
Inna Bulatova
Inna Bulatova15h ago
I see that it loads only font files for Roboto Bold and Roboto Regular, and doesn't load the Roboto Black, and heading is Roboto Bold instead of Black, but I have no idea why it is not loading, I've given it three options already
No description
No description
Inna Bulatova
Inna Bulatova15h ago
and I tried renaming it to 'Roboto' instead of 'main' - nothing has changed, it still renders as Roboto-Bold and not Roboto-Black
ἔρως
ἔρως15h ago
I FOUND IT src: url('./Roboto-Black.ttf') format('truetype'); you have ttf it's truetype
Inna Bulatova
Inna Bulatova15h ago
I changed it - didn't help - It still is Roboto Bold
ἔρως
ἔρως15h ago
it works if you fix the path to have ./
Inna Bulatova
Inna Bulatova15h ago
Can you show your screenshot?
ἔρως
ἔρως15h ago
you have /
Inna Bulatova
Inna Bulatova15h ago
Because I fixed everything
ἔρως
ἔρως15h ago
No description
Inna Bulatova
Inna Bulatova15h ago
No description
ἔρως
ἔρως15h ago
No description
Inna Bulatova
Inna Bulatova15h ago
but check the rendered font
Inna Bulatova
Inna Bulatova15h ago
this one
No description
Inna Bulatova
Inna Bulatova15h ago
the bottom rendered fonts - does it say Roboto Black?
ἔρως
ἔρως15h ago
it is roboto black the url is wrong. it is ./assets/...
ἔρως
ἔρως15h ago
i threw everything into a folder because im lazy
No description
ἔρως
ἔρως15h ago
just fix the path and it will work
Inna Bulatova
Inna Bulatova15h ago
I did... it still doesn't
No description
ἔρως
ἔρως15h ago
you have to separate the paths with commas url(...) format(...), url(...) format(...) you have it separated by newlines
Inna Bulatova
Inna Bulatova15h ago
it worked!!!
Inna Bulatova
Inna Bulatova15h ago
No description
Inna Bulatova
Inna Bulatova15h ago
I reselected the file by deleting the path and using the pop-up hints, and then it worked
ἔρως
ἔρως15h ago
so, the problems were: - i was wrong about the path - the format is wrong - it isn't ttf but truetype - you had everything smushed together - the font declarations have to be separated by commas and now, i will throw a wrench: roboto has a variable font version, which has 100-900 font-weight in a single file
Inna Bulatova
Inna Bulatova15h ago
yes, you are right. I also forgot (or didn't know) about the commas I tried it with woff2 and it worked too I haven't gotten to this topic yet, thank you for this, I will be sure to check it out
ἔρως
ἔρως15h ago
you should check it
Inna Bulatova
Inna Bulatova15h ago
thank you for your help! this was driving me crazy
ἔρως
ἔρως15h ago
you just need to declare the font once and you save a lot of bandwidth you're welcome dont forget to mark as solved
Inna Bulatova
Inna Bulatova15h ago
how do I do that? it's my first issue
ἔρως
ἔρως15h ago
it's just a tag in the post by the way, just so you know, the variable version is roboto flex
Want results from more Discord servers?
Add your server