Explorar o código

Working on implementing unicode ranges again

Gaël Métais %!s(int64=4) %!d(string=hai) anos
pai
achega
15d60a3a7b

+ 2 - 2
lib/metadata/policies.js

@@ -875,7 +875,7 @@ var policies = {
             return offenders;
         }
     },
-    /*"unusedUnicodeRanges": {
+    "unusedUnicodeRanges": {
         "tool": "redownload",
         "label": "Unused Unicode ranges",
         "message": "<p>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.</p><p>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).</p><p>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.</p><p>Tools such as <a href=\"https://www.fontsquirrel.com/tools/webfont-generator\" target=\"_blank\">Font Squirrel</a> can remove some unicode ranges from a font.</p><p>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.</p>",
@@ -886,7 +886,7 @@ var policies = {
         "offendersTransformFn": function(offenders) {
             return offenders;
         }
-    },*/
+    },
     "nonWoff2Fonts": {
         "tool": "redownload",
         "label": "WOFF 2",

+ 2 - 1
lib/metadata/scoreProfileGeneric.json

@@ -86,7 +86,8 @@
             "policies": {
                 "fontsCount": 1,
                 "heavyFonts": 0.5,
-                "nonWoff2Fonts": 0.5
+                "nonWoff2Fonts": 0.5,
+                "unusedUnicodeRanges": 0.1
             }
         },
         "serverConfig": {

+ 2 - 2
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