angularjs - OTS将Glyphicon的字体文件的: Failed to convert WOFF 2. 0字体错误解析为SFNT,用于Spring-boot

标签 angularjs maven spring-boot glyphicons

尝试在通过maven创建的Spring-boot Java项目中使用带有Glyphicons的Algular时,未显示图标,并且可以在控制台中看到以下错误:

Failed to decode downloaded font: <URL> ..
OTS parsing error: Failed to convert WOFF 2.0 font to SFNT
OTS parsing error: incorrect file size in WOFF header
OTS parsing error: incorrect entrySelector for table directory

这里有一些解决方案,但是都没有考虑Spring-Boot Maven方案。

最佳答案

似乎Maven构建资源以某种方式破坏了这些文件,并且Bootstrap无法再对其进行正确解码,从而导致这些错误。
我发现一种解决方法是在maven-resources-plugin中添加nonFilteredFileExtensions:

<configuration>
    <nonFilteredFileExtensions>
    <nonFilteredFileExtension>ttf</nonFilteredFileExtension>
    <nonFilteredFileExtension>woff</nonFilteredFileExtension>
    <nonFilteredFileExtension>woff2</nonFilteredFileExtension>
    <nonFilteredFileExtension>eot</nonFilteredFileExtension>
    <nonFilteredFileExtension>svg</nonFilteredFileExtension>
    </nonFilteredFileExtensions>
 </configuration>

在这里,我们可以添加maven损坏的所有字体/图标文件扩展名,它应该可以解决问题。

插件部分应具有以下内容:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>ttf</nonFilteredFileExtension>
            <nonFilteredFileExtension>woff</nonFilteredFileExtension>
            <nonFilteredFileExtension>woff2</nonFilteredFileExtension>
            <nonFilteredFileExtension>eot</nonFilteredFileExtension>
            <nonFilteredFileExtension>svg</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>

关于angularjs - OTS将Glyphicon的字体文件的: Failed to convert WOFF 2. 0字体错误解析为SFNT,用于Spring-boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55868995/

相关文章:

html - 如何使用 ng-click 功能更改按钮颜色?

javascript - Angular 图表上的重叠图例 Piechart

java - Groovy 和 maven - 从 src/main/groovy 编译源代码

java - Artifactory:我可以避免 War 和 Zip Artifact 的嵌入冗余吗?

java - Dockerized Spring Boot 无法在 Raspberry Hyperiot OS + Gitlab CI + Spring Boot 上运行

ajax - 拦截器和 transformResponse 之间的确切区别是什么?

javascript - HTML/JavaScript 应用程序的 LDAP 身份验证

java - 使用 maven 生成一个包含所有依赖项的 xml 文件

reactjs - 使用 React UI 和 Spring Boot 服务器实现用户搜索的建议

java - 组织.hibernate.HibernateException : Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set