Google Fonts is an amazing resource. Before it was so widespread, making websites that used unique fonts was a real pain. Now, though, with a few clicks and one snippet of code, your website moves from being Helvetic-eh to Helvetic-awesome. But what if the font you love isnβt a part of the Google Fonts family? You need to know how to use downloaded fonts because youβve discovered a fantastic hipster font that speaks to your beardβs soul.
Using a downloaded font on your website is not quite as simple as clicky-clicky-paste-paste. Itβs not a hard process, mind you, and I am gonna walk you through it so that you never, ever, ever have a Helvetic-eh website again.
Now, I want to point out that you can do this via a plugin. There are a handful available in the repo. But why would we want to do that? I am the kind of guy who prefers to avoid using a plugin when a few lines of code will do the same thing. Excess plugins cause tons of bloat, unnecessary HTTP requests, and slow down your site.
So weβre going to import these fonts by handβlike itβs the late β90s again. Awww, yeah.
Choosing and Downloading a Font
Iβm a big fan of font roundups. Elegant Themes has a ton you can scan through to see what you like. So hit some of these and see what you like.
For me, I am going with the Aventura font from the Hipster round-up.
Your first step is to find the download link for the font and save the file to your computer. It will likely be a .zip file containing various file formats. The most common ones youβll find is .ttf (TrueType Font) or .otf (OpenType Font).
Making a Webfont (Kinda Optional, but Not Really)
FontSquirrel has a great tool you can use to make sure no one and no browser is left incompatible with your siteβs splendor. Since most fonts you download will only be available in a single format, the FontSquirrel tool makes it so that youβre not limited by what the font author distributed. As long as youβve got rights to use the font, you can make sure it works with your product/site.
Just upload your recently downloaded font and pick your options. Personally, I use the Expert options, just to get all the font formats I can. The others work, but you donβt get as many file types, which is kind of the point of the whole thing.
FontSquirrel is also awesome that it provides you with the required CSS to import them to your site. Howβs that for user-friendly? Youβll just copy and paste it in (which we deal with below).
Uploading Your Font to WordPress
With that done, youβll need to upload the font to your hosting provider. I always do this via FTP (I use FileZilla, but you can use whatever client you want).
If you donβt know your hostβs FTP information, head into your cPanel and look under Files -> FTP Accounts.
You will see every FTP account for the host there, and you should also see a Configure FTP Client link beside each one.
When you go in there, cPanel gives you server information or a FileZilla (and others) file you can import to get your credentials set. I go for manual, personally, but you do what you like. Even if you use the file, youβll need the password to login, so both methods are safe and secure.
Now that youβre logged into your host via FTP, navigate to your /wp-content folder for your site. Because this is content for your WordPress site, why wouldnβt you put it there? Feel free to put it wherever, even in /wp-content/uploads. You do you.
FTP is super easy to upload your file. Just find the font file you downloaded and drag it into the bottom-right pane in FileZilla. That will start the upload. It wonβt take more than a second or so for you to see it in the directory.
If you used the FontSquirrel tool we discussed above, you will do this for all of the font files you downloaded from them as well. Just drag and drop them into wherever you want to store them.
Using Your Font with CSS
Your font is now uploaded and safely snuggled into its warm, comfy wp-content blanket. Itβs time to add the needed CSS import to your theme.
Head to your child themeβs directory (you are using a child theme, right?) in your FTP client and find the style.css file, right-click it, and select View/Edit to bring it up in your default text editor.
If you donβt have a child theme, use the Orbisius Child Theme Creator to do it mega-ultra quick. You can delete the plugin afterward. I love this thing.
@font-face
The code we use comes directly from FontSquirrel (you can write your own or copy/paste the example below), and all I changed was the URL upload path to include /wp-content. Everything else is what the webfont generator provided.
All this @font-face script does is tell your websiteβs stylesheets, βhey, dude, Iβm putting this new font over here if you want to use it sometime.β You know, kind of like you do when you bring cupcakes home and tell the people you live with.
Without @font-face, if you try to call font-family: βaventuraboldβ; by CSS, your site wonβt be able to find it because itβs never been told where youβre keeping it.
@font-face { font-family: 'aventurabold'; src: url('/wp-content/aventura-bold-webfont.eot'); src: url('/wp-content/aventura-bold-webfont.eot?#iefix') format('embedded-opentype'), url('/wp-content/aventura-bold-webfont.woff2') format('woff2'), url('/wp-content/aventura-bold-webfont.woff') format('woff'), url('/wp-content/aventura-bold-webfont.ttf') format('truetype'), url('/wp-content/aventura-bold-webfont.svg#aventurabold') format('svg'); font-weight: normal; font-style: normal; }
Save the file, and since you opened it to edit through the FileZilla, you will get a dialogue asking if you want to replace the one on the server. Your answer is, obviously, yes.
Now all you have to do is go into your custom.css (or if you use Divi, Divi -> Theme Options -> Custom CSS in your WP dashboardβs navigation pane.)
You just add the CSS styling in like you would for any other font. I simply replaced the βRobotoβ and βExoβ Google Fonts I was using with βaventuraboldβ, and things were good to go (thanks to the @font-face import above).
body { font-family: "aventurabold", arial, sans-serif; font-size: 18px; line-height: 28px; color: #ffffff; text-transform: uppercase; } h1, h2, h3, h4, h5, h6 { color: #fff; font-family: 'aventurabold', sans-serif; font-weight: 700; text-transform: uppercase; }
The Fruits of our Labors
Hereβs what it looked like before:
And hereβs what happened after I added Aventura to the CSS:
Hooray! It works! Good job! Go us!
Lookinβ Good, Friendo
Like Captain Malcolm Reynolds once famously said, βWeβve done the impossible, and that makes us mighty.β Well, okay, so uploading a font and importing it via CSS may not quite amount to having done the impossible, but youβve certainly done something many WordPress users wouldnβt dare think of doing: adding core functionality without a plugin.
And that, my friends, does indeed make you mighty.
So whatβs your favorite font to use on the web thatβs not a Google Font? Tell me in teh comments!
Article thumbnail image by 32 Pixels / shutterstock.com
Great article , am using css in this method, very help full
It is ok to do this with css but how can we add these custom fonts to the Divi font selector dropdown?
That’s what I’m trying to figure out too. I did all the steps, but when I went into the Divi -> Theme Options -> Custom CSS, I added the code but there was nothing to replace as in the example.
Did you find something ?
All links go to 404 page.
Such a nice information.
Thanks for sharing…
Here’s the link
https://www.elegantthemes.com/blog/resources/professional-fonts-for-upscale-web-designs
Somehow I just screwed up my site when I entered in the css code. Now I’m totally lost. π
This is what I would like to do : load my font from my server. Thanks. But how to stop divi loading so much JS and Google fonts links ?
All of the font links return “This Page Does Not Exist”.
Links are wrong written, you can correct them, i.e. from:
https://www.elegantthemes.com/blog/resources/“https:/www.elegantthemes.com/blog/resources/30-retro-fonts-for-timeless-designs”
To:
https://www.elegantthemes.com/blog/resources/30-retro-fonts-for-timeless-designs
Many of the links in this article lead to “That page does not exist.” I’d love to see the pages these links go to. Can this be fixed?
Thanks for a great article – a keeper!
Great post. Much prefer using CSS. Thank you!