本文整理汇总了PHP中ConvertSize函数的典型用法代码示例。如果您正苦于以下问题:PHP ConvertSize函数的具体用法?PHP ConvertSize怎么用?PHP ConvertSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ConvertSize函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCSS
function setCSS($arrayaux)
{
//! @return void
//! @desc Change some class attributes according to CSS properties
if (!is_array($arrayaux)) {
return;
}
//Removes PHP Warning
foreach ($arrayaux as $k => $v) {
switch ($k) {
case 'WIDTH':
$this->divwidth = ConvertSize($v, $this->pgwidth);
break;
case 'HEIGHT':
$this->divheight = ConvertSize($v, $this->pgwidth);
break;
case 'BORDER':
// width style color (width not supported correctly - it is always considered as normal)
$prop = explode(' ', $v);
if (count($prop) != 3) {
break;
}
// Not supported: borders not fully declared
//style: dashed dotted none (anything else => solid )
if (strnatcasecmp($prop[1], "dashed") == 0) {
$this->dash_on = true;
$this->SetDash(2, 2);
//2mm on, 2mm off
} elseif (strnatcasecmp($prop[1], "dotted") == 0) {
$this->dotted_on = true;
} elseif (strnatcasecmp($prop[1], "none") == 0) {
$this->divborder = 0;
} else {
$this->divborder = 1;
}
//color
$coul = ConvertColor($prop[2]);
$this->SetDrawColor($coul['R'], $coul['G'], $coul['B']);
$this->issetcolor = true;
break;
case 'FONT-FAMILY':
// one of the $this->fontlist fonts
//If it is a font list, get all font types
$aux_fontlist = explode(",", $v);
$fontarraysize = count($aux_fontlist);
for ($i = 0; $i < $fontarraysize; $i++) {
$fonttype = $aux_fontlist[$i];
$fonttype = trim($fonttype);
//If font is found, set it, and exit loop
if (in_array(strtolower($fonttype), $this->fontlist)) {
$this->SetFont(strtolower($fonttype));
break;
}
//If font = "courier new" for example, try simply looking for "courier"
$fonttype = explode(" ", $fonttype);
$fonttype = $fonttype[0];
if (in_array(strtolower($fonttype), $this->fontlist)) {
$this->SetFont(strtolower($fonttype));
break;
}
}
break;
case 'FONT-SIZE':
//Does not support: smaller, larger
if (is_numeric($v[0])) {
$mmsize = ConvertSize($v, $this->pgwidth);
$this->SetFontSize($mmsize * (72 / 25.4));
//Get size in points (pt)
} else {
$v = strtoupper($v);
switch ($v) {
//Values obtained from http://www.w3schools.com/html/html_reference.asp
case 'XX-SMALL':
$this->SetFontSize(0.7 * 11);
break;
case 'X-SMALL':
$this->SetFontSize(0.77 * 11);
break;
case 'SMALL':
$this->SetFontSize(0.86 * 11);
break;
case 'MEDIUM':
$this->SetFontSize(11);
break;
case 'LARGE':
$this->SetFontSize(1.2 * 11);
break;
case 'X-LARGE':
$this->SetFontSize(1.5 * 11);
break;
case 'XX-LARGE':
$this->SetFontSize(2 * 11);
break;
}
}
break;
case 'FONT-STYLE':
// italic normal oblique
switch (strtoupper($v)) {
case 'ITALIC':
//.........这里部分代码省略.........
示例2: setCSS
function setCSS($array)
{
//! @return void
foreach ($array as $k => $v) {
switch ($k) {
case 'WIDTH':
$this->divwidth = ConvertSize($v, $this->pgwidth);
break;
case 'HEIGHT':
$this->divheight = ConvertSize($v, $this->pgwidth);
break;
case 'BORDER':
// width style color (width not supported correctly - it is always considered as normal)
$prop = explode(' ', $v);
if (count($prop) != 3) {
break;
}
// It does not support: borders not fully declared
//style: dashed dotted none (anything else => solid )
if (strnatcasecmp($prop[1], "dashed") == 0) {
$this->dash_on = true;
$this->SetDash(2, 2);
//2mm on, 2mm off
} elseif (strnatcasecmp($prop[1], "dotted") == 0) {
$this->dotted_on = true;
} elseif (strnatcasecmp($prop[1], "none") == 0) {
$this->divborder = 0;
} else {
$this->divborder = 1;
}
//color
$coul = ConvertColor($prop[2]);
$this->SetDrawColor($coul['R'], $coul['G'], $coul['B']);
$this->issetcolor = true;
break;
case 'FONT-FAMILY':
// one of the $this->fontlist fonts
if (in_array(strtolower($v), $this->fontlist)) {
$this->SetFont(strtolower($v));
}
break;
case 'FONT-SIZE':
$this->SetFontSize(ConvertSize($v, $this->pgwidth));
break;
case 'FONT-STYLE':
// italic normal oblique
switch (strtoupper($v)) {
case 'ITALIC':
case 'OBLIQUE':
$this->SetStyle('I', true);
break;
case 'NORMAL':
break;
}
break;
case 'FONT-WEIGHT':
// normal bold
switch (strtoupper($v)) {
case 'BOLD':
$this->SetStyle('B', true);
break;
case 'NORMAL':
break;
}
break;
case 'TEXT-DECORATION':
// none underline
switch (strtoupper($v)) {
case 'UNDERLINE':
$this->SetStyle('U', true);
break;
case 'NONE':
break;
}
case 'TEXT-TRANSFORM':
// none uppercase lowercase
switch (strtoupper($v)) {
case 'UPPERCASE':
$this->toupper = true;
break;
case 'LOWERCASE':
$this->tolower = true;
break;
case 'NONE':
break;
}
case 'TEXT-ALIGN':
//left right center justify
switch (strtoupper($v)) {
case 'LEFT':
$this->divalign = "L";
break;
case 'CENTER':
$this->divalign = "C";
break;
case 'RIGHT':
$this->divalign = "R";
break;
case 'JUSTIFY':
$this->divalign = "J";
//.........这里部分代码省略.........