Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

File Size: 763 lines (27 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Font  - X-Ref

setAutoSizeMethod($pValue)   X-Ref
Set autoSize method.

param: string $pValue see self::AUTOSIZE_METHOD_*
return: bool Success or failure

getAutoSizeMethod()   X-Ref
Get autoSize method.

return: string

setTrueTypeFontPath($pValue)   X-Ref
Set the path to the folder containing .ttf files. There should be a trailing slash.
Typical locations on variout some platforms:
<ul>
<li>C:/Windows/Fonts/</li>
<li>/usr/share/fonts/truetype/</li>
<li>~/.fonts/</li>
</ul>.

param: string $pValue

getTrueTypeFontPath()   X-Ref
Get the path to the folder containing .ttf files.

return: string

calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, ?\PhpOffice\PhpSpreadsheet\Style\Font $defaultFont = null)   X-Ref
Calculate an (approximate) OpenXML column width, based on font size and text contained.

param: \PhpOffice\PhpSpreadsheet\Style\Font $font Font object
param: RichText|string $cellText Text to calculate width
param: int $rotation Rotation angle
param: null|\PhpOffice\PhpSpreadsheet\Style\Font $defaultFont Font object
return: int Column width

getTextWidthPixelsExact($text, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0)   X-Ref
Get GD text width in pixels for a string of text in a certain font at a certain rotation angle.

param: string $text
param: \PhpOffice\PhpSpreadsheet\Style\Font
param: int $rotation
return: int

getTextWidthPixelsApprox($columnText, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0)   X-Ref
Get approximate width in pixels for a string of text in a certain font at a certain rotation angle.

param: string $columnText
param: int $rotation
return: int Text width in pixels (no padding added)

fontSizeToPixels($fontSizeInPoints)   X-Ref
Calculate an (approximate) pixel size, based on a font points size.

param: int $fontSizeInPoints Font size (in points)
return: int Font size (in pixels)

inchSizeToPixels($sizeInInch)   X-Ref
Calculate an (approximate) pixel size, based on inch size.

param: int $sizeInInch Font size (in inch)
return: int Size (in pixels)

centimeterSizeToPixels($sizeInCm)   X-Ref
Calculate an (approximate) pixel size, based on centimeter size.

param: int $sizeInCm Font size (in centimeters)
return: float Size (in pixels)

getTrueTypeFontFileFromFont($font)   X-Ref
Returns the font path given the font.

param: \PhpOffice\PhpSpreadsheet\Style\Font $font
return: string Path to TrueType font file

getCharsetFromFontName($name)   X-Ref
Returns the associated charset for the font name.

param: string $name Font name
return: int Character set code

getDefaultColumnWidthByFont(\PhpOffice\PhpSpreadsheet\Style\Font $font, $pPixels = false)   X-Ref
Get the effective column width for columns without a column dimension or column with width -1
For example, for Calibri 11 this is 9.140625 (64 px).

param: \PhpOffice\PhpSpreadsheet\Style\Font $font The workbooks default font
param: bool $pPixels true = return column width in pixels, false = return in OOXML units
return: mixed Column width

getDefaultRowHeightByFont(\PhpOffice\PhpSpreadsheet\Style\Font $font)   X-Ref
Get the effective row height for rows without a row dimension or rows with height -1
For example, for Calibri 11 this is 15 points.

param: \PhpOffice\PhpSpreadsheet\Style\Font $font The workbooks default font
return: float Row height in points