Source for file FontFamily.php
Documentation is available at FontFamily.php
* Validates a font family list according to CSS spec
* @todo whitelisting allowed fonts would be nice
public function validate($string, $config, $context) {
static $generic_names =
array(
// assume that no font names contain commas in them
$fonts =
explode(',', $string);
foreach($fonts as $font) {
if ($font ===
'') continue;
if (isset
($generic_names[$font])) {
if ($font[0] ===
'"' ||
$font[0] ===
"'") {
if ($length <=
2) continue;
if ($font[$length -
1] !==
$quote) continue;
$font =
substr($font, 1, $length -
2);
for ($i =
0, $c =
strlen($font); $i <
$c; $i++
) {
if ($font[$i] ===
'\\') {
for ($a =
1, $i++
; $i <
$c &&
$a <
6; $i++
, $a++
) {
// We have to be extremely careful when adding
// new characters, to make sure we're not breaking
if ($i <
$c &&
trim($font[$i]) !==
'') $i--
;
if ($font[$i] ===
"\n") continue;
// $font is a pure representation of the font name
// very simple font, allow it in unharmed
// complicated font, requires quoting
// armor single quotes and new lines
$final =
rtrim($final, ', ');
if ($final ===
'') return false;
Documentation generated on Thu, 19 Jun 2008 18:49:15 -0400 by phpDocumentor 1.4.2