function loadFont($file) { // Carica un font $font = file_get_contents($file) or die("Errore nel file font.\n"); $inf = getFontInfo($font); if (!is_array($inf)) $inf=array('ver' => 1); if (!isset($inf['max'])) $inf['max']=256; if (!isset($inf['charset'])) $inf['charset']='CP437'; if (!isset($inf['height'])) $inf['height'] = strlen($font) >=3072 ? 16: 8; // 8x256 byte = font 8x8, 16x256 byte = font 8x16. Ho messo una via di mezzo perchè alcuni file hanno roba alla fine. if (isset($inf['map'])) $inf['map'] = data2Map($inf['map']); $inf['font'] = $font; $font=null; return $inf; }
static function get_system_fonts() { $files = glob("/usr/share/fonts/truetype/*.ttf") + glob("/usr/share/fonts/truetype/*/*.ttf") + glob("/usr/share/fonts/truetype/*/*/*.ttf") + glob("C:\\Windows\\fonts\\*.ttf") + glob("C:\\WinNT\\fonts\\*.ttf") + glob("/mnt/c_drive/WINDOWS/Fonts/"); new TTF_Info(); $names = array(); foreach ($files as $file) { $info = getFontInfo($file); $info["path"] = $file; $type = $info[2]; if (preg_match("/regular|normal|medium|book/i", $type)) { $type = "normal"; } elseif (preg_match("/bold/i", $type)) { if (preg_match("/italic|oblique/i", $type)) { $type = "bold_italic"; } else { $type = "bold"; } } elseif (preg_match("/italic|oblique/i", $type)) { $type = "italic"; } $names[mb_strtolower($info[1])][$type] = $file; } $keys = array_keys($names); /*$matches = array_intersect(array("times", "times new roman"), $keys); $names["serif"] = $names[reset($matches)]; $matches = array_intersect(array("helvetica", "arial", "verdana"), $keys); $names["sans-serif"] = $names[reset($matches)]; $matches = array_intersect(array("courier", "courier new"), $keys); $names["monospace"] = $names[reset($matches)]; $names["fixed"] = $names[reset($matches)];*/ return $names; }
function getFontList($match = '') { require_once e_HANDLER . 'file_class.php'; $fl = new e_file(); if (!$match) { $match = '~^uni2cid'; } $fileList = $fl->get_files(e_PLUGIN . 'pdf/font/', $match, 'standard', 1); $fontList = array(); $intList = array(); foreach ($fileList as $v) { if (isset($v['fname']) && substr($v['fname'], -4) == '.php') { $intList[] = substr($v['fname'], 0, -4); } } unset($fileList); sort($intList); // This will guarantee that base font names appear before bold, italic etc foreach ($intList as $f) { if (substr($f, -2) == 'bi') { $fontList[substr($f, 0, -2)]['bi'] = $f . '.php'; } elseif (substr($f, -1) == 'i') { $fontList[substr($f, 0, -1)]['i'] = $f . '.php'; } elseif (substr($f, -1) == 'b') { $fontList[substr($f, 0, -1)]['b'] = $f . '.php'; } else { // Must be base font name $fontList[$f]['base'] = $f . '.php'; } } // Now get the info on each font. foreach ($fontList as $font => $info) { $fontList[$font]['info'] = getFontInfo($info['base']); } //print_a($fontList); return $fontList; }