0xf015) $name_to_code = []; if (!preg_match_all('/\.fa-([a-z0-9-]+):before\{content:"\\\\([0-9a-f]{4})"\}/i', $css, $m, PREG_SET_ORDER)) { fwrite(STDERR, "No glyph rules matched in all.min.css\n"); exit(1); } foreach ($m as $hit) { $name_to_code[$hit[1]] = hexdec($hit[2]); } // style → set of codepoints, parsed from the SVG font files $code_to_style = ['fas' => [], 'far' => [], 'fab' => []]; foreach (array_keys($code_to_style) as $style) { $file = $fonts_path . '/fa-' . ($style === 'fab' ? 'brands-400' : ($style === 'far' ? 'regular-400' : 'solid-900')) . '.svg'; $src = (string) file_get_contents($file); if (!preg_match_all('/]*unicode="&#x([0-9a-f]+);"/i', $src, $g, PREG_SET_ORDER)) { fwrite(STDERR, "No glyphs matched in {$file}\n"); exit(1); } foreach ($g as $hit) { $code_to_style[$style][hexdec($hit[1])] = true; } } $groups = ['fas' => [], 'far' => [], 'fab' => []]; foreach ($name_to_code as $name => $code) { foreach ($groups as $style => $unused) { if (!empty($code_to_style[$style][$code])) { $groups[$style][] = $name; } } } foreach ($groups as $style => $names) { sort($groups[$style], SORT_NATURAL | SORT_FLAG_CASE); } $export = var_export($groups, true); $php = <<