zoukankan      html  css  js  c++  java
  • 浏览器警告Failed to decode downloaded font和OTS parsing error: Failed to convert *** font to ***

    昨晚,在做一个自己感兴趣的东西时,发现浏览器报警告,Failed to decode downloaded font以及OTS parsing error: Failed to convert *** font to ***。

    但是这个问题从来没有遇到过,在网上找了一会儿答案后,发现了类似的问题回答下有网友猜测是拦截器没通过,所以我检查了shiro的拦截配置:

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

    但是这个配置理论上是没问题的,所以不是这个问题。

    今天在查阅了一些资料后,发现了可能的原因:

    在maven的filter解析font文件时,它破坏了font文件的二进制文件格式,导致浏览器解析出错。

    解决的思路是:font文件不需要filter,因此我们需要在配置中设置一下(SpringBoot在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>

    在经如上所示的配置后,maven在编译项目时不解析font文件,浏览器就不会报警告,字体也可以正常显示。

  • 相关阅读:
    云架构师进阶攻略(1)
    针对云主机卡死问题的定位分析方法
    让App飞久一点
    OC静态代码检查实战
    PAT 1010. 一元多项式求导
    PAT 1009. 说反话
    PAT 1008 数组元素循环右移问题
    PAT 1007. 素数对猜想
    PAT 1006 换个格式输出整数
    PAT 1005 继续(3n+1)猜想
  • 原文地址:https://www.cnblogs.com/Ericzya/p/8056293.html
Copyright © 2011-2022 走看看