summaryrefslogtreecommitdiffstats
path: root/src/driver
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-06-02 12:25:08 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-06-02 12:25:08 +0000
commitaf2abec76e82803d5d87f67c95c0009e09315aa5 (patch)
treec33946ac22bd0c15b878d584529da24ad42ef526 /src/driver
parent3e7be683345e3c54bbf07e082c9c2d8784d5b041 (diff)
downloadzetacomponents-graph-af2abec76e82803d5d87f67c95c0009e09315aa5.zip
zetacomponents-graph-af2abec76e82803d5d87f67c95c0009e09315aa5.tar.gz
- Moved font configuration to elements
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/gd.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/driver/gd.php b/src/driver/gd.php
index e0e4912..2a0fb8e 100644
--- a/src/driver/gd.php
+++ b/src/driver/gd.php
@@ -157,7 +157,7 @@ class ezcGraphGdDriver extends ezcGraphDriver
$selectedLine = $lines[$line];
$selectedLine[] = $token;
- $boundings = imagettfbbox( $size, 0, $this->options->font, implode( ' ', $selectedLine ) );
+ $boundings = imagettfbbox( $size, 0, $this->options->font->font, implode( ' ', $selectedLine ) );
// Check if line is too long
if ( $boundings[2] > $width )
@@ -204,11 +204,17 @@ class ezcGraphGdDriver extends ezcGraphDriver
public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align )
{
$image = $this->getImage();
- $drawColor = $this->allocate( $this->options->fontColor );
+ $drawColor = $this->allocate( $this->options->font->color );
+
+ // Test font
+ if ( !is_file( $this->options->font->font ) || !is_readable( $this->options->font->font ) )
+ {
+ throw new ezcGraphGdDriverInvalidFontException( $this->options->font->font );
+ }
// Try to get a font size for the text to fit into the box
- $maxSize = min( $height, $this->options->maxFontSize );
- for ( $size = $maxSize; $size >= $this->options->minFontSize; --$size )
+ $maxSize = min( $height, $this->options->font->maxFontSize );
+ for ( $size = $maxSize; $size >= $this->options->font->minFontSize; --$size )
{
$result = $this->testFitStringInTextBox( $string, $position, $width, $height, $size );
if ( $result !== false )
@@ -240,19 +246,19 @@ class ezcGraphGdDriver extends ezcGraphDriver
foreach ( $result as $line )
{
$string = implode( ' ', $line );
- $boundings = imagettfbbox( $size, 0, $this->options->font, $string );
+ $boundings = imagettfbbox( $size, 0, $this->options->font->font, $string );
$position->y += $size;
switch ( true )
{
case ( $align & ezcGraph::LEFT ):
- imagettftext( $image, $size, 0, $position->x, $position->y + $yOffset, $drawColor, $this->options->font, $string );
+ imagettftext( $image, $size, 0, $position->x, $position->y + $yOffset, $drawColor, $this->options->font->font, $string );
break;
case ( $align & ezcGraph::RIGHT ):
- imagettftext( $image, $size, 0, $position->x + ( $width - $boundings[2] ), $position->y + $yOffset, $drawColor, $this->options->font, $string );
+ imagettftext( $image, $size, 0, $position->x + ( $width - $boundings[2] ), $position->y + $yOffset, $drawColor, $this->options->font->font, $string );
break;
case ( $align & ezcGraph::CENTER ):
- imagettftext( $image, $size, 0, $position->x + ( ( $width - $boundings[2] ) / 2 ), $position->y + $yOffset, $drawColor, $this->options->font, $string );
+ imagettftext( $image, $size, 0, $position->x + ( ( $width - $boundings[2] ) / 2 ), $position->y + $yOffset, $drawColor, $this->options->font->font, $string );
break;
}
OpenPOWER on IntegriCloud