Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OTS parsing error: Failed to convert WOFF 2.0 font to SFNT for font files of Glyphicon for Spring-boot

When trying to use Glyphicons with Algular inside a Spring-boot Java project created through maven, icons are not shown, and these following errors can be seen in console:

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

There are some solutions around here, but none of them considers Spring-Boot Maven scenario.

like image 290
Pranay Avatar asked Apr 26 '19 13:04

Pranay


2 Answers

It seems like Maven build resources somehow corrupts those files and Bootstrap can not decode them anymore properly, resulting in these errors. One workaround I have found is to add nonFilteredFileExtensions in maven-resources-plugin:

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

Here, we can add all extensions of font/icon files that maven is corrupting, and it should solve the issue.

Plugin section should have something like this:

<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>
like image 162
Pranay Avatar answered Sep 24 '22 15:09

Pranay


For angular + aws, add this: 'image/svg+xml', 'font/ttf', 'font/woff', 'font/woff2',

to binaryMimeTypes.

like image 39
Cerchi Avatar answered Sep 25 '22 15:09

Cerchi