Skip to content

[loader] Failed to decode downloaded font. OTS parsing error: invalid version tag #1468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
luqin opened this issue Sep 23, 2015 · 28 comments
Closed

Comments

@luqin
Copy link

luqin commented Sep 23, 2015

my config:

            { test: /\.eot/, loader: 'url-loader?limit=100000&mimetype=application/vnd.ms-fontobject' },
            { test: /\.woff2/, loader: 'url-loader?limit=100000&mimetype=application/font-woff2' },
            { test: /\.woff/, loader: 'url-loader?limit=100000&mimetype=application/font-woff' },
            { test: /\.ttf/, loader: 'url-loader?limit=100000&mimetype=application/font-ttf' }

chrome console:

Failed to decode downloaded font: data:application/font-woff2;base64,bW9kdWxlLmV4cG9ydHMgPSAiZGF0YTphcHBsaWNh…dXbXR0MlhlVWZrVDBjZUhZTHVWSFlCVFJoMU4waUtEeHE0bHd0L01NcWZUZS9IL1R1MzlYIg==
OTS parsing error: invalid version tag
@SimenB
Copy link
Contributor

SimenB commented Sep 23, 2015

Have you tried adding $s to the end of test? Like test: /\.eot$/, on all of them. woff might get hit twice

@luqin
Copy link
Author

luqin commented Sep 24, 2015

But the url is .woff2?v=4.4.0 and .woff2?xxxx

@luqin
Copy link
Author

luqin commented Sep 24, 2015

Thank you. It works when the test is /\.woff2(\?\S*)?$/.

@luqin luqin closed this as completed Sep 26, 2015
@dody87
Copy link

dody87 commented Dec 14, 2015

Please verify on awesome-fonts .css file if the url path for fonts are ok. It works for me.

@isramv
Copy link

isramv commented Aug 8, 2016

I removed all other config and used this:

{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }

I hope this helps someone else too.
remember: remove other font test configurations for fonts.

@hmichelkernix
Copy link

Hello @isramv, on your snippet, I think there is a typo on minetype, shouldn't be mimetype ?

@mbifulco
Copy link

I'm having this same issue, and none of the above seem to work for me.

@barberj
Copy link

barberj commented Oct 1, 2016

@mbifulco any luck?

@mbifulco
Copy link

mbifulco commented Oct 5, 2016

Not yet, unfortunately :/

@refaelos
Copy link

refaelos commented Oct 7, 2016

@mbifulco if you find anything I'd love to see that as well .. 😞

@StaticSphere
Copy link

Thanks, @isramv !!! This worked great for me.

@aspirisen
Copy link

Have the same

@existe-deja
Copy link

existe-deja commented Jan 2, 2017

Didn't work neither for woff/woff2 files, but now it's ok. What I did:

{
  test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  loader: 'url',
  query: {
    limit: 10000,
    mimetype: "application/font-woff",
    name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  }
},
{
  test: /\.(eot|ttf|otf)(\?.*)?$/,
  loader: 'url',
  query: {
    limit: 10000,
    name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  }
},

I also re-converted my font files using online convertors, and now it works like a charm.

@designbyadrian
Copy link

@LaCroute What is "utils" in your example?

@lubien
Copy link

lubien commented Jan 29, 2017

I'd like to share the solution to my problem that's fairly same as yours for those who google they way out here (like me).

Given my folder structure

/ # root of web server
   css/
       file-that-import-fonts.css
   fonts/
       font-file.ext

The output css file was trying to import font files at the same folder level of it.

So it always hit 404 /css/font.x and my server rendered 404 error was mistaken as a broken font. That's why Failed to decode downloaded font. OTS parsing error: invalid version tag.

The following snippet solved:

{
  test: /\.(otf|eot|svg|ttf|woff|woff2)$/,
  loader: 'file-loader',
  query: {
    outputPath: 'fonts/',
    publicPath: '../fonts/' // That's the important part
  }
},

Now my font files are properly referenced within my css file.

