Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The browser won't make a request for every webfont although they're all in the CSS

I am using the midnight theme for Jekyll. Jekyll is currently v3.7.4

My theme refers to the bundled OpenSans webfont, and I have also added FontAwesome. But the browser only ever makes a request for the OpenSans fonts, and never for the FontAwesome file.

In my page's head (compiled):

  <!-- theme -->
  <link rel="stylesheet" href="/assets/css/style.css?v=e16a158">
  <!-- theme overrides -->
  <link rel="stylesheet" href="/assets/css/hello.css?v=e16a158">

Not compiled:

  <!-- theme -->
  <link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.data['hash'] | relative_url }}">
  <!-- theme overrides -->
  <link rel="stylesheet" href="{{ '/assets/css/hello.css?v=' | append: site.data['hash'] | relative_url }}">

hello.scss is where I have my custom styles. The first two lines are these as per the FontAwesome instructions:

---
---
@import "./vendor/fontawesome/fontawesome.scss";
@import "./vendor/fontawesome/brands.scss";

The compiled CSS (served at /assets/css) includes this:

@charset "UTF-8";
/*!
 * Font Awesome Free 5.13.0 by @fontawesome - https://fontawesome.com
 * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
 */

@font-face {
  font-family: 'Font Awesome 5 Brands';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("../fonts/fa-brands-400.eot");
  src: url("../fonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-brands-400.woff2") format("woff2"), url("../fonts/fa-brands-400.woff") format("woff"), url("../fonts/fa-brands-400.ttf") format("truetype"), url("../fonts/fa-brands-400.svg#fontawesome") format("svg"); }
.fab {
  font-family: 'Font Awesome 5 Brands';
  font-weight: 400; }

GETting /assets/fonts/fa-brands-400.woff works:

$ http :8888/assets/fonts/fa-brands-400.woff
HTTP/1.1 200 OK
cache-control: private, max-age=0, proxy-revalidate, no-store, no-cache, must-revalidate
connection: close
content-length: 89824
content-type: application/font-woff; charset=utf-8
date: Sun, 19 Apr 2020 08:26:19 GMT
etag: 3011a2-15ee0-5e9b582b
last-modified: Sat, 18 Apr 2020 19:42:35 GMT
server: WEBrick/1.4.2 (Ruby/2.6.2/2019-03-13)



+-----------------------------------------+
| NOTE: binary data not shown in terminal |
+-----------------------------------------+

And yet when I access the site in any browser (tried Firefox, Chrome on Linux and Safari on iOS), it doesn't even try to make a request for the FontAwesome font files:

Firefox's network activity: no request for fa-brands-*

Interestingly, the OpenSans font files are referred like this in the compiled CSS and that is fine for the browser to initiate the request:

@font-face {
  font-family: 'OpenSansLight';
  src: url("../fonts/OpenSans-Light-webfont.eot");
  src: url("../fonts/OpenSans-Light-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-Light-webfont.woff") format("woff"), url("../fonts/OpenSans-Light-webfont.ttf") format("truetype"), url("../fonts/OpenSans-Light-webfont.svg#OpenSansLight") format("svg");
  font-weight: normal;
  font-style: normal; }
@font-face {
  font-family: 'OpenSansLightItalic';
  src: url("../fonts/OpenSans-LightItalic-webfont.eot");
  src: url("../fonts/OpenSans-LightItalic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-LightItalic-webfont.woff") format("woff"), url("../fonts/OpenSans-LightItalic-webfont.ttf") format("truetype"), url("../fonts/OpenSans-LightItalic-webfont.svg#OpenSansLightItalic") format("svg");
  font-weight: normal;
  font-style: normal; }
