1<?php 2// $Header: /cvsroot/html2ps/css.line-height.inc.php,v 1.15 2006/11/11 13:43:52 Konstantin Exp $ 3 4require_once(HTML2PS_DIR.'value.line-height.class.php'); 5 6/** 7 * We'll treat 'line-height' as a subproperty of 'font', as it can be set using 8 * 'font' value 9 */ 10class CSSLineHeight extends CSSSubFieldProperty { 11 var $_defaultValue; 12 13 function CSSLineHeight(&$owner, $field) { 14 $this->CSSSubFieldProperty($owner, $field); 15 16 $this->_defaultValue = new LineHeight_Relative(1.1); 17 } 18 19 function default_value() { 20 return $this->_defaultValue; 21 } 22 23 function parse($value) { 24 if ($value === 'inherit') { 25 return CSS_PROPERTY_INHERIT; 26 }; 27 28 // <Number> 29 // The used value of the property is this number multiplied by the element's font size. 30 // Negative values are illegal. The computed value is the same as the specified value. 31 if (preg_match("/^\d+(\.\d+)?$/",$value)) { 32 return new LineHeight_Relative((float)$value); 33 }; 34 35 // <percentage> 36 // The computed value of the property is this percentage multiplied by the element's 37 // computed font size. Negative values are illegal. 38 if (preg_match("/^\d+%$/",$value)) { 39 return new LineHeight_Relative(((float)$value)/100); 40 }; 41 42 // normal 43 // Tells user agents to set the used value to a "reasonable" value based on the font of the element. 44 // The value has the same meaning as <number>. We recommend a used value for 'normal' between 1.0 to 1.2. 45 // The computed value is 'normal'. 46 if (trim($value) === "normal") { 47 return $this->default_value(); 48 }; 49 50 // <length> 51 // The specified length is used in the calculation of the line box height. 52 // Negative values are illegal. 53 return new LineHeight_Absolute($value); 54 } 55 56 function get_property_code() { 57 return CSS_LINE_HEIGHT; 58 } 59 60 function get_property_name() { 61 return 'line-height'; 62 } 63} 64 65?> 66