@existe-deja
Copy link

@designbyadrian sorry I didn't see utils was not defined...

I adapted my config from this template. So utils is the require of this file > https://github.com/vuejs-templates/webpack/blob/master/template/build/utils.js

@brandonsueur
Copy link

Hi @isramv, thank you !

@wladyslawczyzewski
Copy link

Recently I also had the same problem, the following webpack config script snipped is solved the issue:

    {
      test: /\.svg(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: 'url?limit=65000&mimetype=image/svg+xml&name=/[name].[ext]'
    },
    {
      test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: 'url?limit=65000&mimetype=application/font-woff&name=/[name].[ext]'
    },
    {
      test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: 'url?limit=65000&mimetype=application/font-woff2&name=/[name].[ext]'
    },
    {
      test: /\.[ot]tf(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: 'url?limit=65000&mimetype=application/octet-stream&name=/[name].[ext]'
    },
    {
      test: /\.eot(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: 'url?limit=65000&mimetype=application/vnd.ms-fontobject&name=/[name].[ext]'
    }

The most important thing from the config above is name query parameter for url loader, with my config fonts will be rendered as /, you may prefixed this with, for example, fonts: &name=/fonts/[name].[ext]

@naulacambra
Copy link

@vchyzhevskyi thanks!! It worked after few hours searching a solution

@existe-deja
Copy link

@vchyzhevskyi this way you'll encode your fonts in base64 into your css file no ? Could be better to have font files to light the weight of your app..

@cyberhck
Copy link

cyberhck commented Aug 3, 2017

it worked for me after I specify the format like this:

@font-face {
    font-family: "shop-icons";
    src: url(node_modules/mypkg/fonts/shop-icons.svg) format("svg"),
        url(node_modules/mypkg/fonts/shop-icons.ttf) format("truetype"),
        url(node_modules/mypkg/fonts/shop-icons.eot),
        url(node_modules/mypkg/fonts/fonts/shop-icons.woff) format("woff");
}

Initially I didn't have format and my style looked like:

@font-face {
    font-family: "shop-icons";
    src: url(node_modules/mypkg/fonts/shop-icons.svg),
        url(node_modules/mypkg/fonts/shop-icons.ttf),
        url(node_modules/mypkg/fonts/shop-icons.eot),
        url(node_modules/mypkg/fonts/fonts/shop-icons.woff);
}

@timotew
Copy link

timotew commented Oct 2, 2017

Has Similar issue, This works for me:
{ test: /\.(eot|woff|ttf|svg)$/, loaders: ["file?name=[path][name].[ext]?[hash]"] }, { test: /\.woff2(\?\S*)?$/, loaders: ["file?name=[path][name].[ext]?[hash]"] }

@Pushplaybang
Copy link

none of these solutions are working for me.

still getting the error :)

@kaankucukx
Copy link

kaankucukx commented Mar 31, 2018

@Pushplaybang have u realized wuts going on ? me either having the same erros and still cant figure it out.. :(

Edit :

I come up with this. simply removed the loader and it worked.

I have to mention, my build is with Vue Cli 3 and applying this configuration on vue.config.js

Hope this helps. 🎉

       {
          test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        }

@Pushplaybang
Copy link

@kaankucukx - ok, will try that out. thanks.

@jessiezf
Copy link

I removed all other config and used this:

{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }

I hope this helps someone else too.
remember: remove other font test configurations for fonts.

This works for me thinks

@vis97c
Copy link

vis97c commented Aug 10, 2019

@Pushplaybang have u realized wuts going on ? me either having the same erros and still cant figure it out.. :(

Edit :

I come up with this. simply removed the loader and it worked.

I have to mention, my build is with Vue Cli 3 and applying this configuration on vue.config.js

Hope this helps. 🎉

       {
          test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        }

This solved the issue, thanks!!

@ZeroByter
Copy link

{ test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader" }

Strangely, this worked for me. If anyone out there is stuck on this with no hope, give this bizarre solution a try ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests