Tag Archives: Failed to decode downloaded font

[Solved] Browser Error: Failed to decode downloaded font and OTS parsing error: Failed to convert *** font to ***

Last night, when I was doing something I was interested in, I found that the browser alarm failed to decode downloaded font and OTS parsing error: failed to convert * * * font to * * *.

However, I have never encountered this problem. After looking for the answer on the Internet for a while, I found a similar question. Some netizens guessed that the interceptor failed, so I checked Shiro’s interception configuration:

<property name="filterChainDefinitions">
       <value>
                /=authc
                /index=authc
                /logout=logout
                /assets/** = anon
                /css/** = anon
                /fonts/**=anon
                /img/**=anon
                /**= user
       </value>
</property>

But this configuration is theoretically OK, so it’s not this problem.

After consulting some materials today, we found the possible reasons:

When Maven’s filter parses the font file, it destroys the binary file format of the font file, resulting in browser parsing errors.

The solution is: the font file does not need a filter, so we need to set it in the configuration (springboot is written in pom.xml):

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <!-- fonts file cannot use filter as the data structure of byte file will be changed via filter -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>static/fonts/**</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>static/fonts/**</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

After the configuration shown above, Maven does not parse the font file when compiling the project, the browser will not give an alarm, and the font can be displayed normally.

Failed to decode downloaded font [How to Solve]

The following error is encountered. This error occurs when the print, export and filter columns of layui are opened. The icon and text cannot be displayed normally

Reason:

@Reference article

Because after Maven’s filter, the binary file format of the font file will be destroyed, and the foreground parsing error will occur

Solution:

Remove the interception of. TFF and. Woff

springmvc.xml:

<mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**" />
            <mvc:exclude-mapping path="/**/fonts/*" />
            <mvc:exclude-mapping path="/**/*.css" />
            <mvc:exclude-mapping path="/**/*.js" />
            <mvc:exclude-mapping path="/**/*.png" />
            <mvc:exclude-mapping path="/**/*.gif" />
            <mvc:exclude-mapping path="/**/*.jpg" />
            <mvc:exclude-mapping path="/**/*.jpeg" />
            <mvc:exclude-mapping path="/**/*.ttf" />
            <mvc:exclude-mapping path="/**/*.woff" />
        </mvc:interceptor>
    </mvc:interceptors>