Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I have followed several tutorials and added the following CSS to test with both base.css and then a custom.css file linked to theme.liquid:
@font-face {
font-family: "smokey";
src: url({{"smokey.woff" | asset_url}}) format("woff"),
url({{"smokey.woff2" | asset_url}}) format("woff2");
}
Both woff & woff2 fonts are uploaded to the assets folder.
I then tried to use font on h2 headers with:
h2 {
font-family: "smokey" !important;
}
The headers change from a sans serif to a serif font (so they are being targeted) but they do not change to the smokey font.
Just wondering if I am doing anything wrong or if this doesn't work with the Dawn 6.0.2 theme.
Cheers!
Solved! Go to the solution
This is an accepted solution.
Hi @chookz,
Try this different approach. You can also try to upload your font this way instead of doing it from the asset folder in your theme.
1. In your Admin store, click Settings on your left hand bottom corner
2. Go to Files, then upload your font.
3. Copy the link when done uploading, and paste it in the font-face. See code below for reference
@font-face {
font-family: 'smokey';
src: url(https://samplelink) format('woff2'),
url(https://samplelink) format('woff');
}
This is an accepted solution.
Hi @chookz,
Try this different approach. You can also try to upload your font this way instead of doing it from the asset folder in your theme.
1. In your Admin store, click Settings on your left hand bottom corner
2. Go to Files, then upload your font.
3. Copy the link when done uploading, and paste it in the font-face. See code below for reference
@font-face {
font-family: 'smokey';
src: url(https://samplelink) format('woff2'),
url(https://samplelink) format('woff');
}
Hi,
Your approach is correct.
However you always need to use fallback font.
Please keep your fonts in assets and upload the fonts to your file folder (Admin > Settings > Files )
Please add the code below to Assets/base.css.
@font-face {
font-family:"smokey";
src: url("{{ 'smokey.woff' | asset_url }}") format("woff"),
url("{{ 'smokey.otf' | asset_url }}") format("opentype");
font-display:auto; font-style:normal; font-weight:400; font-stretch:normal;
}
@font-face {
font-family: smokey;
font-weight: 400;
font-style: normal;
font-display: fallback;
src: url("https://cdn.shopify.com/your-font-file-address/") format("woff2"),
url("https://cdn.shopify.com/your-font-file-address/") format("woff");
}
/* Don't remove the header font-familty */
h2 {
font-family: "smokey" !important;
}
Hope it works and helps.
Thanks.
Thank you very much. This worked great. Perhaps just edit your code to put the url sample link in quotation marks for anybody else looking for the same answer. Cheers
User | RANK |
---|---|
150 | |
94 | |
65 | |
58 | |
53 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By