【问题标题】:OTS parsing error: Failed to convert WOFF 2.0 font to SFNT for font files of Glyphicon for Spring-bootOTS 解析错误:无法将 Glyphicon for Spring-boot 的字体文件的 WOFF 2.0 字体转换为 SFNT
【发布时间】:2019-09-16 01:11:22
【问题描述】:

在通过 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 场景。

【问题讨论】:

标签: angularjs maven spring-boot glyphicons


【解决方案1】:

似乎 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>

【讨论】:

  • 它解决了这个问题,但实际上nonFilteredFileExtensions做了什么来解决这个问题?
  • 我正在尝试将 frontend-maven-plugin 与 reactjs 一起使用。这解决了我的问题,谢谢。
【解决方案2】:

对于 angular + aws,添加: '图像/svg+xml', '字体/ttf', '字体/woff', '字体/woff2',

到 binaryMimeTypes。

【讨论】:

  • 这有助于我在 AWS Lambda 上运行基于 express 的应用程序。
  • const binaryMimeTypes = ['application/octet-stream',' font/eot', 'font/opentype', 'font/otf', 'image/jpeg', 'image/png', 'image/svg+xml', 'font/ttf', 'font/woff', 'font/woff2'] 将在 lambda.js 文件中可用
猜你喜欢
  • 2019-02-11
  • 2019-06-12
  • 2016-03-12
  • 2016-03-06
  • 2016-02-20
  • 2019-02-04
  • 2016-07-28
  • 2021-10-27
  • 2016-03-17
相关资源
最近更新 更多