cli: [Bug]: Custom fonts in assets directory causing OTS parsing error
Please confirm that you have:
- Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
- Reproduced the issue in the latest CLI version.
In which of these areas are you experiencing a problem?
Theme
Expected behavior
Font files added to the assets directory should upload to the server on push, and be usable with an @font-face reference immediately with no errors in the browser’s console blocking dev.
Actual behavior
When adding custom font files to my assets directory locally, then running shopify theme dev --theme-editor-sync the font files are uploaded to the temp dev server, but in the console I get this error:
Failed to decode downloaded font: http://127.0.0.1:9292/cdn/shop/t/8/assets/Bayard-Regular.woff2?v=135843728640516025251700896606
OTS parsing error: Failed to convert WOFF 2.0 font to SFNT
What does this mean? Why do custom fonts added to the assets directory cause this to happen? This error is blocking my custom fonts from working on the frontend during development.
FYI this is a known issue [https://community.shopify.com/c/technical-q-a/has-anyone-else-had-issues-with-corrupted-woff-or-woff2-files/m-p/1732103]
If I add the font files to Files using the admin side that works, and instead of asset_url I use file_url but this should work without admin access, using assets directory instead.
Verbose output
n/a
Reproduction steps
- Add font files to assets directory
- Create
@font-facerule with link to font file usingasset_url - Run
shopify theme devand check the browser’s console to see if the font pushed is causing an error to appear
Operating System
Windows 11
Shopify CLI version (check your project’s package.json if you’re not sure)
v3.50.2
Shell
Bash, Powershell
Node version (run node -v if you’re not sure)
v18.17.1
What language and version are you using in your application?
Ruby v31
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (6 by maintainers)
Thank you @jamiestead, I’ve managed to recreate the issue because of this. It looks like a regression was indeed introduced in a prior version that broke being able to render font styles in a
<style>tag. This seems to occur on Windows machines only.For anyone else seeing this, a temporary workaround is to move any font style definitions into a dedicated CSS file (e.g.
base.css.liquid). After doing this, rendering the font on the local dev server should work as expected.In the meantime I’ll try to track down what introduced this regression.