How do I add custom fonts?

Our support for this feature is limited to this tutorial. It requires some coding knowledge of Shopify themes. We suggest hiring a Shopify Expert if you don't feel comfortable proceeding with the following tutorial.

With some custom code you can add your own fonts to our themes. These fonts will not appear in the theme editor as a dropdown option, but instead override the values directly in the stylesheet.

1. Generate your font and style files

Upload your custom font files to Font Squirrel with this tool. TTF file types have the best success. Then click the Download your kit button to get a zip file with the required files.

Fonts must have a valid license to use on the web

2. Add the font files to your theme

First, open up your theme editor (navigate to /admin/themes, click Actions on your copy of Expanse, and then click Edit code. Click on Add new asset in your assets folder and upload the fonts that you just got in the zip file above.

3. Edit your theme's code

Look for an open css-variables.liquid inside your snippets folder.

Add this code on the first line after the {% style %} tag:

@font-face {
  font-family: "MyFont";
  src: url('{{ "font_myfont.woff2" | asset_url }}') format("woff2"),
       url('{{ "font_myfont.woff" | asset_url }}') format("woff");
}

You can set the headings and body fonts by changing these two lines:

--typeHeaderPrimary: {{ settings.type_header_font_family.family }};
--typeBasePrimary:{{ settings.type_base_font_family.family }};

to match your newly created font:

--typeHeaderPrimary: 'MyFont';
--typeBasePrimary: 'MyFont';

You'll also want to adjust a few other lines in this file. The following lines previously used your theme settings to set the style and font weight. Similar to above, you'll want to change these values according to your newly added font.

--typeHeaderWeight: {{ settings.type_header_font_family.weight }};
--typeBaseWeight: {{ settings.type_base_font_family.weight }};

The above would change to something like:

--typeHeaderWeight: 700;
--typeBaseWeight: normal;