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

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

    I was getting the following errors:

    Failed to decode downloaded font: [...]/fonts/glyphicons-halflings-regular.woff2
    OTS parsing error: invalid version tag
    

    which was fixed after downloading the raw file directly from:
    https://github.com/twbs/bootstrap/blob/master/fonts/glyphicons-halflings-regular.woff2

    The problem was that there was a proxy error when downloading the file (it contained the HTML error message).

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

    I got the exact same error, and in my case it turned out to be because of a wrong path for the @font-face declaration. The web inspector never complained with a 404 since the dev server we're using (live-server) was configured to serve up the default index.html on any 404:s. Without knowing any details about your setup, this could be a likely culprit.

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

    When using angular-cli, this is what works for me:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.webServer>
            <staticContent>
                <remove fileExtension=".eot" />
                <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
                <remove fileExtension=".ttf" />
                <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
                <remove fileExtension=".svg" />
                <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
                <remove fileExtension=".woff" />
                <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
                <remove fileExtension=".woff2" />
                <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
                <remove fileExtension=".json" />
                <mimeMap fileExtension=".json" mimeType="application/json" />
            </staticContent>
            <rewrite>
                <rules>
                    <rule name="AngularJS" stopProcessing="true">
                        <match url="^(?!.*(.bundle.js|.bundle.js.map|.bundle.js.gz|.bundle.css|.bundle.css.gz|.chunk.js|.chunk.js.map|.png|.jpg|.ico|.eot|.svg|.woff|.woff2|.ttf|.html)).*$" />
                        <conditions logicalGrouping="MatchAll">
                        </conditions>
                        <action type="Rewrite" url="/"  appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
    0 讨论(0)
  • 2020-12-04 12:07

    Check your font's css file. (fontawesome.css/fontawesome.min.css), you will see like this:

    @font-face {
        font-family: 'FontAwesome';
        src: url('../fonts/fontawesome-webfont.eot-v=4.6.3.htm');
        src: url('../fonts/fontawesome-webfont.eot#iefix-v=4.6.3') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2-v=4.6.3.htm') format('woff2'), url('../fonts/fontawesome-webfont.woff-v=4.6.3.htm') format('woff'), url('../fonts/fontawesome-webfont.ttf-v=4.6.3.htm') format('truetype'), url('../fonts/fontawesome-webfont.svg-v=4.6.3.htm#fontawesomeregular') format('svg');
        font-weight: normal;
        font-style: normal
    }
    

    you will see version tag after your font's file extension name. Like:

    -v=4.6.3

    You just need to remove this tag from your css file. After removing this, you need to go to your fonts folder, And you will see:

    And, Form these font's files, you just need to remove the version tag -v=4.6.3 from the file name.

    Then, The problem will be sloved.

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

    I've had this problem twice already with icon fonts generated by icomoon. In both cases one of the icons was using the "space character" (20)

    It seems that using the space character (code 20) is triggering this issue. After I changed the code to something other than 20 (space), the font worked properly in Chrome.

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

    After trying lots of other approaches, and lots of re-installs and checks, I have just fixed the issue by clearing out browsing data from Chrome (cached images and files) and then refreshing the page.

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