Failed to decode downloaded font, OTS parsing error: invalid version tag + rails 4

后端 未结 25 1471
长发绾君心
长发绾君心 2020-12-04 11:46

I am doing assets pre-compile, and running the application in production mode. After compilation when I load the my index page I got followings warnings in the chrome consol

相关标签:
25条回答
  • 2020-12-04 12:20

    What helped me was that I changed the order. The .eot get's loaded first, but my error was on loading the .eot. So I ditched the .eot as a first src for woff2 and the error went away.

    So code is now:

    @font-face {
      font-family: 'icomoon';
      src:  url('assets/fonts/icomoon.woff2?9h1pxj') format('woff2');
      src:  url('assets/fonts/icomoon.eot?9h1pxj#iefix') format('embedded-opentype'),
        url('assets/fonts/icomoon.woff2?9h1pxj') format('woff2'),
        url('assets/fonts/icomoon.ttf?9h1pxj') format('truetype'),
        url('assets/fonts/icomoon.woff?9h1pxj') format('woff'),
        url('assets/fonts/icomoon.svg?9h1pxj#icomoon') format('svg');
      font-weight: normal;
      font-style: normal;
      font-display: block;
    }
    

    And is was:

    @font-face {
      font-family: 'icomoon';
      src:  url('assets/fonts/icomoon.eot?9h1pxj');
      src:  url('assets/fonts/icomoon.eot?9h1pxj#iefix') format('embedded-opentype'),
        url('assets/fonts/icomoon.woff2?9h1pxj') format('woff2'),
        url('assets/fonts/icomoon.ttf?9h1pxj') format('truetype'),
        url('assets/fonts/icomoon.woff?9h1pxj') format('woff'),
        url('assets/fonts/icomoon.svg?9h1pxj#icomoon') format('svg');
      font-weight: normal;
      font-style: normal;
      font-display: block;
    }
    
    0 讨论(0)
  • 2020-12-04 12:21
    For it is fixed by using below statement in app.web.scss
        $fa-font-path:   "../../node_modules/font-awesome/fonts/" !default;
        @import "../../node_modules/font-awesome/scss/font-awesome";
    
    0 讨论(0)
  • 2020-12-04 12:23

    I've had the same issue.

    Adding the font version (e.g. ?v=1.101) to the font URLS should do the trick ;)

    @font-face {
        font-family: 'Open Sans';
        font-style: normal;
        font-weight: 600;
        src: url('../fonts/open-sans-v15-latin-600.eot?v=1.101'); /* IE9 Compat Modes */
        src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
        url('../fonts/open-sans-v15-latin-600.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
        url('../fonts/open-sans-v15-latin-600.woff2?v=1.101') format('woff2'), /* Super Modern Browsers */
        url('../fonts/open-sans-v15-latin-600.woff?v=1.101') format('woff'), /* Modern Browsers */
        url('../fonts/open-sans-v15-latin-600.ttf') format('truetype'), /* Safari, Android, iOS */
        url('../fonts/open-sans-v15-latin-600.svg#OpenSans') format('svg'); /* Legacy iOS */
    }
    

    Clicking (right mouse click) on font's TTF version and selecting "Get Info" (Mac OSX) "Properties" (Windows) in context menu should be enough to access the font version.

    0 讨论(0)
  • 2020-12-04 12:25

    Go to the address below on GitHub and download each of the FontAwesome files.

    https://github.com/FortAwesome/font-awesome-sass/tree/master/assets/fonts/font-awesome

    ...but instead of right-clicking and saving the link as, click on each of the files and use the 'Download' button to save them.

    I found that saving the link as downloaded an HTML page and not the FontAwesome file binary itself.

    Once I had all of the binaries it worked for me.

    0 讨论(0)
  • 2020-12-04 12:25

    For angular-cli and webpack users I suspected that there is some issue while importing the fonts in css file , so please also provide url location encoded with single quotes as following -

    @font-face {
    font-family: 'some_family';
    src: url('./assets/fonts/folder/some_family-regular-webfont.woff2') format('woff2'),
         url('./assets/fonts/folder/some_family-regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    }
    

    This post might be old , but this is the solution which worked for me .

    0 讨论(0)
  • 2020-12-04 12:26

    If you use bootstrap then Update bootstrap css(bootstrap.min.css) file and fonts files. I fixed my problem with this solution.

    0 讨论(0)
提交回复
热议问题