Pelican plugin to minify fontawesome assets to include used icons.
git clone https://github.com/m-col/pelican-minify-fontawesome
Files | Refs | Readme

Commit 7a07c40d6da2030e9ef1d3ce3ded5bf4f82eb756
Parent: 94d36eb5c5332e8e9a1b7ff93f39db139d4bbd1f
Author: mcol <mcol@posteo.net>
Date: 2019-10-15 11:12:24 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2019-10-15 11:12:24 +0100

Select each glyph individually in each font

minify_fontawesome.py Modified

@@ -34,21 +34,23 @@
         icons.append(match[0])
 
     os.mkdir(dest)
-    icons = ['rss']
     for root, dirs, files in os.walk(source):
         for f in files:
             if f.endswith('woff'):
                 font = fontforge.open(os.path.join(root, f))
 
-                try:
-                    font.selection.select(("more",), *icons)
-                except ValueError:
-                    font.close()
-                    continue
-
-                font.selection.invert()
-                font.clear()
-                font.generate(os.path.join(dest, f))
+                selected = False
+                for icon in icons:
+                    try:
+                        font.selection.select(("more",), icon)
+                        selected = True
+                    except ValueError:
+                        pass
+
+                if selected:
+                    font.selection.invert()
+                    font.clear()
+                    font.generate(os.path.join(dest, f))
                 font.close()