Text
in package
A Text class to embed string into Canvas.
Tags
Table of Contents
- $align : string
- $angle : int
- $blue : int
- $fontface : string
- $green : int
- $height : int
- $lineHeight : float
- $opacity : int
- $red : int
- $size : int
- $string : string
- $valign : string
- $width : int
- $x : int
- $y : int
- $align : mixed
- $angle : mixed
- $blue : mixed
- $fontface : mixed
- $green : mixed
- $height : mixed
- $lineHeight : mixed
- $opacity : mixed
- $red : mixed
- $size : mixed
- $string : mixed
- $valign : mixed
- $width : mixed
- $x : mixed
- $y : mixed
- __construct() : mixed
- Sets the plain text.
- getAlign() : string
- Gets the horizontal alignment for text.
- getAngle() : int
- Gets the angle.
- getColor() : array<string|int, mixed>
- Gets an array with rgb color.
- getContent() : string
- Gets the plain text.
- getCords() : array<string|int, mixed>
- Get the text cords [x, y].
- getFontface() : string
- Gets the font face.
- getHeight() : int
- Gets height.
- getLeft() : int
- Gets left position.
- getLineHeight() : float
- Gets line height.
- getOpacity() : int
- Gets the opacity.
- getSize() : int
- Gets fthe ont size.
- getTop() : int
- Gets top position.
- getValign() : string
- Gets the vertical alignment for text.
- getWidth() : int
- Gets width.
- getWrappedText() : array<string|int, mixed>
- Gets wrapped text.
- setAlign() : $this
- Sets the horizontal alignment for text.
- setAngle() : $this
- Sets text's angle.
- setColor() : $this
- Sets RGB color for text.
- setContent() : $this
- Sets a plain text.
- setFontface() : $this
- Sets font face (TTF font) for text.
- setHeight() : $this
- Sets box height.
- setLeft() : $this
- Sets left position.
- setLineHeight() : $this
- Sets line height.
- setOpacity() : $this
- Sets text's opacity.
- setSize() : $this
- Sets font size for text.
- setTop() : $this
- Sets top position.
- setValign() : $this
- Sets the vertical alignment for text.
- setWidth() : $this
- Sets box width.
- wrappText() : array<string|int, mixed>
- Wrapps the text.
- getBoundingBox() : array<string|int, mixed>|bool
- Calculates bounding box of text using the TrueType font.
Properties
$align
public
string
$align
Horizontal align mode.
$angle
public
int
$angle
Angle for the text.
$blue
public
int
$blue
$fontface
public
string
$fontface
Font face .ttf filename.
$green
public
int
$green
$height
public
int
$height
$lineHeight
public
float
$lineHeight
$opacity
public
int
$opacity
Opacity for the text.
$red
public
int
$red
$size
public
int
$size
$string
public
string
$string
String text.
$valign
public
string
$valign
Vertical align mode.
$width
public
int
$width
$x
public
int
$x
$y
public
int
$y
$align
private
mixed
$align
= 'none'
Tags
$angle
private
mixed
$angle
= 0
Tags
$blue
private
mixed
$blue
= 0
Tags
$fontface
private
mixed
$fontface
Tags
$green
private
mixed
$green
= 0
Tags
$height
private
mixed
$height
= 50
Tags
$lineHeight
private
mixed
$lineHeight
= 1.2
Tags
$opacity
private
mixed
$opacity
= 0
Tags
$red
private
mixed
$red
= 0
Tags
$size
private
mixed
$size
= 12
Tags
$string
private
mixed
$string
= ''
Tags
$valign
private
mixed
$valign
= 'none'
Tags
$width
private
mixed
$width
= 100
Tags
$x
private
mixed
$x
= 0
Tags
$y
private
mixed
$y
= 0
Tags
Methods
__construct()
Sets the plain text.
public
__construct([string $string = '' ]) : mixed
Parameters
- $string : string = ''
-
plain text
Tags
Return values
mixed —getAlign()
Gets the horizontal alignment for text.
public
getAlign() : string
Tags
Return values
string —alignment supported: 'none' or 'center'
getAngle()
Gets the angle.
public
getAngle() : int
Tags
Return values
int —getColor()
Gets an array with rgb color.
public
getColor() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getContent()
Gets the plain text.
public
getContent() : string
Tags
Return values
string —getCords()
Get the text cords [x, y].
public
getCords() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —an array with [x, y] cords
getFontface()
Gets the font face.
public
getFontface() : string
Tags
Return values
string —getHeight()
Gets height.
public
getHeight() : int
Tags
Return values
int —getLeft()
Gets left position.
public
getLeft() : int
Tags
Return values
int —getLineHeight()
Gets line height.
public
getLineHeight() : float
Tags
Return values
float —getOpacity()
Gets the opacity.
public
getOpacity() : int
Tags
Return values
int —getSize()
Gets fthe ont size.
public
getSize() : int
Tags
Return values
int —getTop()
Gets top position.
public
getTop() : int
Tags
Return values
int —getValign()
Gets the vertical alignment for text.
public
getValign() : string
Tags
Return values
string —alignment supported: 'none' or 'center'
getWidth()
Gets width.
public
getWidth() : int
Tags
Return values
int —getWrappedText()
Gets wrapped text.
public
getWrappedText(int $size, int $angle, string $fontface, string $string[, int $width = 100 ]) : array<string|int, mixed>
Parameters
- $size : int
-
font size fot the text
- $angle : int
-
angole for the text
- $fontface : string
-
path of TTF font
- $string : string
-
string text
- $width : int = 100
-
width for text box area
Tags
Return values
array<string|int, mixed> —setAlign()
Sets the horizontal alignment for text.
public
setAlign(string $align) : $this
Parameters
- $align : string
-
Values supported: none, center
Tags
Return values
$this —setAngle()
Sets text's angle.
public
setAngle(int $angle) : $this
Parameters
- $angle : int
-
Angle
Tags
Return values
$this —setColor()
Sets RGB color for text.
public
setColor(int $red, int $green, int $blue) : $this
Parameters
- $red : int
-
red color
- $green : int
-
green color
- $blue : int
-
blue color
Tags
Return values
$this —setContent()
Sets a plain text.
public
setContent([string $string = '' ]) : $this
Parameters
- $string : string = ''
-
plain text
Tags
Return values
$this —setFontface()
Sets font face (TTF font) for text.
public
setFontface(string $fontface) : $this
Parameters
- $fontface : string
-
path of TTF font
Tags
Return values
$this —setHeight()
Sets box height.
public
setHeight(int $height) : $this
Parameters
- $height : int
-
Height
Tags
Return values
$this —setLeft()
Sets left position.
public
setLeft(int $x) : $this
Parameters
- $x : int
-
position
Tags
Return values
$this —setLineHeight()
Sets line height.
public
setLineHeight(float $lineHeight) : $this
Parameters
- $lineHeight : float
-
line-height
Tags
Return values
$this —setOpacity()
Sets text's opacity.
public
setOpacity(int $opacity) : $this
Parameters
- $opacity : int
-
Opacity value from 0 to 1
Tags
Return values
$this —setSize()
Sets font size for text.
public
setSize(int $size) : $this
Parameters
- $size : int
-
font size
Tags
Return values
$this —setTop()
Sets top position.
public
setTop(int $y) : $this
Parameters
- $y : int
-
position
Tags
Return values
$this —setValign()
Sets the vertical alignment for text.
public
setValign(string $valign) : $this
Parameters
- $valign : string
-
Two values supported: 'none' or 'center'
Tags
Return values
$this —setWidth()
Sets box width.
public
setWidth(int $width) : $this
Parameters
- $width : int
-
Width
Tags
Return values
$this —wrappText()
Wrapps the text.
public
wrappText() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getBoundingBox()
Calculates bounding box of text using the TrueType font.
private
getBoundingBox(int $fontSize, int $fontAngle, string $fontFile, string $text) : array<string|int, mixed>|bool
Returns an array with 'left', 'top', 'width' and 'height' values.
Parameters
- $fontSize : int
-
font size fot the text
- $fontAngle : int
-
angole for the text
- $fontFile : string
-
path of TTF font
- $text : string
-
string text