37

I have downloaded FontAwesome using npm and then copied the css-file and the fonts into the right folders in the root-diretory of my electron-application using grunts copy task.

So far so good. Everything is where it is supposed to be.

Now, when i am referencing FontAwesome in my app, the icons do not get loaded. These are the errors that I get in the console:

Failed to decode downloaded font:
file:///path/to/fonts/fontawesome-webfont.woff2?v=4.4.0
OTS parsing error: Failed to convert WOFF 2.0 font to SFNT

Failed to decode downloaded font:
file:////path/to/fonts/fontawesome-webfont.woff?v=4.4.0
OTS parsing error: incorrect file size in WOFF header

Failed to decode downloaded font:
file:////path/to/fonts/fontawesome-webfont.ttf?v=4.4.0
OTS parsing error: incorrect entrySelector for table directory

I have already tried to modify FontAwesome's css file by removing all the version parameters but this does not seem to be the problem. The Issues comes up both by starting the app via electron . and when viewing the html-file in the browser.

UPDATE

To Answer some comments:

  • This problem occurrs in electron as well as in the browser (tested in chrome and firefox)
  • I am using the newest versions of both, FontAwesome (4.4.0) and Electron (0.32.1) (fresh install via npm)
  • css is loaded like: <link rel="stylesheet" type="text/css" href="css/font-awesome.css" >
8
  • assuming that you have the file in physical location on server, this issue is caused because server is not allowing files with .woff extension. you have to add .woff in allowed MIME types. In IIS , go to IIS server > your web site . click on MIME Type under IIS section and right click and add new MIME type with file name extension .woff and MIME Type text/woff
    – J Santosh
    Sep 9, 2015 at 10:01
  • 1
    @JSantosh, thx for the comment. unfortunately, the files are not on a server. they should ger deliverted with an electron app, so basically, they are locally.
    – nozzleman
    Sep 9, 2015 at 10:35
  • Do you have the same problem when you open the HTML files in a browser and not electron?
    – Yan Foto
    Sep 9, 2015 at 12:58
  • @YanFoto, Yes, this happens in electron as well as in the browser.
    – nozzleman
    Sep 9, 2015 at 12:59
  • Could you also provide the CSS snippet using to load the fonts?
    – Yan Foto
    Sep 9, 2015 at 14:18

8 Answers 8

68

I had a similar issue (perhaps this answer will help someone). I use Maven to build projects (Java + JS). Maven Filter Plugin corrupted binary font files. I had to add includes and excludes:

    <resources>
        <resource>
            <directory>${project.sources}</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>**/*.woff</exclude>
                <exclude>**/*.ttf</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>${project.sources}</directory>
            <filtering>false</filtering>
            <includes>
                <include>**/*.woff</include>
                <include>**/*.ttf</include>
            </includes>
        </resource>
    </resources>
7
  • 1
    You did well answering... It helped me with this issue. Jan 18, 2016 at 17:22
  • 2
    You don't need to download the sources again, just make a clean install of your project, and will work
    – cralfaro
    Sep 13, 2016 at 8:41
  • 9
    You can also acomplish the same using: <nonFilteredFileExtensions> <nonFilteredFileExtension>svg</nonFilteredFileExtension> <nonFilteredFileExtension>woff</nonFilteredFileExtension> <nonFilteredFileExtension>woff2</nonFilteredFileExtension> <nonFilteredFileExtension>ttf</nonFilteredFileExtension> <nonFilteredFileExtension>eot</nonFilteredFileExtension> <nonFilteredFileExtension>otf</nonFilteredFileExtension> </nonFilteredFileExtensions>
    – Monir
    Jun 5, 2017 at 19:01
  • 1
    What is the point of the second resource section with "includes"? Why is not enough to just exclude? Nov 30, 2017 at 18:36
  • 1
    @wrapperapps - AFAIK, if you'll exclude files from resources they won't get into the target build. You still have to include them BUT WITHOUT filtering.
    – Azee
    Jul 24, 2018 at 2:51
31

