Guide to adding a new font to your Ember project

I am currently in the process of developing a website utilizing the MEEN Stack framework (Mongo, Ember, Express, Node). One challenge I am encountering is importing the Lato font family into my project to serve as the main font for the entire site. Despite placing the downloaded Lato font files in the public/assets/fonts directory, I'm facing difficulties with this task and have not been able to find helpful resources online. Any suggestions on how to successfully accomplish this? It may also be worth mentioning that I am incorporating Foundation into my project.

Within my app.scss file, the following code snippet can be found:

/* Webfont: Lato-SemiboldItalic */
@font-face {
    font-family: 'LatoWebSemibold';
    src: url('fonts/Lato-SemiboldItalic.eot'); /* IE9 Compat Modes */
    src: url('fonts/Lato-SemiboldItalic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('fonts/Lato-SemiboldItalic.woff2') format('woff2'), /* Modern Browsers */
         url('fonts/Lato-SemiboldItalic.woff') format('woff'), /* Modern Browsers */
         url('fonts/Lato-SemiboldItalic.ttf') format('truetype');
    font-style: italic;
    font-weight: normal;
    text-rendering: optimizeLegibility;
}

nav {
    font-family: "LatoWebSemibold";
    background-color: none;
    width:150px;
    text-align:left;
    font-size:1em;
    list-style: none;
    margin: 0 0 0 0;
    padding: 0 20 30 20;
    float:left;
}

Answer №1

It appears that the '/assets/' part is essential to include in the url

Refer to the following code snippet for a functional example

@font-face {
  font-family: 'Mytupi-Bold';
  src: url(/assets/fonts/mytupibold.ttf) format('truetype');
}

Answer №2

I recently attempted to incorporate a local font file into my ember addon.

Although Sheriffderek shared a helpful mixin here, I was continuously encountering 404 errors.

After some trial and error, I managed to resolve the issue by including the app's name at the start of the font URL.

$font-url: '/<app/addon-name>/fonts';
 
@mixin font-face($name) {
@font-face {
  font-family: $name;
  src: url("#{$font-url}/#{$name}.woff2") format("woff2"),
       url("#{$font-url}/#{$name}.woff") format("woff");
}


@include font-face('font-name-500');

body {
  font-family: 'font-name-500';
}

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

Remix is throwing a Hydration Error while trying to process data mapping

While working on my Remix project locally, I encountered a React hydration error. One thing I noticed is that the HTML rendered by the server does not match the HTML generated by the client. This issue seems to be related to the Material UI library usage. ...

Implement the geocomplete feature following an ajax event

When I click a button, it adds an input box for entering an address. To assist with auto-completion of the address, I'm using the geocomplete plugin. However, I've noticed that the geocomplete functionality only works on input boxes generated wit ...

An alternative way to adjust font size without having control over the HTML code

Is there a way to adjust the font size in a web page when only the div or iFrame is editable, not the actual HTML content? Our website allows users to upload their own ebooks, resulting in uncontrolled and complex HTML content for each chapter. We want to ...

Sort by characteristics of embedded array - Knockout

I'm struggling with filtering a nested array using Knockout. My goal is to filter the array by both 'tag-names' and 'name'. For example, searching for 'whal' should display all objects that contain a tag with that name ...

Concealing a DIV element when the value is not applicable

I'm currently working on a website for a coffee shop product. On this site, each product has a coffee strength indicator that is determined by the database. The strength can be categorized as Strong, Medium, Weak, or n/a (for non-coffee products). If ...

getting information from a JSON array using AngularJS

Looking to extract all images from the imagePath array in the following JSON. While retrieving a single image works fine, encountering difficulties when trying to fetch the entire imagePath array. Any help with this issue would be greatly appreciated. Than ...

I encountered a blank page issue when incorporating ui.bootstrap into my controller within Angular

After attempting to utilize angular bootstrap in my project, I encountered an issue where adding the dependency in my controller and starting the server with grunt serve resulted in a blank page. Take a look at the bower components in the screenshot provid ...

Generating multiple div elements within an AJAX iteration

Currently, I am retrieving data from the server side using AJAX. My goal is to populate data from a list of objects into divs but I am facing an issue where I cannot create the div while inside the foreach loop. $(document).ready(function () { var ...

The constructor window.CCapture is not valid in Node.js environment

Can anyone help me figure out how to load CCapture in Node.js without using a headless browser for recording canvas stream? Every time I try, I keep running into the error message saying "window.CCapture is not a constructor." If you are familiar with the ...

Bring in an SVG element from a separate document while retaining the CSS <style> details from the original source

Creating a number of SVG files can be made easier by keeping common symbols in one file and importing them into others. An effective method for achieving this is using the <use> element: <use href="common.svg#symbol1" /> However, th ...

Transitioning a JavaScriptIonicAngular 1 application to TypescriptIonic 2Angular 2 application

I am currently in the process of transitioning an App from JavaScript\Ionic\Angular1 to Typescript\Ionic2\Angular2 one file at a time. I have extensively researched various guides on migrating between these technologies, completed the A ...

Utilizing Data From External Sources in a React Application

I have encountered an issue with displaying data from another page in a reusable table I created using React. Specifically, I am having trouble getting the value to be shown in <TableCell> Please check out this code sandbox link for reference ACCES ...

Error: The specified file or directory does not exist at location 'D:E-commerceJsfrontend ode_modules.axios.DELETE'

As I work on my e-commerce project using vanilla JavaScript and webpack with npm, I keep encountering an issue while trying to install axios. npm ERR! enoent ENOENT: no such file or directory, rename 'D:\E-commerceJs\frontend\node_mod ...

Using select2, items can be automatically selected for an ajax call

Is it possible to configure a select2 control to automatically select an item when the ajax response contains extra data? I am looking to set up my controller to mark an item as an exact match in the JsonResult and have the select2 control automatically s ...

Having trouble integrating MaterialUI Datepicker, Dayjs, useFormik, and Yup

Currently, I am facing a recurring issue with the Material UI Date picker in conjunction with day js. The problem arises when I select a date on the calendar for the first time, it updates correctly in the text field but fails to work thereafter. Additiona ...

Managing the state in NextJS applications

I've scoured the depths of the internet in search of a solution for this issue, but unfortunately I have yet to come across one that effectively resolves it. I've experimented with various state management tools including: useContext Redux Zusta ...

Tips on serving a static file from a location other than the public or view directories following middleware in Express JS

I am organizing my files in a specific way. Inside the folder api-docs, I have an index.html file along with some CSS and JS files. My goal is to display the API documentation only for authenticated users. Since I am using Jade for views in this proje ...

I'm looking to provide the average rating of a restaurant along with the name of the owner

Currently, I am utilizing knex to craft queries for my express server. Within my database, I have two tables structured as follows: My objective is to establish a join between the two tables using the "owner_id" foreign key. Subsequently, I aim to retriev ...

Encountering an Internal Server Error while setting up a Next.js Application

I recently decided to dive into Next.js and followed the tutorial on their official website, but unfortunately, I hit a roadblock. When I run npm run dev, I encounter the following error messages in my console and terminal: Failed to load resource: the ser ...

No change in the element's text content when clicking

I'm working on creating a timer that counts down from either 15 or 30 seconds. However, I'm having trouble changing the text value when the 15 button is clicked. Can someone help me figure out what's wrong? Thank you in advance HTML <h ...