@font-face {
  font-family: 'OpenSansRegular';
  src: url("../fonts/OpenSans-Regular-webfont.eot");
  src: url("../fonts/OpenSans-Regular-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-Regular-webfont.woff") format("woff"), url("../fonts/OpenSans-Regular-webfont.ttf") format("truetype"), url("../fonts/OpenSans-Regular-webfont.svg#OpenSansRegular") format("svg");
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased; }
@font-face {
  font-family: 'OpenSansItalic';
  src: url("../fonts/OpenSans-Italic-webfont.eot");
  src: url("../fonts/OpenSans-Italic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-Italic-webfont.woff") format("woff"), url("../fonts/OpenSans-Italic-webfont.ttf") format("truetype"), url("../fonts/OpenSans-Italic-webfont.svg#OpenSansItalic") format("svg");
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased; }
@font-face {
  font-family: 'OpenSansSemibold';
  src: url("../fonts/OpenSans-Semibold-webfont.eot");
  src: url("../fonts/OpenSans-Semibold-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-Semibold-webfont.woff") format("woff"), url("../fonts/OpenSans-Semibold-webfont.ttf") format("truetype"), url("../fonts/OpenSans-Semibold-webfont.svg#OpenSansSemibold") format("svg");
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased; }
@font-face {
  font-family: 'OpenSansSemiboldItalic';
  src: url("../fonts/OpenSans-SemiboldItalic-webfont.eot");
  src: url("../fonts/OpenSans-SemiboldItalic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-SemiboldItalic-webfont.woff") format("woff"), url("../fonts/OpenSans-SemiboldItalic-webfont.ttf") format("truetype"), url("../fonts/OpenSans-SemiboldItalic-webfont.svg#OpenSansSemiboldItalic") format("svg");
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased; }
@font-face {
  font-family: 'OpenSansBold';
  src: url("../fonts/OpenSans-Bold-webfont.eot");
  src: url("../fonts/OpenSans-Bold-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-Bold-webfont.woff") format("woff"), url("../fonts/OpenSans-Bold-webfont.ttf") format("truetype"), url("../fonts/OpenSans-Bold-webfont.svg#OpenSansBold") format("svg");
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased; }
@font-face {
  font-family: 'OpenSansBoldItalic';
  src: url("../fonts/OpenSans-BoldItalic-webfont.eot");
  src: url("../fonts/OpenSans-BoldItalic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/OpenSans-BoldItalic-webfont.woff") format("woff"), url("../fonts/OpenSans-BoldItalic-webfont.ttf") format("truetype"), url("../fonts/OpenSans-BoldItalic-webfont.svg#OpenSansBoldItalic") format("svg");
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased; }

_config.yml:

# Site config
defaults:
  -
    scope:
      path: "" # empty string means everywhere
      type: "pages"
    values:
      layout: "default"

author: "64b.it"
title: "64b.it | custom-built software"
description: "We deliver custom-built software to maximize your business' ROI."
repo: "https://github.com/coaxial/hello"
# Jekyll config
theme: jekyll-theme-midnight
markdown: kramdown
include:
  - assets/vendor/fontawesome
exclude:
  - Gemfile
  - Gemfile.lock

What is going on? Why can't I get the browser to even request the FontAwesome font files when OpenSans works fine?

You can poke around at this Netlify deploy if more details are needed: https://5e9c012d3f93e40006beb655--hello-64bit.netlify.app/ and the code revision this corresponds to: https://github.com/coaxial/hello/tree/e16a1580af9396c8cf2cfafa4944edb86982180a

like image 643
Pierre Avatar asked Apr 19 '20 08:04

Pierre


People also ask

How can I add font in HTML?

To change font size in HTML, use the CSS font-size property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.


1 Answers

I clicked this link: https://5e9c012d3f93e40006beb655--hello-64bit.netlify.app/

Your HTML (line 71) reads:

<i class="fa fa-twitter"></i>

And your hello.css (parsed, line 4512) reads:

.fab {
  font-family:'Font Awesome 5 Brands';
  font-weight:400
} 

Obviously you need to change line 71 to:

<i class="fab fa-twitter"></i>

Happy coding!

like image 99
JoostS Avatar answered Nov 15 '22 06:11

JoostS