$fontname = mb_strtolower($style["family"]); $families = Font_Metrics::get_font_families(); $entry = array(); if (isset($families[$fontname])) { $entry = $families[$fontname]; } $local_file = DOMPDF_FONT_DIR . md5($remote_file); $cache_entry = $local_file; $local_file .= ".ttf"; $style_string = Font_Metrics::get_type("{$style['weight']} {$style['style']}"); if (!isset($entry[$style_string])) { $entry[$style_string] = $cache_entry; Font_Metrics::set_font_family($fontname, $entry); // Download the remote file if (!is_file($local_file)) { file_put_contents($local_file, file_get_contents($remote_file)); } $font = Font::load($local_file); if (!$font) { return false; } $font->parse(); $font->saveAdobeFontMetrics("{$cache_entry}.ufm"); // Save the changes Font_Metrics::save_font_families(); } return true; } } Font_Metrics::load_font_families();