Font
extends Supervisor
in package
Table of Contents
Constants
- CAP_ALL = 'all'
- CAP_NONE = 'none'
- CAP_SMALL = 'small'
- UNDERLINE_DOUBLE = 'double'
- UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting'
- UNDERLINE_NONE = 'none'
- UNDERLINE_SINGLE = 'single'
- UNDERLINE_SINGLEACCOUNTING = 'singleAccounting'
- VALID_CAPS = [self::CAP_ALL, self::CAP_SMALL, self::CAP_NONE]
Properties
- $colorIndex : int|null
- $bold : bool|null
- Bold.
- $cap : string|null
- $color : Color
- Foreground color.
- $isSupervisor : bool
- Supervisor?
- $italic : bool|null
- Italic.
- $name : string|null
- Font Name.
- $parent : Spreadsheet|Supervisor
- Parent. Only used for supervisor.
- $parentPropertyName : string|null
- Parent property name.
- $scheme : string
- $size : float|null
- Font Size.
- $strikethrough : bool|null
- Strikethrough.
- $subscript : bool|null
- Subscript.
- $superscript : bool|null
- Superscript.
- $underline : string|null
- Underline.
- $baseLine : int
- $chartColor : ChartColor|null
- $complexScript : string
- $eastAsian : string
- $latin : string
- The following 7 are used only for chart titles, I think.
- $strikeType : string
- $underlineColor : ChartColor|null
Methods
- __clone() : mixed
- Implement PHP __clone to create a deep clone, not just a shallow copy.
- __construct() : mixed
- Create a new Font.
- applyFromArray() : $this
- Apply styles from array.
- bindParent() : $this
- Bind parent. Only used for supervisor.
- exportArray() : array<string|int, mixed>
- Export style as array.
- getActiveCell() : string
- Get the currently active cell coordinate in currently active sheet.
- getActiveSheet() : Worksheet
- Get the currently active sheet. Only used for supervisor.
- getBaseLine() : int
- getBold() : bool|null
- Get Bold.
- getCap() : string|null
- getChartColor() : ChartColor|null
- getColor() : Color
- Get Color.
- getComplexScript() : string
- getEastAsian() : string
- getHashCode() : string
- Get hash code.
- getIsSupervisor() : bool
- Is this a supervisor or a cell style component?
- getItalic() : bool|null
- Get Italic.
- getLatin() : string
- getName() : string|null
- Get Name.
- getScheme() : string
- getSelectedCells() : string
- Get the currently active cell coordinate in currently active sheet.
- getSharedComponent() : self
- Get the shared style component for the currently active cell in currently active sheet.
- getSize() : float|null
- Get Size.
- getStrikethrough() : bool|null
- Get Strikethrough.
- getStrikeType() : string
- getStyleArray() : array<string|int, mixed>
- Build style array from subcomponents.
- getSubscript() : bool|null
- Get Subscript.
- getSuperscript() : bool|null
- Get Superscript.
- getUnderline() : string|null
- Get Underline.
- getUnderlineColor() : ChartColor|null
- setBaseLine() : self
- setBold() : $this
- Set Bold.
- setCap() : self
- Set capitalization attribute. If not one of the permitted values (all, small, or none), set it to null.
- setChartColor() : self
- setChartColorFromObject() : self
- setColor() : $this
- Set Color.
- setComplexScript() : self
- setEastAsian() : self
- setItalic() : $this
- Set Italic.
- setLatin() : self
- setName() : self
- Set Name and turn off Scheme.
- setScheme() : self
- setSize() : $this
- Set Size.
- setStrikethrough() : $this
- Set Strikethrough.
- setStrikeType() : self
- setSubscript() : $this
- Set Subscript.
- setSuperscript() : $this
- Set Superscript.
- setUnderline() : $this
- Set Underline.
- setUnderlineColor() : self
- exportArray1() : array<string|int, mixed>
- Abstract method to be implemented in anything which extends this class.
- exportArray2() : void
- Populate array from exportArray1.
- hashChartColor() : string
Constants
CAP_ALL
public
mixed
CAP_ALL
= 'all'
CAP_NONE
public
mixed
CAP_NONE
= 'none'
CAP_SMALL
public
mixed
CAP_SMALL
= 'small'
UNDERLINE_DOUBLE
public
mixed
UNDERLINE_DOUBLE
= 'double'
UNDERLINE_DOUBLEACCOUNTING
public
mixed
UNDERLINE_DOUBLEACCOUNTING
= 'doubleAccounting'
UNDERLINE_NONE
public
mixed
UNDERLINE_NONE
= 'none'
UNDERLINE_SINGLE
public
mixed
UNDERLINE_SINGLE
= 'single'
UNDERLINE_SINGLEACCOUNTING
public
mixed
UNDERLINE_SINGLEACCOUNTING
= 'singleAccounting'
VALID_CAPS
private
mixed
VALID_CAPS
= [self::CAP_ALL, self::CAP_SMALL, self::CAP_NONE]
Properties
$colorIndex
public
int|null
$colorIndex
= null
$bold
Bold.
protected
bool|null
$bold
= false
$cap
protected
string|null
$cap
= null
$color
Foreground color.
protected
Color
$color
$isSupervisor
Supervisor?
protected
bool
$isSupervisor
$italic
Italic.
protected
bool|null
$italic
= false
$name
Font Name.
protected
string|null
$name
= 'Calibri'
$parent
Parent. Only used for supervisor.
protected
Spreadsheet|Supervisor
$parent
$parentPropertyName
Parent property name.
protected
string|null
$parentPropertyName
= null
$scheme
protected
string
$scheme
= ''
$size
Font Size.
protected
float|null
$size
= 11
$strikethrough
Strikethrough.
protected
bool|null
$strikethrough
= false
$subscript
Subscript.
protected
bool|null
$subscript
= false
$superscript
Superscript.
protected
bool|null
$superscript
= false
$underline
Underline.
protected
string|null
$underline
= self::UNDERLINE_NONE
$baseLine
private
int
$baseLine
= 0
$chartColor
private
ChartColor|null
$chartColor
= null
$complexScript
private
string
$complexScript
= ''
$eastAsian
private
string
$eastAsian
= ''
$latin
The following 7 are used only for chart titles, I think.
private
string
$latin
= ''
$strikeType
private
string
$strikeType
= ''
$underlineColor
private
ChartColor|null
$underlineColor
= null
Methods
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
public
__clone() : mixed
__construct()
Create a new Font.
public
__construct([bool $isSupervisor = false ][, bool $isConditional = false ]) : mixed
Parameters
- $isSupervisor : bool = false
-
Flag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are
- $isConditional : bool = false
-
Flag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are
applyFromArray()
Apply styles from array.
public
applyFromArray(array<string|int, mixed> $styleArray) : $this
$spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
[
'name' => 'Arial',
'bold' => TRUE,
'italic' => FALSE,
'underline' => \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE,
'strikethrough' => FALSE,
'color' => [
'rgb' => '808080'
]
]
);
Parameters
- $styleArray : array<string|int, mixed>
-
Array containing style information
Return values
$thisbindParent()
Bind parent. Only used for supervisor.
public
bindParent(Spreadsheet|self $parent[, string|null $parentPropertyName = null ]) : $this
Parameters
- $parent : Spreadsheet|self
- $parentPropertyName : string|null = null
Return values
$thisexportArray()
Export style as array.
public
final exportArray() : array<string|int, mixed>
Available to anything which extends this class: Alignment, Border, Borders, Color, Fill, Font, NumberFormat, Protection, and Style.
Return values
array<string|int, mixed>getActiveCell()
Get the currently active cell coordinate in currently active sheet.
public
getActiveCell() : string
Only used for supervisor.
Return values
string —E.g. 'A1'
getActiveSheet()
Get the currently active sheet. Only used for supervisor.
public
getActiveSheet() : Worksheet
Return values
WorksheetgetBaseLine()
public
getBaseLine() : int
Return values
intgetBold()
Get Bold.
public
getBold() : bool|null
Return values
bool|nullgetCap()
public
getCap() : string|null
Return values
string|nullgetChartColor()
public
getChartColor() : ChartColor|null
Return values
ChartColor|nullgetColor()
Get Color.
public
getColor() : Color
Return values
ColorgetComplexScript()
public
getComplexScript() : string
Return values
stringgetEastAsian()
public
getEastAsian() : string
Return values
stringgetHashCode()
Get hash code.
public
getHashCode() : string
Return values
string —Hash code
getIsSupervisor()
Is this a supervisor or a cell style component?
public
getIsSupervisor() : bool
Return values
boolgetItalic()
Get Italic.
public
getItalic() : bool|null
Return values
bool|nullgetLatin()
public
getLatin() : string
Return values
stringgetName()
Get Name.
public
getName() : string|null
Return values
string|nullgetScheme()
public
getScheme() : string
Return values
stringgetSelectedCells()
Get the currently active cell coordinate in currently active sheet.
public
getSelectedCells() : string
Only used for supervisor.
Return values
string —E.g. 'A1'
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
public
getSharedComponent() : self
Only used for style supervisor.
Return values
selfgetSize()
Get Size.
public
getSize() : float|null
Return values
float|nullgetStrikethrough()
Get Strikethrough.
public
getStrikethrough() : bool|null
Return values
bool|nullgetStrikeType()
public
getStrikeType() : string
Return values
stringgetStyleArray()
Build style array from subcomponents.
public
getStyleArray(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed>getSubscript()
Get Subscript.
public
getSubscript() : bool|null
Return values
bool|nullgetSuperscript()
Get Superscript.
public
getSuperscript() : bool|null
Return values
bool|nullgetUnderline()
Get Underline.
public
getUnderline() : string|null
Return values
string|nullgetUnderlineColor()
public
getUnderlineColor() : ChartColor|null
Return values
ChartColor|nullsetBaseLine()
public
setBaseLine(int $baseLine) : self
Parameters
- $baseLine : int
Return values
selfsetBold()
Set Bold.
public
setBold(bool $bold) : $this
Parameters
- $bold : bool
Return values
$thissetCap()
Set capitalization attribute. If not one of the permitted values (all, small, or none), set it to null.
public
setCap(string $cap) : self
This will be honored only for the font for chart titles. None is distinguished from null because null will inherit the current value, whereas 'none' will override it.
Parameters
- $cap : string
Return values
selfsetChartColor()
public
setChartColor(array<string|int, mixed> $colorArray) : self
Parameters
- $colorArray : array<string|int, mixed>
Return values
selfsetChartColorFromObject()
public
setChartColorFromObject(ChartColor|null $chartColor) : self
Parameters
- $chartColor : ChartColor|null
Return values
selfsetColor()
Set Color.
public
setColor(Color $color) : $this
Parameters
- $color : Color
Return values
$thissetComplexScript()
public
setComplexScript(string $fontname) : self
Parameters
- $fontname : string
Return values
selfsetEastAsian()
public
setEastAsian(string $fontname) : self
Parameters
- $fontname : string
Return values
selfsetItalic()
Set Italic.
public
setItalic(bool $italic) : $this
Parameters
- $italic : bool
Return values
$thissetLatin()
public
setLatin(string $fontname) : self
Parameters
- $fontname : string
Return values
selfsetName()
Set Name and turn off Scheme.
public
setName(string $fontname) : self
Parameters
- $fontname : string
Return values
selfsetScheme()
public
setScheme(string $scheme) : self
Parameters
- $scheme : string
Return values
selfsetSize()
Set Size.
public
setSize(mixed $sizeInPoints[, bool $nullOk = false ]) : $this
Parameters
- $sizeInPoints : mixed
-
A float representing the value of a positive measurement in points (1/72 of an inch)
- $nullOk : bool = false
Return values
$thissetStrikethrough()
Set Strikethrough.
public
setStrikethrough(bool $strikethru) : $this
Parameters
- $strikethru : bool
Return values
$thissetStrikeType()
public
setStrikeType(string $strikeType) : self
Parameters
- $strikeType : string
Return values
selfsetSubscript()
Set Subscript.
public
setSubscript(bool $subscript) : $this
Parameters
- $subscript : bool
Return values
$thissetSuperscript()
Set Superscript.
public
setSuperscript(bool $superscript) : $this
Parameters
- $superscript : bool
Return values
$thissetUnderline()
Set Underline.
public
setUnderline(bool|string $underlineStyle) : $this
Parameters
- $underlineStyle : bool|string
-
\PhpOffice\PhpSpreadsheet\Style\Font underline type If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE, false equates to UNDERLINE_NONE
Return values
$thissetUnderlineColor()
public
setUnderlineColor(array<string|int, mixed> $colorArray) : self
Parameters
- $colorArray : array<string|int, mixed>
Return values
selfexportArray1()
Abstract method to be implemented in anything which extends this class.
protected
exportArray1() : array<string|int, mixed>
This method invokes exportArray2 with the names and values of all properties to be included in output array, returning that array to exportArray, then to caller.
Return values
array<string|int, mixed>exportArray2()
Populate array from exportArray1.
protected
final exportArray2(array<string|int, mixed> &$exportedArray, string $index, mixed $objOrValue) : void
This method is available to anything which extends this class. The parameter index is the key to be added to the array. The parameter objOrValue is either a primitive type, which is the value added to the array, or a Style object to be recursively added via exportArray.
Parameters
- $exportedArray : array<string|int, mixed>
- $index : string
- $objOrValue : mixed
hashChartColor()
private
hashChartColor(ChartColor|null $underlineColor) : string
Parameters
- $underlineColor : ChartColor|null