Having trouble displaying font within a Stylus-defined class using @font-face in Chrome

I am currently running a MEAN application with Angular2 on the frontend and using Stylus-based CSS for styling.

After compiling, the resources are organized in the following folder structure:

  • dist
    • backend
    • frontend
    • resources
      • font.woff
      • font.woff2
      • general.css (compiled styles)

The general.css file is compiled from general.styl, which contains:

@font-face
  font-family: retro-computer;
  src: url(font.woff2) format(woff2);
  src: url(font.woff) format(woff);

nav {
  border-width: 10px;
  border-style: solid;
  font-family: retro-computer;
}

The fonts' relative location seems to be correct as they are in the same folder as the CSS file.

To ensure the fonts are accessible across the server, I have defined the static path correctly in app.ts in the backend:

private config() {
  this.app.set("views", path.join(__dirname, "..", "frontend", "views"));
  this.app.set("view engine", "hbs");

  this.app.use("/scripts", express.static(path.join(__dirname, "..", "frontend")));
  this.app.use("/node_modules", express.static(path.join(__dirname, "..", "..", "node_modules"))); 
  this.app.use("/resources/styles", express.static(path.join(__dirname, "..", "resources", "styles"))); //<-- THIS
}

When attempting to access the font from http://localhost:8000/resources/styles/font.woff, it works fine and the font is downloaded by the browser.

The generated CSS is also successfully applied to the home page in the Angular2 app. However, there seems to be an issue with rendering the font in Chrome (works fine in Microsoft Edge but not yet tested in Firefox).

I have tried adjusting the paths in the stylus and CSS files, but the problem with the font rendering persists. Any insights on what I might be doing wrong would be greatly appreciated.

Thank you!

Answer №1

Aha, I've identified the issue! Chrome appears to be quite particular about quotation marks in CSS, but using " for the format did the trick.

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

I need assistance from someone knowledgeable in HTML and CSS. I am trying to create a div that dynamically increases its width until it reaches a specific

Seeking assistance to create a dynamic div that continuously expands its width until it reaches a maximum of 540px. It should start at 75px. Below is the HTML and CSS code I've attempted: .Loading-Screen { background-color: black; color: alicebl ...

encountering problems with error messages during form field validation in Express.js

When encountering validation errors, I would like to display the appropriate error message on the same jade page (i.e register.jade). If no errors occur, then I want to successfully store the data using the schema object and return to the home page. Howeve ...

Align two child elements vertically in the center using flexbox

I require your assistance; I have been attempting to center the text vertically within this div, but all my efforts thus far have been unsuccessful. I have included the default layout for reference. While using padding may offer a solution, I believe that ...

Encountering a SyntaxError: Unexpected token '?' error while utilizing the 'express-rate-limit' package

I am encountering an issue while trying to implement 'express-rate-limit' in my code. Strangely, when I run the server, I receive a SyntaxError: Unexpected token '?', even though I have double-checked that there are no syntax errors in ...

Alter the color scheme using jQuery

Exploring the world of websites, I've come across many with a unique color switch feature. Users have the ability to choose a color, and the entire page transforms to match their selection. Check out these links for some examples... http://csmthe ...

Identify the browser dimensions and implement CSS styling for all screen resolutions

I am currently facing an issue with a function that I have created to apply CSS changes to a menu based on browser resizing and different resolutions. The problem lies in the fact that my function does not seem to be correctly interpreted by the browser. W ...

Tips for creating a custom Angular Material modal window that is fully responsive to its parent modal window

Hey there! I've put together a custom modal window in Angular Material by combining the custom modal window example with the Angular Material slider demo. Everything is working well except for the fact that the sliders inside the modal window are not ...

How to efficiently center and adjust the size of a div-wrapper containing multiple responsive divs

I could use some assistance with this particular issue. What's been successful so far: I have a large div within my body (and also inside main, for css-related reasons), housing eight smaller divs divided into four columns. I've applied float:l ...

How to implement a Django block for loading CSS files

I have multiple pages and I need to load unique CSS for each page. I am using this method for all static files. In the head of my index.html file, I have the following code: {% block css %} {% endblock %} However, in my contact.html file, I have the fol ...

Creating an Art Deco inspired border using CSS

I am interested in creating a border effect using only CSS. Here is an image of the effect I am looking to achieve: https://i.sstatic.net/cKWXZm.jpg I would like to achieve this effect without adding additional div elements. Any suggestions or tips on how ...

Toggle visibility of div elements in a list

Users have the option to either download a file by clicking on "download" or view it as a PNG in their browser by clicking "open". I found a solution on this platform for creating a show/hide toggle function. It worked well for one item, but I'm look ...

How to center a div both vertically and horizontally within a flex-fill using Bootstrap 4

Hello there! I am currently using Bootstrap 4 and the layout I have implemented seems to be working fine as all my pages start from the top. However, now I am trying to center the elements. <style> body, wrapper { min-height: 100vh; ...

Modifying the font style and color of text within the table header - Material Table version 0.19.4

Recently, I began using React and Material UI but have encountered an issue with modifying the color and font of text in the table header. Despite attempting to override it, the default style remains unchanged. It has been mentioned that utilizing "heade ...

Sustaining the hover effect background color when hovering over submenu options

I am currently working on a navigation menu that includes list items a, b, c, d, e, f. One issue I am facing is when a user hovers over the list item d, the submenu items like d1, d2, d3, d4, and d5 appear within the d section. However, the background col ...

I am curious about the significance of ":op?" in a URL route

Reviewing some Node.js Express code, I came across the following route list: app.all('/user/:id/:task?', user.load); app.get('/user/:id', user.view); app.get('/user/:id/view', user.view); app.get('/user/:id/edit', u ...

I have successfully configured the div to show only one at a time, however, I am currently facing an issue with turning off the div

My goal is to disable all annotations within a specific div class and then enable just one particular ID afterwards. This method is meant to ensure that only one annotation can be open at any given time. However, I have encountered an issue with the Javasc ...

The pictures in a <div> tag are not showing up

Functionality: I have set up 2 different <div> elements with unique IDs. Each of these <div> elements will make an ajax call to fetch a specific set of images for display. To summarize, both <div> elements are invoking the same ajax met ...

An array of tooltips linked to specific areas on an image using

Hello, I have created an imagemap with area polygons that display tooltips when the mouse hovers over them. Additionally, there is a legend at the bottom of the image map. My goal is to show the tooltip on the specific polygon area when the mouse is hove ...

What steps should I take to fix a nexe compiler error with code 2?

I've been facing issues while trying to compile my node server using nexe (3.3.2). Initially, I was prompted to use the --build flag which I added to my script. However, even after the process restarted, it compiled for more than two hours only to fai ...

Detecting file changes in ExpressJS after writing data to a file.This

I'm facing an issue with my endpoints. One endpoint is responsible for writing JSON data to a static file, while another endpoint is supposed to retrieve and send that data. The problem arises when I make changes to the file but the endpoint still sen ...