浏览器警告Failed to decode downloaded font和OTS parsing error: Failed to convert *** font to ***...

本文详细介绍了在使用Maven构建SpringBoot项目时,遇到的字体文件解析错误问题及解决方案。通过调整pom.xml中资源文件的过滤设置,确保字体文件不被过滤,从而避免了浏览器解析错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

昨晚,在做一个自己感兴趣的东西时,发现浏览器报警告,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文件,浏览器就不会报警告,字体也可以正常显示。

 

转载于:https://www.cnblogs.com/Ericzya/p/8056293.html

user.js:1 Uncaught SyntaxError: Identifier 'isEventListenerAdded' has already been declared (at user.js:1:1) user.js:1 Uncaught SyntaxError: Identifier 'isEventListenerAdded' has already been declared (at user.js:1:1) (索引):1302 检查字体加载状态... (索引):1324 字体 WangXiZhiXingShu 宽度: 80 (索引):1324 字体 WangXiZhiQianZiWen 宽度: 80 (索引):1324 字体 WangXiZhiKaiJian 宽度: 80 (索引):1324 字体 WangXiZhiCaoShu 宽度: 80 (索引):1324 字体 LanTingTi 宽度: 80 (索引):1324 字体 WangXiZhi 宽度: 80 custom.js:2 custom.js loaded successfully custom.js:7 Found input text area, setting up auto-resize custom.js:28 Found back-to-top button, setting up event listeners custom.js:2 custom.js loaded successfully custom.js:7 Found input text area, setting up auto-resize custom.js:28 Found back-to-top button, setting up event listeners custom.js:2 custom.js loaded successfully custom.js:7 Found input text area, setting up auto-resize custom.js:28 Found back-to-top button, setting up event listeners 127.0.0.1/:1 Failed to decode downloaded font: http://127.0.0.1:8083/fonts/%E7%8E%8B%E7%BE%B2%E4%B9%8B%E8%A1%8C%E4%B9%A6%E4%BD%93.TTF 127.0.0.1/:1 OTS parsing error: cmap: Failed to serialize table :8083/api/user/font:1 Failed to load resource: the server responded with a status of 405 () user.js:199 字体设置加载失败: Error: 获取字体设置失败 at user.js:143:31 (匿名) @ user.js:199 custom.js:17 Input event triggered, adjusting height custom.js:17 Input event triggered, adjusting height custom.js:17 Input event triggered, adjusting height saveHistory.js:30 历史记录已保存 js?id=G-E03XY1VHKP:194 Failed to decode downloaded font: http://127.0.0.1:8083/fonts/%E7%8E%8B%E7%BE%B2%E4%B9%8B%E8%A1%8C%E4%B9%A6%E4%BD%93.TTF Cc @ js?id=G-E03XY1VHKP:194 js?id=G-E03XY1VHKP:194 OTS parsing error: cmap: Failed to serialize table Cc @ js?id=G-E03XY1VHKP:194 saveHistory.js:30 历史记录已保存 saveHistory.js:30 历史记录已保存
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值