Class TIC

Description

TIC - Text Image Converter.

Use this class to instantiate concrete classes of TIC or extend it to support other font types besides ttf.

  1. <?php
  2.  // return and instance of TIC_ttf (based on font file extension)
  3.  $tic TIC::factory('/path/to/font.ttf');
  4.  // methods are chainable
  5.  $tic->setText('Hello World !')
  6.  ->setBgColor(0x000x000xff)
  7.  ->setFontColor(array(0x000x000x00))
  8.  ->create(true)// create and output
  9.  ?>

Located in /tic.php (line 41)


	
			
Direct descendents
Class Description
TIC_ttf TIC concrete class for TrueType Fonts
Variable Summary
bool $align
int $angle
array $bgColor
string $font
array $fontColor
resource $gd
int $imgWidth
int $size
string $text
bool $valign
Method Summary
static TIC factory (string $font)
TIC __construct (string $font)
void __destruct ()
TIC create ([boolean $render = false], [string $type = 'png'])
array dimension ([string $text = -1], [int $size = -1], [int $angle = -1], [string $font = -1])
void render ([string $type = 'png'])
TIC setAngle (int $angle)
TIC setBgColor (int|array $rgb, [int $g = 0x00], [int $b = 0x00])
TIC setFontColor (int|array $rgb, [int $g = 0x00], [int $b = 0x00])
TIC setFontSize (int $size)
TIC setHorAlign ([bool $align = true])
TIC setHorPadding (int $padding)
TIC setImgHeight (int $height)
TIC setImgWidth (int $width)
void setPadding ( $padding)
TIC setText (string $text)
TIC setVerAlign ([bool $valign = true])
TIC setVerPadding (int $padding)
void wrap_text ()
void wrap_word ( &$lines,  &$wline,  $line,  $max_width)
Variables
bool $align (line 131)

if true horizontal align text

  • access: protected
int $angle (line 119)

In degrees, 0 is 'left to write' reading.

  • access: protected
array $bgColor (line 53)

image background color

  1.  array(0xff0x000x00)// red

  • access: protected
string $font (line 46)
  • var: full path to a font
  • access: protected
array $fontColor (line 60)

text color

  1.  array(0x000xff0x00)// green

  • access: protected
resource $gd (line 113)
  • var: GD resource
  • access: protected
int $horPadding (line 108)

left and right padding, spacing between end of image and the text

  • access: protected
int $imgHeight (line 91)

Height of the image, if set and greater than 0 will takes

priority over $textHeight;

  • access: protected
int $imgWidth (line 84)

Width of the image, if set and greater than 0 will takes

priority over $textWidth

  • access: protected
int $size (line 96)
  • var: font size
  • access: protected
string $text (line 66)

text to write to image

  • access: protected
int $textHeight (line 77)
  • var: stores the actual height of the font
  • access: protected
int $textWidth (line 72)

stores width of text, it depends on the font used

  • access: protected
bool $valign (line 125)

if true vertical align text

  • access: protected
int $verPadding (line 102)

Vertical Padding top and bottom padding, spacing between end of image and the text

  • access: protected
Methods
static method factory (line 176)
  • return: An instance of a Text Image Converter, based on the font extension
  • access: public
static TIC factory (string $font)
  • string $font: Path to a font
    1. <?php
    2.  $tic TIC::factory('relative/path/font.ttf');
    3.  $tic->setText('Hello World !')
    4.  ->create(true);
    5.  ?>
Constructor __construct (line 137)
  • access: public
TIC __construct (string $font)
  • string $font: Path to a font

Redefined in descendants as:
Destructor __destruct (line 159)

Free $this->gd resource

  • access: public
void __destruct ()
create (line 471)

Creates the image with the text, optionally output the image

  • abstract:
  • access: public
TIC create ([boolean $render = false], [string $type = 'png'])
  • boolean $render: Set to true to render the image
  • string $type: png|jpg|jpeg|gif

Redefined in descendants as:
dimension (line 462)

Calculates text width, height and x, y coordinates where drawing starts.

If a parameter is not passed or passed with negative value then the class property is going to be used

  • return: array($width, $height)
    1.  <?php list($width$height$x$y$this->dimension()?>
  • abstract:
  • access: protected
array dimension ([string $text = -1], [int $size = -1], [int $angle = -1], [string $font = -1])
  • string $text: If -1 then $this->text is going to be used
  • int $size: font size, depending on GD version is going to be interpreded as points or pixels
  • int $angle: Angle in degree text should be written into image.
  • string $font: Full or Relative path to a True type font

Redefined in descendants as:
render (line 329)
  • access: public
void render ([string $type = 'png'])
  • string $type: Supported types are 'png', 'jpeg|jpg' and gif
setAngle (line 299)
  • return: method is chainable
  • access: public
TIC setAngle (int $angle)
  • int $angle: Angle to write the text in
setBgColor (line 245)
  • return: method is chainable
  • access: public
TIC setBgColor (int|array $rgb, [int $g = 0x00], [int $b = 0x00])
  • int|array $rgb: If int (red) should be between 0 and 255, if array should have 3 ints, each between 0 and 255
  • int $g: Ignored if $rgb is an array, is the green part of RGB
  • int $b: Ignored if $rgb is an array, is the blue part of RGB
setFontColor (line 228)
  • return: method is chainable
  • access: public
TIC setFontColor (int|array $rgb, [int $g = 0x00], [int $b = 0x00])
  • int|array $rgb: If int (red) should be between 0 and 255, if array should have 3 ints, each between 0 and 255
  • int $g: Ignored if $rgb is an array, is the green part of RGB
  • int $b: Ignored if $rgb is an array, is the blue part of RGB
setFontSize (line 216)
  • return: method is chainable
  • access: public
TIC setFontSize (int $size)
  • int $size: Set the font size
setHorAlign (line 319)
  • return: method is chainable
  • access: public
TIC setHorAlign ([bool $align = true])
  • bool $align: If true align text
setHorPadding (line 282)
  • return: method is chainable
  • access: public
TIC setHorPadding (int $padding)
  • int $padding: The horizonal padding (left and right) between the text and the border of the image
setImgHeight (line 206)
  • return: method is chainable
  • access: public
TIC setImgHeight (int $height)
  • int $height: Set the height of the image
setImgWidth (line 196)
  • return: method is chainable
  • access: public
TIC setImgWidth (int $width)
  • int $width: Set the width of the image
setPadding (line 288)
  • access: public
void setPadding ( $padding)
  • $padding
setText (line 260)
  • return: method is chainable
  • access: public
TIC setText (string $text)
  • string $text: Text to write in the image
setVerAlign (line 309)
  • return: method is chainable
  • access: public
TIC setVerAlign ([bool $valign = true])
  • bool $valign: If true valign text
setVerPadding (line 271)
  • return: method is chainable
  • access: public
TIC setVerPadding (int $padding)
  • int $padding: The vertical padding (top and bottom) between the text and the border of the image
wrap_text (line 354)

Wraps $this->text into multiple lines if wider then $this->width - ($this->padding * 2)

  • access: protected
void wrap_text ()
wrap_word (line 409)

Wraps a word into multiple lines if the word is wider than $this->imgWidth

  • access: protected
void wrap_word ( &$lines,  &$wline,  $line,  $max_width)
  • &$lines
  • &$wline
  • $line
  • $max_width

Documentation generated on Sat, 27 Mar 2010 17:10:32 +0900 by phpDocumentor 1.4.3