1<?php 2 3class CSSFontFamily extends CSSSubFieldProperty { 4 function default_value() { 5 return 'times'; 6 } 7 8 function parse($value) { 9 if ($value == 'inherit') { 10 return CSS_PROPERTY_INHERIT; 11 } 12 13 $subvalues = preg_split("/\s*,\s*/",$value); 14 15 foreach ($subvalues as $subvalue) { 16 $subvalue = trim(strtolower($subvalue)); 17 18 // Check if current subvalue is not empty (say, in case of 'font-family:;' or 'font-family:family1,,family2;') 19 if ($subvalue !== "") { 20 21 // Some multi-word font family names can be enclosed in quotes; remove them 22 if ($subvalue{0} == "'") { 23 $subvalue = substr($subvalue,1,strlen($subvalue)-2); 24 } elseif ($subvalue{0} == '"') { 25 $subvalue = substr($subvalue,1,strlen($subvalue)-2); 26 }; 27 28 global $g_font_resolver; 29 if ($g_font_resolver->have_font_family($subvalue)) { return $subvalue; }; 30 31 global $g_font_resolver_pdf; 32 if ($g_font_resolver_pdf->have_font_family($subvalue)) { return $subvalue; }; 33 }; 34 }; 35 36 // Unknown family type 37 return "times"; 38 } 39 40 function get_property_code() { 41 return CSS_FONT_FAMILY; 42 } 43 44 function get_property_name() { 45 return 'font-family'; 46 } 47 48} 49 50?>