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

后端 未结 25 1470
长发绾君心
长发绾君心 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:26

    If other answers didn't work try:

    1. check .htaccess file

      # Fonts
      # Add correct content-type for fonts

      AddType application/vnd.ms-fontobject .eot
      AddType application/x-font-ttf .ttf
      AddType application/x-font-opentype .otf
      AddType application/x-font-woff .woff
      AddType application/x-font-woff2 .woff2
      AddType image/svg+xml .svg

    2. clear server cache

    3. clear browser cache & reload
    0 讨论(0)
  • 2020-12-04 12:27

    try

    @font-face {
      font-family: 'icomoon';
      src: asset-url('icomoon.eot');
      src: asset-url('icomoon.eot?#iefix') format('embedded-opentype'),
           asset-url('icomoon.ttf') format('truetype'),
           asset-url('icomoon.woff') format('woff'),
           asset-url('icomoon.svg#icomoon') format('svg');
      font-weight: normal;
      font-style: normal;
    }
    

    and rename your file to application.css.scss

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

    I had same problem when I opened and saved .woff and .woff2 files through Sublime Text with EditorConfig option end_of_line = lf. I just copied files to font folder without opening them into Sublime and problem was solved.

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

    Just state format at @font-face as following:

    @font-face {
      font-family: 'Some Family';
      src: url('/fonts/fontname.ttf') format('ttf'); /* and this for every font */
    }

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

    If your are using Chrome, try adding an opentype (OTF) version of your font as shown below:

        ...
         url('icomoon.otf') format('opentype'),
        ...
    

    Cheers!

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

    I am using ASP.NET with IIS and it turns out I just needed to add the MIME-type to IIS: '.woff2' / 'application/font-woff'

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