$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How do I install a custom local font?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How do I install a custom local font?

matteradmin8PV0评论

I am trying to install a custom local font but it doesn't look like it's working.

style.css:

@font-face {
  font-family: "TTNorms";
  src: url("./fonts/TTNorms.eot");
  src: url("./fonts/TTNorms.eot?#iefix") format("embedded-opentype"),
    url("./fonts/TTNorms.woff2") format("woff2"),
    url("./fonts/TTNorms.woff") format("woff"),
    url("./fonts/TTNorms.ttf") format("truetype"),
    url("./fonts/TTNorms.svg#TTNorms-Regular") format("svg");
  font-weight: normal;
  font-style: normal;
}

My fonts folder:

fonts
├── TTNorms-Regular.eot
├── TTNorms-Regular.svg
├── TTNorms-Regular.ttf
├── TTNorms-Regular.woff
├── TTNorms-Regular.woff2

However, when I try to set any element's font-family: "TTNorms" it doesn't work. What am I doing wrong?

I am trying to install a custom local font but it doesn't look like it's working.

style.css:

@font-face {
  font-family: "TTNorms";
  src: url("./fonts/TTNorms.eot");
  src: url("./fonts/TTNorms.eot?#iefix") format("embedded-opentype"),
    url("./fonts/TTNorms.woff2") format("woff2"),
    url("./fonts/TTNorms.woff") format("woff"),
    url("./fonts/TTNorms.ttf") format("truetype"),
    url("./fonts/TTNorms.svg#TTNorms-Regular") format("svg");
  font-weight: normal;
  font-style: normal;
}

My fonts folder:

fonts
├── TTNorms-Regular.eot
├── TTNorms-Regular.svg
├── TTNorms-Regular.ttf
├── TTNorms-Regular.woff
├── TTNorms-Regular.woff2

However, when I try to set any element's font-family: "TTNorms" it doesn't work. What am I doing wrong?

Share Improve this question asked Dec 7, 2018 at 22:09 bigpotatobigpotato 3352 gold badges6 silver badges17 bronze badges 2
  • 1 Your filenames are wrong. :) For example in your CSS you're asking for "TTNorms.eot" but in your fonts folder the file is actually called "TTNorms-Regular.eot". – WebElaine Commented Dec 7, 2018 at 22:24
  • omg... I'm an idiot. It works after changing them!!!!! – bigpotato Commented Dec 7, 2018 at 22:34
Add a comment  | 

1 Answer 1

Reset to default 0

It's probably how you're referencing the fonts from the css. Assuming "style.css" and "fonts" directories are on the same level, your code should work. Are you using a bundler (Webpack or Gulp)? Either could resolve your issue quickly.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far