From 15d60a3a7bbaee813231845d338d15be6bc21f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 7 Mar 2021 09:45:56 +0000 Subject: [PATCH] Working on implementing unicode ranges again --- lib/metadata/policies.js | 4 ++-- lib/metadata/scoreProfileGeneric.json | 3 ++- lib/tools/redownload/redownload.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index f76c01f..8a10eca 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -875,7 +875,7 @@ var policies = { return offenders; } }, - /*"unusedUnicodeRanges": { + "unusedUnicodeRanges": { "tool": "redownload", "label": "Unused Unicode ranges", "message": "

This metric counts the number of unused Unicode ranges inside each font. For example, one font could include Cyrillic glyphs but none of them are used on the page.

It also reveals the number of ligatures (letters that are represented differently when close to each other) and hidden chars (glyphs not linked to the unicode system that can't be displayed on the web).

Because of technical limitations, Yellow Lab Tools checks each font against the glyphs of the entire page. As a result, estimated use is >= to reality. For example, if you read that 10 glyphs are \"possibly used\", it means that these 10 glyphs are used on the page but nothing guaranties that they are displayed using this font.

Tools such as Font Squirrel can remove some unicode ranges from a font.

In the case of an icon font, make sure you only keep the icons that are used on the website and to remove the others. Several tools are able to extract SVG images from a font, then some other tools can generate a font from the SVGs you want to keep.

", @@ -886,7 +886,7 @@ var policies = { "offendersTransformFn": function(offenders) { return offenders; } - },*/ + }, "nonWoff2Fonts": { "tool": "redownload", "label": "WOFF 2", diff --git a/lib/metadata/scoreProfileGeneric.json b/lib/metadata/scoreProfileGeneric.json index 14dfd0f..cc82643 100644 --- a/lib/metadata/scoreProfileGeneric.json +++ b/lib/metadata/scoreProfileGeneric.json @@ -86,7 +86,8 @@ "policies": { "fontsCount": 1, "heavyFonts": 0.5, - "nonWoff2Fonts": 0.5 + "nonWoff2Fonts": 0.5, + "unusedUnicodeRanges": 0.1 } }, "serverConfig": { diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index 82793ad..bab99ae 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -65,8 +65,8 @@ var Redownload = function() { // Prevent a bug with the font analyzer on empty pages var differentCharacters = ''; - if (data.toolsResults.phantomas.offenders.differentCharacters && data.toolsResults.phantomas.offenders.differentCharacters.length > 0) { - differentCharacters = data.toolsResults.phantomas.offenders.differentCharacters[0]; + if (data.toolsResults.phantomas.offenders.charactersCount && data.toolsResults.phantomas.offenders.charactersCount.length > 0) { + differentCharacters = data.toolsResults.phantomas.offenders.charactersCount[0]; } // Transform every request into a download function with a callback when done