CheckTTF

The WooCommerce PDF & Print CheckTTF function.

Description

CheckTTF( $file ); 

Parameters (1)

0. $file
The file.

Usage

  1. if ( !function_exists( 'CheckTTF' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-pdf-print/pdf/font/makefont/makefont.php'; 
  3.  
  4. // The file. 
  5. $file = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = CheckTTF($file); 
  9.  

Defined (1)

The function is defined in the following location(s).

/pdf/font/makefont/makefont.php  
  1. function CheckTTF($file) 
  2. //Check if font license allows embedding 
  3. $f=fopen($file, 'rb'); 
  4. if(!$f) 
  5. die('<b>Error:</b> Can\'t open '.$file); 
  6. //Extract number of tables 
  7. fseek($f, 4, SEEK_CUR); 
  8. $nb=ReadShort($f); 
  9. fseek($f, 6, SEEK_CUR); 
  10. //Seek OS/2 table 
  11. $found=false; 
  12. for($i=0;$i<$nb;$i++) 
  13. if(fread($f, 4)=='OS/2') 
  14. $found=true; 
  15. break; 
  16. fseek($f, 12, SEEK_CUR); 
  17. if(!$found) 
  18. fclose($f); 
  19. return; 
  20. fseek($f, 4, SEEK_CUR); 
  21. $offset=ReadLong($f); 
  22. fseek($f, $offset, SEEK_SET); 
  23. //Extract fsType flags 
  24. fseek($f, 8, SEEK_CUR); 
  25. $fsType=ReadShort($f); 
  26. $rl=($fsType & 0x02)!=0; 
  27. $pp=($fsType & 0x04)!=0; 
  28. $e=($fsType & 0x08)!=0; 
  29. fclose($f); 
  30. if($rl && !$pp && !$e) 
  31. echo '<b>Warning:</b> font license does not allow embedding';