In my situation, Git was treating the file as a text file, and messing with its "line endings". This was corrupting the file.

Adjusting the .gitconfig to recognize *.woff files as binary, then removing the file, and adding a new copy from https://github.com/FortAwesome/Font-Awesome/raw/v4.2.0/fonts/fontawesome-webfont.woff solved the issue for me.

1
  • 3
    to treat files as binary files I had to add following lines to .gitattributes file: *.woff2 -text diff
    – Philip
    Oct 4, 2016 at 8:42
7

I faced same issue, using API Gateway to serve static font-files on Amazon S3.

I fixed it by adding */* as Binary Media Types on the AWS Console.

More information on binary media types management on https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-configure-with-console.html

2
  • I have the same issue, setting binary media types to / is not working for me. Did you just set binary media types or you also changed headers, etc.?
    – Art713
    Jan 16, 2019 at 15:56
  • I think I followed the guide and I changed Content Handling value to "convert as binary". But i'm not 100% sure and I cannot double check now.
    – piercus
    Jan 16, 2019 at 16:02
5

For some people who are deploying to IIS, adding this to web.config file (the main one, not the one inside Controller directory) might be of help.

<system.webServer>
   <staticContent>
      <remove fileExtension=".eot" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <remove fileExtension=".ttf" />
      <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
      <remove fileExtension=".svg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
    </staticContent>
</system.webServer>

3

The Problem was in my grunt-file. I tried to reproduce the issue by simply downloading all dependencies manually at their vendors websites and placed them in the corresponding script-folder of my project - suddenly it worked.

I switched to gulp now and it still works. No idea what i was doing wrong with grunt though...

3
  • 2
    For me too it was Grunt. I was mistakenly processing the font file contents as string when copying.
    – Tigran
    May 30, 2016 at 16:28
  • Oh, well this could have been my mistake too. Thanks!
    – nozzleman
    May 30, 2016 at 18:45
  • That's what my mistake was as well. I had to explicitly exclude the files from the copy processing like this: options: { process: processFiles, noProcess: ['www/**/*.{png,gif,jpg,ico,psd,svg,ttf,otf,woff,woff2,eot}']}
    – gabaum10
    Jun 28, 2016 at 14:27
1

try the following, call the font-face as the following in the beginning of your CSS file.

@font-face {
    font-family: FontAwesome;
    src: url(../fonts/fontawesome-webfont.eot?v=4.0.3);
    src: url(../fonts/fontawesome-webfont.eot?#iefix&v=4.0.3) format('embedded-opentype'), url(../fonts/fontawesome-webfont.woff?v=4.0.3) format('woff'), url(../fonts/fontawesome-webfont.ttf?v=4.0.3) format('truetype'), url(../fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular) format('svg');
    font-weight: 400;
    font-style: normal
}
1
  • Unfortunately, this didn't do the trick. btw, the only thing that changed was the version parameter. It doesn't even get processed since i try this locally. but thx anyway.
    – nozzleman
    Sep 10, 2015 at 5:19
1

If you are using the bower you could rewrite your font-face to:

@font-face {
  font-family: FontAwesome;
  src: url(font-awesome/fonts/fontawesome-webfont.eot);
  src: url(font-awesome/fonts/fontawesome-webfont.eot?#iefix) format('embedded-opentype'), 
       url(font-awesome/fonts/fontawesome-webfont.woff) format('woff'), 
       url(font-awesome/fonts/fontawesome-webfont.ttf) format('truetype'), 
       url(font-awesome/fonts/fontawesome-webfont.svg#fontawesomeregular) format('svg');
  font-weight: 400;
  font-style: normal
}
1
  • 3
    can you explain this a bit more? Sep 6, 2016 at 11:56
0

I'm sure this is solved, but this worked for me, so... I'm gonna leave this here:

I just had the same issue with a font I had used before. Turned out this was caused by a problem with FTP. The file was uploaded as text (ASCII) instead of binary, which corrupted the file. I simply re-uploaded the font files, and then it all worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.