Add your own fonts
Make sure you have the proper license for any custom font before you add it to your store.
You can add your own fonts to your store without having to edit the code directly, which means that you can still upgrade your theme to new versions without losing your custom font! 🎉 Instructions follow.
1) Collect all the font files
In the past, different browsers supported different types of font files and so it was necessary to upload several different file versions of the same font. This is no longer the case, and a "woff" or "woff2" file is the only file you need for all modern browsers. You only need to upload one of these, so if you have both, I'd recommend the "woff2" as it's a newer format with better compression.
There are three font styles offered in the Whisk theme: Body, Heading, and Accent. For all three, you will need two different font weights: 1 default weight (usually "regular" or "400"), and a "bold" or "700" weight. Unless you are uploading a variable font file that can hold more than one weight and style, these will be two separate font files. To add your own body font, you will need 2 more separate font files, an "italic" and a "bold italic". If you do not upload a bold or italic font files for body copy, anytime there is bold or italic text in your store, the browser will make up how it's supposed to look and this can often look bad.
2) Upload the font files to your store
In the Shopify Admin left hand sidebar, go to "Content/Files". Upload your font files by clicking the "Upload files" button.
Once your files are uploaded, click on the "link" button next to the file and save the link url for each file.
3) Add the font files to your theme.
We recommend that you duplicate your current theme and make all of these changes in a draft version of your theme so as to not affect your live store while you make edits, and in case anything goes wrong.
Inside the theme editor, go to "Theme settings/Theme style" and scroll down to find the "Custom CSS" section.
For each font file you have added, add this code block and replace the following areas with data related to your font file. Take note of which values are stored inside of quotes and which aren't.
FONT_FAMILY_NAME = The font family name without any style attached. Example: "Futura".
FONT_LINK_URL = The link url for the file that you copied from the upload in "Content/Files".
FONT_FILE_TYPE = The extension file type. Will most likely be "woff" or "woff2".
FONT_WEIGHT = The weight of the font file. We recommend you use a number for this value. Here are the numbers associated with every weight. If you are uploading a variable font file with more than one weight, separate each weight with a space, e.g. "400 700".
- 100 Thin
- 200 Extra Light
- 300 Light
- 400 Normal
- 500 Medium
- 600 Semi Bold
- 700 Bold
- 800 Extra Bold
- 900 Ultra Bold
FONT_STYLE = either "normal" or "italic".
src: url("FONT_LINK_URL") format("FONT_FILE_TYPE"),
4) Declare your fonts within the available CSS Custom properties
The Whisk theme uses CSS Custom properties (aka CSS variables) which will update the font CSS values throughout your store if you update them at the root like the following example. Add this in the same Custom CSS section that you added the @font-face declarations, just underneath. We've added every custom property that is available in the theme, you can use only the ones that you need. Here's a little more detail about each
FONT_FAMILY_NAME = This needs to match exactly the FONT_FAMILY NAME in your @font-face declaration.
FONT_DEFAULT_WEIGHT = This is the number for the font weight and is the weight when the font style is not purposefully bold. For Heading or Accent styles, you can make the default a bold weight if you like.
FONT_STYLE = Only available for Heading or Accent styles. You can make this "italic" or "oblique" if you always want these font styles to be that way, or else this should be "normal".
Voilà! Your custom font should be visible on your theme! It can also be used in the theme as the font style you declared it with, wherever there is an option to select a font style.
Here's a screencast where we add one font as an example: a regular weight custom font for headings.
For more examples of using CSS's font face, you can read these articles: https://stackdiary.com/tutorials/how-to-use-fonts-in-css-font-face/, https://scalablecss.com/setup-custom-fonts-with-font-face/