Exoseed
Exoseed

Reputation: 41

Failed to decode downloaded font Laravel

This issue is driving me mad, so if anybody is able to help, thank you in advance!

I'm trying to use a custom font in a Laravel project, but the font doesn't work and I've got this message in Chrome console:

Failed to decode downloaded font: https://womenbirthphoto.com/fonts/lucyrose-regular-webfont.woff

I have the same message for .ttf and .woff2 fonts. This is what is in my CSS code:

    @font-face {
        font-family: 'Lucy Rose';
        src: url('../fonts/lucyrose-regular-webfont.eot');
        src: url('../fonts/lucyrose-regular-webfont.eot?#iefix') format('embedded-opentype'),
             url('../fonts/lucyrose-regular-webfont.woff2') format('woff2'),
             url('../fonts/lucyrose-regular-webfont.woff') format('woff'),
             url('../fonts/lucyrose-regular-webfont.ttf') format('truetype'),
             url('../fonts/lucyrose-regular-webfont.svg#lucy_roseregular') format('svg');
        font-weight: normal;
        font-style: normal;
}

The names/paths of the files are right. The files were generated via Fontsquirrel webfont generator.

I feel like I tried everything, I don't see why this error shows up. The font is not working on any browser.

Thanks in advance for your help!

Upvotes: 0

Views: 1924

Answers (2)

Exoseed
Exoseed

Reputation: 41

Ok so I finally resolved this issue, here is the answer if this can help somebody in the future. The issue came from my .htaccess file, I had this rule:

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

As you can see, the first line is missing the extensions for all font formats. I resolved the issue by changing to this:

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.woff|\.woff2|\.ttf|\.eot|\.svg|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Now everything works! Hope this can help.

Upvotes: 3

Farid
Farid

Reputation: 762

Any attemp to point my browse directly to your fonts files results in a blank page so I must ask you if have you test your fonts online with the html file generated by fontsquirrel as a proof, because I suspect that maybe your fonts files are corrupted.

You would have a try with transfonter.org in order to check if everything is fine with generated files. Regards.

Upvotes: 0

Related Questions