url, 'https://fonts.gstatic.com/')) continue; $woff2name = sprintf('%s-%03d-%s-%s.woff2', $info->name, $info->weight, $info->style, $info->hash); $woff2path = sprintf('%s/%s', WOFF2_TARGET_FS, $woff2name); if(!is_dir(WOFF2_TARGET_FS)) mkdir(WOFF2_TARGET_FS); if(!is_file($woff2path)) file_put_contents($woff2path, file_get_contents($info->url)); $files[$info->url] = sprintf(WOFF2_TARGET_PUB, $woff2name); continue; } if(str_starts_with($line, '@font-face')) { $info = new stdClass; $info->family = null; $info->style = null; $info->weight = null; $info->hash = null; $info->url = null; continue; } if(str_starts_with($line, 'font-family:')) { $info->family = trim(substr($line, 13), "'; "); $info->name = strtolower(strtr($info->family, [' ' => '-'])); continue; } if(str_starts_with($line, 'font-style:')) { $info->style = trim(substr($line, 12), '; '); continue; } if(str_starts_with($line, 'font-weight:')) { $info->weight = (int)trim(substr($line, 13), ' '); continue; } if(str_starts_with($line, 'unicode-range:')) { $info->hash = hash('xxh3', trim(substr($line, 15), '; ')); continue; } if(str_starts_with($line, 'src: url(') && str_ends_with($line, ") format('woff2');")) { $info->url = trim(substr($line, 9, -18), '; '); continue; } } file_put_contents(CSS2_TARGET, strtr($css2, $files));