Source for file LFontgen.php
Documentation is available at LFontgen.php
* @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
* @copyright 2005, diemeisterei GmbH. All rights reserved.
* @author $Author: schmunk $
* @version $Revision: 236 $ $Date: 2006-05-30 23:39:46 +0200 (Di, 30 Mai 2006) $ $HeadURL: https://svn.sourceforge.net/svnroot/lithron/trunk/packages/LContainer/LBrick.php $
* @package Phundament.Components
* @subpackage WebControls
* Adds the ability to render custom font text images
* @package System.Web.UI.WebControls
private $RealOutputDir= "";
private $DescenderHeight;
private $LoadedFonts= array ();
return $this->getViewState('Text', '');
$this->setViewState('Text', $value, '');
return $this->getViewState('Font', '');
$this->setViewState('Font', $value, '');
return $this->getViewState('FontSize', 60);
$this->setViewState('FontSize', $value, 60);
return $this->getViewState('LineHeight', $this->getFontSize());
$this->setViewState('LineHeight', $value, $this->getFontSize());
return $this->getViewState('Color', "");
$this->setViewState('Color', $value, "");
return $this->getViewState('BackgroundColor', "");
$this->setViewState('BackgroundColor', $value, "");
return $this->getViewState('Space', 0);
$this->setViewState('Space', $value, 0);
return $this->getViewState('Type', 'png');
return $this->getViewState('Tightness', 0);
$this->setViewState('Tightness', $value, 0);
return $this->getViewState('Angle', 0);
$this->setViewState('Angle', $value, 0);
return $this->getViewState('AASteps', 16);
$this->setViewState('AASteps', $value, 16);
return $this->getViewState('IEFix', 1);
$this->setViewState('IEFix', $value, 1);
return $this->getViewState('AdjustBaseline', true);
$this->setViewState('AdjustBaseline', TPropertyValue :: ensureBoolean($value), true);
public function extractColor($colString, & $R, & $G, & $B, & $A)
preg_match("/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/", $colString, $matches);
if (count($matches) == 0)
preg_match("/^#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/", $colString, $matches);
if (count($matches) == 0)
parent :: onPreRender($param);
Prado :: log($e->getMessage(), 8, "Lithron.LFontgen");
# only add transparent background behaviour if IEFix is not set
$script= "img {behavior: url(" . $this->publishAsset("LFontgen/iefix.htc") . ")}";
$scriptMgr= $this->getPage()->getClientScript();
$scriptMgr->registerStyleSheet("LFontgenIEFix", $script);
#Prado :: trace("Preparing font (" .
#$this->SkinId . ") ...", "Lithron.LFontGen");
Prado :: log("Font not found (" . $this->Font . ") ...", 16, "Lithron.LFontGen");
if (isset ($loadedFonts[$this->Font]))
$this->FontID= $loadedFonts[$this->Font];
#Prado :: trace("Using static font var ...", "Lithron.LFontGen");
Prado :: trace("Loading font (" . $this->Font . ") ...", "Lithron.LFontGen");
$this->HTCUrl= $this->publishAsset("LFontgen/iefix.htc");
$param= $this->Application->getParameters();
$this->OutputDir= $param->itemAt("OutputDir");
$this->RealOutputDir= realpath($this->OutputDir);
$this->AscenderHeight= $ry - $ly;
$this->DescenderHeight= - $ly;
list ($lx, $ly, $rx, $ry)= $_sw;
if (!$bgAvail && $fgAvail)
#Prado::trace("Font prepared.", "Lithron.LFontGen");
$name= $this->OutputDir . "/" . $hash . "." . $this->getType();
$realname= $this->RealOutputDir . "/" . $hash . "." . $this->getType();
//get the left lower corner and the right upper
imagepstext($im, $word, $this->FontID, $this->getFontSize(), $fgcol, $bgcol, 0, $this->getLineHeight() - $this->DescenderHeight, $this->getSpace(), $this->getTightness(), $this->getAngle(), $this->getAASteps());
* @param THtmlWriter writer
public function render($writer)
Prado :: log("Font rendering aborted.", 8, "Lithron.LFontGen");
$words= split(" ", $text);
foreach ($words as $i => $word)
foreach ($words as $wnum => $word)
Prado :: log($e->getMessage(), 8, "Lithron.LFontgen");
$writer->addAttribute('src', $file);
$writer->addAttribute('width', $imgsize[0]);
$writer->addAttribute('height', $imgsize[1]);
$writer->addStyleAttribute('border-width','0px');
$writer->addStyleAttribute('width', $imgsize[0] . "px");
$writer->addStyleAttribute('height', $imgsize[1] . "px");
$writer->addStyleAttribute('background-image', $this->publishAsset("LFontgen/space.gif"));
$writer->addStyleAttribute('background', 'transparent');
#$writer->addStyleAttribute('margin', '0');
if ($wnum < count($words) - 1)
$writer->addStyleAttribute('margin-right', ($this->SpaceWidth + $this->getSpace() - 1) .
$writer->addStyleAttribute('position', 'relative');
$writer->addStyleAttribute('top', ($this->DescenderHeight + 1) . 'px');
$writer->renderBeginTag('img');
#Prado::trace("Freeing font (".$this->SkinId.")", "Lithron.LFontgen");
#imagepsfreefont($this->FontID);
|