['timeout' => 3]])); if ($stream === false) { throw new RuntimeException('Unable to read a private candidate font.'); } $headers = stream_get_meta_data($stream)['wrapper_data'] ?? []; $body = stream_get_contents($stream); fclose($stream); $woff2 = str_ends_with($font, '.woff2'); $type = $woff2 ? 'font/woff2' : 'font/woff'; if (! is_string($body) || ! str_starts_with($body, $woff2 ? 'wOF2' : 'wOFF') || ! in_array('Content-Type: '.$type, $headers, true) || hash('sha256', $body) !== hash_file('sha256', $font)) { throw new RuntimeException('A candidate font is missing, corrupted or served with an invalid MIME type.'); } } echo json_encode(['private_font_regression_passed' => true, 'fonts' => count($fonts)], JSON_THROW_ON_ERROR).PHP_EOL;