Skip to content
the poor coder

react js averta fonts not working in safari staging deployement

Poor Man
Published
Reading time
2 min read
On this page

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:

CSS

@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:

JavaScript

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.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC