font_collections.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* This script prints out details of any TrueType collection font files
  3. in your font directory. Files ending wih .otc are examined.
  4. Point your browser to
  5. http://your.domain/your_path_to _mpdf/utils/font_collections.php
  6. By default this will examine the folder /ttfonts/ (or the default font
  7. directory defined by _MPDF_TTFONTPATH.
  8. You can optionally define an alternative folder to examine by setting
  9. the variable below (must be a relative path, or filesystem path):
  10. */
  11. $checkdir = '';
  12. //////////////////////////////////
  13. //////////////////////////////////
  14. //////////////////////////////////
  15. ini_set("memory_limit","256M");
  16. define('_MPDF_PATH','../');
  17. include("../mpdf.php");
  18. $mpdf=new mPDF('');
  19. if ($checkdir) {
  20. $ttfdir = $checkdir;
  21. }
  22. else { $ttfdir = _MPDF_TTFONTPATH; }
  23. $mqr=ini_get("magic_quotes_runtime");
  24. if ($mqr) { set_magic_quotes_runtime(0); }
  25. if (!class_exists('TTFontFile', false)) { include(_MPDF_PATH .'classes/ttfontsuni.php'); }
  26. $ttf = new TTFontFile();
  27. $ff = scandir($ttfdir);
  28. echo '<h3>Font collection files found in '.$ttfdir.' directory</h3>';
  29. foreach($ff AS $f) {
  30. $ret = array();
  31. if (strtolower(substr($f,-4,4))=='.ttc' || strtolower(substr($f,-4,4))=='.ttcf') { // Mac ttcf
  32. $ttf->getTTCFonts($ttfdir.$f);
  33. $nf = $ttf->numTTCFonts;
  34. echo '<p>Font collection file ('.$f.') contains the following fonts:</p>';
  35. for ($i=1; $i<=$nf; $i++) {
  36. $ret = $ttf->extractCoreInfo($ttfdir.$f, $i);
  37. $tfname = $ret[0];
  38. $bold = $ret[1];
  39. $italic = $ret[2];
  40. $fname = strtolower($tfname );
  41. $fname = preg_replace('/[ ()]/','',$fname );
  42. $style = '';
  43. if ($bold) { $style .= 'Bold'; }
  44. if ($italic) { $style .= 'Italic'; }
  45. if (!$style) { $style = 'Regular'; }
  46. echo '<div>['.$i.'] '.$tfname.' ('.$fname.') '.$style.'</div>';
  47. }
  48. echo '<hr />';
  49. }
  50. }
  51. exit;
  52. ?>