I upload some font-related files in assets in Shopify. But I don’t know where and how to define the below code.
@font-face {
font-family: 'FreeSansBold';
src: url('FreeSansBold.eot');
src: url('FreeSansBold.eot?#iefix') format('embedded-opentype'),
url('FreeSansBold.woff2') format('woff2'),
url('FreeSansBold.woff') format('woff'),
url('FreeSansBold.ttf') format('truetype'),
url('FreeSansBold.svg#FreeSansBold') format('svg');
font-weight: bold;
font-style: normal;
font-display: swap;
}
4
Answers
create a
css
file callcustom-fonts.css
or anything you likeadd the
@font-face
code you have and declarefont-family
to the taggo to
theme.liquid
find your
theme.scss.css
ortheme.css
line andput this line after
Instead of creating a new file and increasing the https count you can directly include the code in theme.css file of your theme
To reference the font files you need to use the
asset_url
url filter. You do that by passing the file name to the filter, as below.eg.
Please note, this will only work in a file that ends
.liquid
, egtheme.liquid
orfonts.css.liquid
.using
url_filters
, fonts were still not loading. So I did few things,uploaded all the fonts in settings > Files
copied the link of the asset
then I add the below code in my style.css