尝试在通过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/