Source for file Font.php
Documentation is available at Font.php
* Validates shorthand CSS property font.
* Local copy of component validators.
* @note If we moved specific CSS property definitions to their own
* classes instead of having them be assembled at run time by
* CSSDefinition, this wouldn't be necessary. We'd instantiate
protected $info =
array();
$def =
$config->getCSSDefinition();
$this->info['font-style'] =
$def->info['font-style'];
$this->info['font-variant'] =
$def->info['font-variant'];
$this->info['font-weight'] =
$def->info['font-weight'];
$this->info['font-size'] =
$def->info['font-size'];
$this->info['line-height'] =
$def->info['line-height'];
$this->info['font-family'] =
$def->info['font-family'];
public function validate($string, $config, $context) {
static $system_fonts =
array(
// regular pre-processing
$string =
$this->parseCDATA($string);
if ($string ===
'') return false;
// check if it's one of the keywords
if (isset
($system_fonts[$lowercase_string])) {
return $lowercase_string;
$bits =
explode(' ', $string); // bits to process
$stage =
0; // this indicates what we're looking for
$caught =
array(); // which stage 0 properties have we caught?
$stage_1 =
array('font-style', 'font-variant', 'font-weight');
for ($i =
0, $size =
count($bits); $i <
$size; $i++
) {
if ($bits[$i] ===
'') continue;
// attempting to catch font-style, font-variant or font-weight
foreach ($stage_1 as $validator_name) {
if (isset
($caught[$validator_name])) continue;
$r =
$this->info[$validator_name]->validate(
$bits[$i], $config, $context);
$caught[$validator_name] =
true;
// all three caught, continue on
if (count($caught) >=
3) $stage =
1;
// attempting to catch font-size and perhaps line-height
if (strpos($bits[$i], '/') !==
false) {
list
($font_size, $line_height) =
if ($line_height ===
'') {
// ooh, there's a space after the slash!
$r =
$this->info['font-size']->validate(
$font_size, $config, $context);
// attempt to catch line-height
if ($line_height ===
false) {
// we need to scroll forward
for ($j =
$i +
1; $j <
$size; $j++
) {
if ($bits[$j] ===
'') continue;
$line_height =
$bits[$j];
$r =
$this->info['line-height']->validate(
$line_height, $config, $context);
// attempting to catch font-family
$r =
$this->info['font-family']->validate(
$font_family, $config, $context);
// processing completed successfully
Documentation generated on Thu, 19 Jun 2008 18:49:14 -0400 by phpDocumentor 1.4.2