MakeFontDescriptor

The WooCommerce PDF & Print MakeFontDescriptor function.

Description

MakeFontDescriptor( $fm, $symbolic ); 

Parameters (2)

0. $fm
The fm.
1. $symbolic
The symbolic.

Usage

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

Defined (1)

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

/pdf/font/makefont/makefont.php  
  1. function MakeFontDescriptor($fm, $symbolic) 
  2. //Ascent 
  3. $asc=(isset($fm['Ascender']) ? $fm['Ascender'] : 1000); 
  4. $fd="array('Ascent'=>".$asc; 
  5. //Descent 
  6. $desc=(isset($fm['Descender']) ? $fm['Descender'] : -200); 
  7. $fd.=", 'Descent'=>".$desc; 
  8. //CapHeight 
  9. if(isset($fm['CapHeight'])) 
  10. $ch=$fm['CapHeight']; 
  11. elseif(isset($fm['CapXHeight'])) 
  12. $ch=$fm['CapXHeight']; 
  13. else 
  14. $ch=$asc; 
  15. $fd.=", 'CapHeight'=>".$ch; 
  16. //Flags 
  17. $flags=0; 
  18. if(isset($fm['IsFixedPitch']) && $fm['IsFixedPitch']) 
  19. $flags+=1<<0; 
  20. if($symbolic) 
  21. $flags+=1<<2; 
  22. if(!$symbolic) 
  23. $flags+=1<<5; 
  24. if(isset($fm['ItalicAngle']) && $fm['ItalicAngle']!=0) 
  25. $flags+=1<<6; 
  26. $fd.=", 'Flags'=>".$flags; 
  27. //FontBBox 
  28. if(isset($fm['FontBBox'])) 
  29. $fbb=$fm['FontBBox']; 
  30. else 
  31. $fbb=array(0, $desc-100, 1000, $asc+100); 
  32. $fd.=", 'FontBBox'=>'[".$fbb[0].' '.$fbb[1].' '.$fbb[2].' '.$fbb[3]."]'"; 
  33. //ItalicAngle 
  34. $ia=(isset($fm['ItalicAngle']) ? $fm['ItalicAngle'] : 0); 
  35. $fd.=", 'ItalicAngle'=>".$ia; 
  36. //StemV 
  37. if(isset($fm['StdVW'])) 
  38. $stemv=$fm['StdVW']; 
  39. elseif(isset($fm['Weight']) && preg_match('/bold|black/i', $fm['Weight'])) 
  40. $stemv=120; 
  41. else 
  42. $stemv=70; 
  43. $fd.=", 'StemV'=>".$stemv; 
  44. //MissingWidth 
  45. if(isset($fm['MissingWidth'])) 
  46. $fd.=", 'MissingWidth'=>".$fm['MissingWidth']; 
  47. $fd.=')'; 
  48. return $fd;