react js averta fonts not working in safari staging deployement

Issue with Averta Fonts not working in Safari Staging Deployment using ReactJS

As a web developer who primarily works with ReactJS, I have come across several instances where certain fonts do not work properly in certain browsers. Recently, I faced an issue where Averta Fonts were not working in Safari during the staging deployment of a ReactJS project.

Possible reasons for fonts not loading in Safari during staging deployment

  • The font files may not have been included properly in the project.
  • There could be an issue with the CSS file where the font is being called.
  • The font may not be compatible with Safari browser.
  • The font files may have been corrupted.

After analyzing the possible reasons, I found out that the issue was with the CSS file where the font was being called. The CSS file had a syntax error which was causing the font not to load properly in Safari during staging deployment.

Solution to fix the issue

To fix this issue, I made the following changes in the CSS file:


@font-face {
    font-family: 'Averta';
    src: url('../fonts/AvertaRegular.woff2') format('woff2'),
         url('../fonts/AvertaRegular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'Averta', sans-serif;
}

As you can see, I included the font files in the correct path and also made sure that the font-family name and path to the font files were correct.

After making these changes, I deployed the project again and checked it in Safari. The Averta Fonts were loading properly without any issues.

Alternate solution to fix the issue

If the above solution does not work, you can try using a web font loader like FontFaceObserver. This library helps to load web fonts asynchronously and ensures that the font is loaded properly before it is used.

Here is an example of how to use FontFaceObserver:


const font = new FontFaceObserver('Averta');

font.load().then(() => {
  document.documentElement.classList.add('averta-font-loaded');
});

After including the above code in your project and making sure that the CSS file is correct, you can deploy your project again and check if the font is loading properly in Safari.

In summary, when Averta Fonts are not working in Safari during the staging deployment of a ReactJS project, it could be due to various reasons such as incorrect path to font files, syntax errors in CSS file, font compatibility issues with Safari, or corrupted font files. To fix this issue, you can check the CSS file for any syntax errors or use a web font loader like FontFaceObserver to ensure that the font is loaded properly before it is used.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe