The fonts appear differently when working on a Mac but show up as Times New Roman when displayed on Windows in development

Currently, I am utilizing react combined with nextjs for server-side rendering and bootstrap. Within my component, I have integrated bootstrap via a CDN:

<Head>
      <title>{title}</title>
      <meta charSet="utf-8" />
      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <link
        rel="stylesheet"
        href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
      />


      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" />
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" />
   </Head>

At this point, in my navbar, I am using the Montserrat font via style jsx which is NextJS's method for altering CSS:

import Link from "next/link";

class Navbar extends React.Component {
  render() {
    return (
      <div>
        <nav
          className="navbar navbar-light navbar-expand-lg fixed-top bg-secondary text-uppercase"
          id="mainNav"
        >
          <Link href="/">
            <a className="navbar-brand js-scroll-trigger ">Navbar</a>
          </Link>
          <button
            className="navbar-toggler"
            type="button"
            data-toggle="collapse"
            data-target="#navbarResponsive"
            aria-controls="navbarResponsive"
            aria-expanded="false"
            aria-label="Toggle navigation"
          >
            <span className="navbar-toggler-icon" />
          </button>

          <div className="collapse navbar-collapse" id="navbarResponsive">
            <ul className="navbar-nav ml-auto">
              <li className="nav-item mx-0 mx-lg-1">
                <Link href="/about">
                  <a className="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger">
                    Blog
                  </a>
                </Link>
              </li>
              <li className="nav-item mx-0 mx-lg-1">
                <a
                  className="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"
                  href="#"
                >
                 More
                </a>
              </li>
              <li className="nav-item mx-0 mx-lg-1">
                <a
                  className="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"
                  href="#"
                >
                 About
                </a>
              </li>
            </ul>
          </div>
        </nav>

        <style jsx>{`
          @media (min-width: 992px) {
            #mainNav {
              padding-top: 0.5rem;
              padding-bottom: 0.5rem;
              transition: padding-top 0.3s, padding-bottom 0.3s;
            }
          }

          .navbar-light .navbar-brand {
            color: white;
            font-weight: bold;
            font-family: Montserrat;
            font-size: 130%;
          }
          .navbar-light .navbar-nav .nav-link {
            color: white;
            font-family: Montserrat;
            font-size: 90%;
            font-weight: bold;
          }
          .bg-secondary {
            background-color: #2c3e50 !important;
          }
        `}</style>
      </div>
    );
  }
}

export default Navbar;

To streamline my workflow, I've employed docker to containerize the entire project on my Mac, enabling me to seamlessly switch between operating systems as needed. While everything operates smoothly, I'm encountering an issue where fonts do not display correctly on Mac. After researching on Stackoverflow, it seems that Chrome defaults to Times New Roman if it fails to locate Google fonts. This leaves me wondering why this disparity exists since I've loaded bootstrap, assuming all fonts should be accessible, just like on Mac. Any insights or suggestions would be greatly appreciated.

Thank you in advance!

Answer №1

Encountered an issue with Montserrat font not being installed on my Windows computer, prompting me to manually import the font family into the project. Despite attempting to do so correctly using nextjs, it initially did not work as expected. Fortunately, after troubleshooting, I have successfully resolved the issue and the font now displays correctly on my local machine.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to update state in ReactJS

Seeking help to understand where I might be going wrong with my code. The first console output is correct, but when I try to set the state using Firebase, it returns undefined. return firebase.database().ref('Users/Trainers/').on('value&apo ...

What are some ways to adjust red and green blocks using CSS?

One question that arises is how to create a version of a webpage where only the yellow block can slide up, while the red and green blocks remain fixed. Currently, the green block is treated with the following CSS: position:sticky; right:0px; top:100px; ...

Error: The function `supabase.from` is not accessible

I've been working on integrating Supabase with my Next.js application, but I'm encountering an issue during the initialization process. Here's the setup for Supabase: utils/supabase/server.js 'use server' import { createServerCl ...

Nextjs exposes a bug in react-bootstrap's navbar component

After integrating react-bootstrap with nextjs, I encountered a strange issue with the NavBar component. The problem arises when I first load the navbar - everything appears as expected, https://i.stack.imgur.com/R9guE.png but upon refreshing the page, CS ...

How to place an image in the bottom right corner using CSS

Does anyone know how to position an image in the bottom right corner of a div? I have tried using margin-right and padding-right with 0px on the img tag, but it does not seem to work. The black lines indicate that I do not need that space Here is my Cod ...

React maintains the state of just a single element within an array at a time

I'm faced with a roadblock while developing my covid19 application. The app should display a list of countries on the left side of the screen, allowing users to add any number of countries to the right side for more detailed covid data. I'm still ...

Tips for employing 'live CSS' in Rails

As someone who is new to Ruby on Rails, I am currently facing a challenge. I want to extract data from specific fields in my database and utilize them for styling purposes. For instance, within my 'Student' database, there are height and width f ...

fixed divs that remain in place while scrolling

In the past, I have implemented a method similar to this: However, I am not a fan of the "flicker" effect that occurs when the page is scrolled and the div needs to move along with it. Recently, I have come across websites where certain elements (such as ...

Manipulating the actual DOM in ReactJS to display a formatted number or string while preserving its original value

Hello, I am new to ReactJS and currently using it along with ReactDataGrid. I am trying to figure out how to change the real DOM value of a specific cell in the table. Here is the table I am working with: https://i.sstatic.net/CAcSH.png My goal is to cha ...

The MS Teams Tab Application fails to close the Admin Permissions Consent window in the Desktop/ Mac Teams application

I am currently developing a Microsoft Teams Tab application by referencing this informative link: https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/what-are-tabs. Within my application, I have the requirement to initiate the admin permissions ...

css and HTML tutorial: Centering a DIV element with CSS styles

I have exhausted all similar questions and solutions, but nothing seems to work for me. My goal is to center a DIV element using CSS, and I've tried options like text-align, margin auto, and inline-block with no success. The example code I am experime ...

Creating custom styles with makeStyles in Material UI

How can I properly write the following CSS value as a string in a makeStyles function within Material UI? background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.8)), url(../assets/pexels-pixabay-41949.jpg), I attempted to do it this way but i ...

JQuery: Techniques for accessing the assigned font of an element

Can the assigned font of an element be retrieved using jQuery? For example, if there is this CSS: #element { font-family: blahblah,Arial; } In the above case, the Arial font will be assigned to #element. Is it possible to extract that information using ...

What is the process for adjusting the color of a particular date in the <input type=Date> field?

Is there a way to modify the styling, such as color, of the input type date in HTML 5? In HTML 5, we can display a calendar using <input type=date>. For example, if March 23rd is a holiday and I want to highlight this specific date in red, how can I ...

Facing Issue with NextJS 13 App: Images Fail to Load When Accessed via GitHub Pages Route

Attempting to host a basic NextJS 13 website on GitHub pages has revealed some strange behavior that appears to only affect Safari users (both iOS and MacOS). Upon initial loading, the images appear correctly. However, as I navigate between routes, I enco ...

Accessing server-side cookies in an Axios interceptor and beyond the getServerSideProps() method

Within my Next.js application, I have organized my axios interceptors in a separate file. In the getServerSideProps() function, I am sending a request that requires an Authorization header with a specific access token. Although I am handling the headers ...

Solutions for resolving the error "Unable to access property 'value1' because it is undefined"

constructor() { super(); this.state = { value1 : Math.floor(Math.random() * 100), value2 : Math.floor(Math.random() * 100), value3 : Math.floor(Math.random() * 100), proposedAnswer : Math.floor(Math.random() * 3) + this.state.value1 + t ...

Tips for accessing the values of fields in React Material UI components

When I console log the object, it shows: { "week":undefined, "name":undefined, "code":undefined } Additionally, is it appropriate to wrap all Material UI components in a form tag and treat the entire code as a form? Here is ...

The use of JQuery repeating fields can cause disruptions to the Bootstrap layout when removing rows

I have been struggling with a form that contains multiple fields that need to be repetitive. My current code is functional, but I'm encountering an issue where clicking on any remove button other than the first one causes the fields in the row to rear ...

Assets from React and Symfony are being blocked due to the loading of mixed active

I've been trying to find a solution to this problem but haven't been successful so far, hence why I'm posting this question. It's strange because I know I've dealt with this issue before and got it working, but now I keep getting a ...