Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify all weights of all fonts used on page/site

I'm using Google webfonts. Initially, I include all the weights of a given family so I can choose all the ones I want. So for example:

  <link href='http://fonts.googleapis.com/css?family=Roboto:300,300italic,400,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet'>

Once I'm done, I only want the weights I ended up using to be fetched on page load to minimize size. My finished link looks something like

<link href='http://fonts.googleapis.com/css?family=Roboto:400,400italic,900,900italic' rel='stylesheet'>

I suppose I can scroll thru my entire CSS directory and eyeball all the pages to find all the weights I used, but that's error-prone. At a glance, how can I know exactly, which weights I ended up using?

PS: A few things I tried:

  1. Firebug's Net panel lets you see whether the google fonts script was called but does not specify which weights were used.
  2. Chengyin Liu's very nice WhatFont tool (http://chengyinliu.com/whatfont.html) but that only lets you hover over a single element.

Update April 2020

For what it's worth, I no longer use any of the solutions below, I've been using a Chrome plugin called FontsNinja for a few years and it does an amazing job of pinpointing fonts and weights used on pages.

like image 330
Heraldmonkey Avatar asked May 05 '14 07:05

Heraldmonkey


People also ask

How do I see what fonts are loaded in Chrome?

Chrome Developer tools can show you the exact rendered fonts for a given web page with just a few clicks. Right click on any element in the page and select Inspect. Next head over to the Computed tab, scroll down, and you'll quickly notice the rendered fonts for the page.

How many font weights are there?

Note that when using relative weights, only four font weights are considered — thin (100), normal (400), bold (700), and heavy (900). If a font-family has more weights available, they are ignored for the purposes of relative weight calculation.


1 Answers

As Firebug is discontinued, here's the way how to get all fonts and their weights used on a page in the Firefox DevTools:

  1. Open the DevTools (e.g. via F12)
  2. Switch to the Inspector panel
  3. Select the <html> element in there
  4. In the Inspector panel switch to the Fonts side panel
  5. Expand the All Fonts on Page panel at the bottom of it

This will show a list of all fonts used on the page. For each web font you can see the @font-face CSS rule that defines it including the font weight information.

See the following screenshot for an example: All fonts of a page in the Firefox DevTools' Inspector panel

like image 142
Sebastian Zartner Avatar answered Oct 12 '22 21:10

Sebastian Zartner