Skip to content

Fonts are not loaded in IE11 with built app #4585

Description

@michaelperrin

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

fonts

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.4
Yarn: 1.6.0
npm: 5.6.0
Watchman: Not Found
Xcode: Not Found
Android Studio: Not Found

Packages: (wanted => installed)
react: ^16.4.0 => 16.4.0
react-dom: ^16.4.0 => 16.4.0
react-scripts: 1.1.4 => 1.1.4

Steps to Reproduce

  1. Create a new project with create-react-app
  2. Add a font in the src/font dir
  3. Add the necessary CSS to use this font using @font-face in index.css like in this example:
@font-face {
    font-family: 'OpenSans-Regular';
    src: url('./fonts/OpenSans/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('./fonts/OpenSans/OpenSans-Regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'OpenSans-Regular', sans-serif;
}
  1. Run yarn start and open http://localhost:3000 in Internet Explorer 11 (using a VM may be a nice idea) and check that your font is used for the text (this is the expected behavior).
  2. Stop the process and run yarn build
  3. Run the built page by running serve -s build
  4. Open http://localhost:3000 with Chrome, Firefox, etc. You will see that the used font is OpenSans
  5. Now open the same URL with Internet Explorer 11.

Expected Behavior

IE11 should display the text with the OpenSans font when the project is built.

Actual Behavior

The OpenSans font is not downloaded and the text is shown as sans-serif.

IE 11 (see how the text is rendered):

ie

Chrome:
react_app_-_font_test

Reproducible Demo

I created a repository to show the problem here: https://github.com/michaelperrin/create-react-app-font-problem.
Steps to reproduce:

  1. Clone my demo repo: git clone https://github.com/michaelperrin/create-react-app-font-problem.git
  2. Run the following commands:
 yarn global add serve
 yarn build
 serve -s build
  1. Open http://localhost:3000 with Chrome, Firefox, etc. You will see that the used font is OpenSans
  2. Now open the same URL with Internet Explorer 11 (using a VM may be a nice idea).

A few notes:

  • This is not due to the fact that you are running the project on localhost (I hosted it on a server and got the same problem).
  • This is not due to font formats (IE11 does support EOT files).
  • This happens with any font.
  • This is not due to security parameters of IE11 (font download is enabled).
  • I hope I didn't miss something and that this is an actual bug 😉

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions