Documentation

Font
in package

Table of Contents

Constants

ARIAL  = 'arial.ttf'
Font filenames
ARIAL_BOLD  = 'arialbd.ttf'
ARIAL_BOLD_ITALIC  = 'arialbi.ttf'
ARIAL_ITALIC  = 'ariali.ttf'
AUTOSIZE_METHOD_APPROX  = 'approx'
AUTOSIZE_METHOD_EXACT  = 'exact'
CALIBRI  = 'calibri.ttf'
CALIBRI_BOLD  = 'calibrib.ttf'
CALIBRI_BOLD_ITALIC  = 'calibriz.ttf'
CALIBRI_ITALIC  = 'calibrii.ttf'
CHARSET_ANSI_ARABIC  = 0xb2
CHARSET_ANSI_BALTIC  = 0xba
CHARSET_ANSI_CHINESE_SIMIPLIFIED  = 0x86
CHARSET_ANSI_CHINESE_TRADITIONAL  = 0x88
CHARSET_ANSI_CYRILLIC  = 0xcc
CHARSET_ANSI_GREEK  = 0xa1
CHARSET_ANSI_HEBREW  = 0xb1
CHARSET_ANSI_JAPANESE_SHIFTJIS  = 0x80
CHARSET_ANSI_KOREAN_HANGUL  = 0x81
CHARSET_ANSI_KOREAN_JOHAB  = 0x82
CHARSET_ANSI_LATIN  = 0x0
Character set codes used by BIFF5-8 in Font records
CHARSET_ANSI_LATIN_II  = 0xee
CHARSET_ANSI_THAI  = 0xdd
CHARSET_ANSI_TURKISH  = 0xa2
CHARSET_ANSI_VIETNAMESE  = 0xa3
CHARSET_APPLE_ROMAN  = 0x4d
CHARSET_FROM_FONT_NAME  = ['EucrosiaUPC' => self::CHARSET_ANSI_THAI, 'Wingdings' => self::CHARSET_SYMBOL, 'Wingdings 2' => self::CHARSET_SYMBOL, 'Wingdings 3' => self::CHARSET_SYMBOL]
CHARSET_OEM_LATIN_I  = 0xff
CHARSET_SYMBOL  = 0x2
CHARSET_SYSTEM_DEFAULT  = 0x1
COMIC_SANS_MS  = 'comic.ttf'
COMIC_SANS_MS_BOLD  = 'comicbd.ttf'
COURIER_NEW  = 'cour.ttf'
COURIER_NEW_BOLD  = 'courbd.ttf'
COURIER_NEW_BOLD_ITALIC  = 'courbi.ttf'
COURIER_NEW_ITALIC  = 'couri.ttf'
DEFAULT_COLUMN_WIDTHS  = ['Arial' => [1 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 2 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 3 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.0], 4 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.75], 5 => ['px' => 40, 'width' => 10.0, 'height' => 8.25], 6 => ['px' => 48, 'width' => 9.59765625, 'height' => 8.25], 7 => ['px' => 48, 'width' => 9.59765625, 'height' => 9.0], 8 => ['px' => 56, 'width' => 9.33203125, 'height' => 11.25], 9 => ['px' => 64, 'width' => 9.140625, 'height' => 12.0], 10 => ['px' => 64, 'width' => 9.140625, 'height' => 12.75]], 'Calibri' => [1 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 2 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 3 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.0], 4 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.75], 5 => ['px' => 40, 'width' => 10.0, 'height' => 8.25], 6 => ['px' => 48, 'width' => 9.59765625, 'height' => 8.25], 7 => ['px' => 48, 'width' => 9.59765625, 'height' => 9.0], 8 => ['px' => 56, 'width' => 9.33203125, 'height' => 11.25], 9 => ['px' => 56, 'width' => 9.33203125, 'height' => 12.0], 10 => ['px' => 64, 'width' => 9.140625, 'height' => 12.75], 11 => ['px' => 64, 'width' => 9.140625, 'height' => 15.0]], 'Verdana' => [1 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 2 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 3 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.0], 4 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.75], 5 => ['px' => 40, 'width' => 10.0, 'height' => 8.25], 6 => ['px' => 48, 'width' => 9.59765625, 'height' => 8.25], 7 => ['px' => 48, 'width' => 9.59765625, 'height' => 9.0], 8 => ['px' => 64, 'width' => 9.140625, 'height' => 10.5], 9 => ['px' => 72, 'width' => 9.0, 'height' => 11.25], 10 => ['px' => 72, 'width' => 9.0, 'height' => 12.75]]]
How wide is a default column for a given default font and size? Empirical data found by inspecting real Excel files and reading off the pixel width in Microsoft Office Excel 2007.
FONT_FILE_NAMES  = ['Arial' => ['x' => self::ARIAL, 'xb' => self::ARIAL_BOLD, 'xi' => self::ARIAL_ITALIC, 'xbi' => self::ARIAL_BOLD_ITALIC], 'Calibri' => ['x' => self::CALIBRI, 'xb' => self::CALIBRI_BOLD, 'xi' => self::CALIBRI_ITALIC, 'xbi' => self::CALIBRI_BOLD_ITALIC], 'Comic Sans MS' => ['x' => self::COMIC_SANS_MS, 'xb' => self::COMIC_SANS_MS_BOLD, 'xi' => self::COMIC_SANS_MS, 'xbi' => self::COMIC_SANS_MS_BOLD], 'Courier New' => ['x' => self::COURIER_NEW, 'xb' => self::COURIER_NEW_BOLD, 'xi' => self::COURIER_NEW_ITALIC, 'xbi' => self::COURIER_NEW_BOLD_ITALIC], 'Georgia' => ['x' => self::GEORGIA, 'xb' => self::GEORGIA_BOLD, 'xi' => self::GEORGIA_ITALIC, 'xbi' => self::GEORGIA_BOLD_ITALIC], 'Impact' => ['x' => self::IMPACT, 'xb' => self::IMPACT, 'xi' => self::IMPACT, 'xbi' => self::IMPACT], 'Liberation Sans' => ['x' => self::LIBERATION_SANS, 'xb' => self::LIBERATION_SANS_BOLD, 'xi' => self::LIBERATION_SANS_ITALIC, 'xbi' => self::LIBERATION_SANS_BOLD_ITALIC], 'Lucida Console' => ['x' => self::LUCIDA_CONSOLE, 'xb' => self::LUCIDA_CONSOLE, 'xi' => self::LUCIDA_CONSOLE, 'xbi' => self::LUCIDA_CONSOLE], 'Lucida Sans Unicode' => ['x' => self::LUCIDA_SANS_UNICODE, 'xb' => self::LUCIDA_SANS_UNICODE, 'xi' => self::LUCIDA_SANS_UNICODE, 'xbi' => self::LUCIDA_SANS_UNICODE], 'Microsoft Sans Serif' => ['x' => self::MICROSOFT_SANS_SERIF, 'xb' => self::MICROSOFT_SANS_SERIF, 'xi' => self::MICROSOFT_SANS_SERIF, 'xbi' => self::MICROSOFT_SANS_SERIF], 'Palatino Linotype' => ['x' => self::PALATINO_LINOTYPE, 'xb' => self::PALATINO_LINOTYPE_BOLD, 'xi' => self::PALATINO_LINOTYPE_ITALIC, 'xbi' => self::PALATINO_LINOTYPE_BOLD_ITALIC], 'Symbol' => ['x' => self::SYMBOL, 'xb' => self::SYMBOL, 'xi' => self::SYMBOL, 'xbi' => self::SYMBOL], 'Tahoma' => ['x' => self::TAHOMA, 'xb' => self::TAHOMA_BOLD, 'xi' => self::TAHOMA, 'xbi' => self::TAHOMA_BOLD], 'Times New Roman' => ['x' => self::TIMES_NEW_ROMAN, 'xb' => self::TIMES_NEW_ROMAN_BOLD, 'xi' => self::TIMES_NEW_ROMAN_ITALIC, 'xbi' => self::TIMES_NEW_ROMAN_BOLD_ITALIC], 'Trebuchet MS' => ['x' => self::TREBUCHET_MS, 'xb' => self::TREBUCHET_MS_BOLD, 'xi' => self::TREBUCHET_MS_ITALIC, 'xbi' => self::TREBUCHET_MS_BOLD_ITALIC], 'Verdana' => ['x' => self::VERDANA, 'xb' => self::VERDANA_BOLD, 'xi' => self::VERDANA_ITALIC, 'xbi' => self::VERDANA_BOLD_ITALIC]]
GEORGIA  = 'georgia.ttf'
GEORGIA_BOLD  = 'georgiab.ttf'
GEORGIA_BOLD_ITALIC  = 'georgiaz.ttf'
GEORGIA_ITALIC  = 'georgiai.ttf'
IMPACT  = 'impact.ttf'
LIBERATION_SANS  = 'LiberationSans-Regular.ttf'
LIBERATION_SANS_BOLD  = 'LiberationSans-Bold.ttf'
LIBERATION_SANS_BOLD_ITALIC  = 'LiberationSans-BoldItalic.ttf'
LIBERATION_SANS_ITALIC  = 'LiberationSans-Italic.ttf'
LUCIDA_CONSOLE  = 'lucon.ttf'
LUCIDA_SANS_UNICODE  = 'l_10646.ttf'
MICROSOFT_SANS_SERIF  = 'micross.ttf'
PALATINO_LINOTYPE  = 'pala.ttf'
PALATINO_LINOTYPE_BOLD  = 'palab.ttf'
PALATINO_LINOTYPE_BOLD_ITALIC  = 'palabi.ttf'
PALATINO_LINOTYPE_ITALIC  = 'palai.ttf'
SYMBOL  = 'symbol.ttf'
TAHOMA  = 'tahoma.ttf'
TAHOMA_BOLD  = 'tahomabd.ttf'
TIMES_NEW_ROMAN  = 'times.ttf'
TIMES_NEW_ROMAN_BOLD  = 'timesbd.ttf'
TIMES_NEW_ROMAN_BOLD_ITALIC  = 'timesbi.ttf'
TIMES_NEW_ROMAN_ITALIC  = 'timesi.ttf'
TREBUCHET_MS  = 'trebuc.ttf'
TREBUCHET_MS_BOLD  = 'trebucbd.ttf'
TREBUCHET_MS_BOLD_ITALIC  = 'trebucbi.ttf'
TREBUCHET_MS_ITALIC  = 'trebucit.ttf'
VERDANA  = 'verdana.ttf'
VERDANA_BOLD  = 'verdanab.ttf'
VERDANA_BOLD_ITALIC  = 'verdanaz.ttf'
VERDANA_ITALIC  = 'verdanai.ttf'
AUTOSIZE_METHODS  = [self::AUTOSIZE_METHOD_APPROX, self::AUTOSIZE_METHOD_EXACT]

Properties

$autoSizeMethod  : string
AutoSize method.
$extraFontArray  : array<string, array<string, string>>
Array that can be used to supplement FONT_FILE_NAMES for calculating exact width.
$paddingAmountExact  : null|float|int
Pad amount for exact in pixels; use best guess if null.
$trueTypeFontPath  : string
Path to folder containing TrueType font .ttf files.

Methods

calculateColumnWidth()  : float
Calculate an (approximate) OpenXML column width, based on font size and text contained.
centimeterSizeToPixels()  : float
Calculate an (approximate) pixel size, based on centimeter size.
fontSizeToPixels()  : int
Calculate an (approximate) pixel size, based on a font points size.
getAutoSizeMethod()  : string
Get autoSize method.
getCharsetFromFontName()  : int
Returns the associated charset for the font name.
getDefaultColumnWidthByFont()  : mixed
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).
getDefaultRowHeightByFont()  : float
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.
getExtraFontArray()  : array<string, array<string, string>>
getPaddingAmountExact()  : null|float|int
Get pad amount for exact in pixels; or null if using best guess.
getTextWidthPixelsApprox()  : int
Get approximate width in pixels for a string of text in a certain font at a certain rotation angle.
getTextWidthPixelsExact()  : float
Get GD text width in pixels for a string of text in a certain font at a certain rotation angle.
getTrueTypeFontFileFromFont()  : string
Returns the font path given the font.
getTrueTypeFontPath()  : string
Get the path to the folder containing .ttf files.
inchSizeToPixels()  : float|int
Calculate an (approximate) pixel size, based on inch size.
setAutoSizeMethod()  : bool
Set autoSize method.
setExtraFontArray()  : void
setPaddingAmountExact()  : void
Set pad amount for exact in pixels; use best guess if null.
setTrueTypeFontPath()  : void
Set the path to the folder containing .ttf files. There should be a trailing slash.
findFontFile()  : string|null

Constants

ARIAL

Font filenames

public mixed ARIAL = 'arial.ttf'

ARIAL_BOLD

public mixed ARIAL_BOLD = 'arialbd.ttf'

ARIAL_BOLD_ITALIC

public mixed ARIAL_BOLD_ITALIC = 'arialbi.ttf'

ARIAL_ITALIC

public mixed ARIAL_ITALIC = 'ariali.ttf'

AUTOSIZE_METHOD_APPROX

public mixed AUTOSIZE_METHOD_APPROX = 'approx'

AUTOSIZE_METHOD_EXACT

public mixed AUTOSIZE_METHOD_EXACT = 'exact'

CALIBRI

public mixed CALIBRI = 'calibri.ttf'

CALIBRI_BOLD

public mixed CALIBRI_BOLD = 'calibrib.ttf'

CALIBRI_BOLD_ITALIC

public mixed CALIBRI_BOLD_ITALIC = 'calibriz.ttf'

CALIBRI_ITALIC

public mixed CALIBRI_ITALIC = 'calibrii.ttf'

CHARSET_ANSI_ARABIC

public mixed CHARSET_ANSI_ARABIC = 0xb2

CHARSET_ANSI_BALTIC

public mixed CHARSET_ANSI_BALTIC = 0xba

CHARSET_ANSI_CHINESE_SIMIPLIFIED

public mixed CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86

CHARSET_ANSI_CHINESE_TRADITIONAL

public mixed CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88

CHARSET_ANSI_CYRILLIC

public mixed CHARSET_ANSI_CYRILLIC = 0xcc

CHARSET_ANSI_GREEK

public mixed CHARSET_ANSI_GREEK = 0xa1

CHARSET_ANSI_HEBREW

public mixed CHARSET_ANSI_HEBREW = 0xb1

CHARSET_ANSI_JAPANESE_SHIFTJIS

public mixed CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80

CHARSET_ANSI_KOREAN_HANGUL

public mixed CHARSET_ANSI_KOREAN_HANGUL = 0x81

CHARSET_ANSI_KOREAN_JOHAB

public mixed CHARSET_ANSI_KOREAN_JOHAB = 0x82

CHARSET_ANSI_LATIN

Character set codes used by BIFF5-8 in Font records

public mixed CHARSET_ANSI_LATIN = 0x0

CHARSET_ANSI_LATIN_II

public mixed CHARSET_ANSI_LATIN_II = 0xee

CHARSET_ANSI_THAI

public mixed CHARSET_ANSI_THAI = 0xdd

CHARSET_ANSI_TURKISH

public mixed CHARSET_ANSI_TURKISH = 0xa2

CHARSET_ANSI_VIETNAMESE

public mixed CHARSET_ANSI_VIETNAMESE = 0xa3

CHARSET_APPLE_ROMAN

public mixed CHARSET_APPLE_ROMAN = 0x4d

CHARSET_FROM_FONT_NAME

public mixed CHARSET_FROM_FONT_NAME = ['EucrosiaUPC' => self::CHARSET_ANSI_THAI, 'Wingdings' => self::CHARSET_SYMBOL, 'Wingdings 2' => self::CHARSET_SYMBOL, 'Wingdings 3' => self::CHARSET_SYMBOL]

CHARSET_OEM_LATIN_I

public mixed CHARSET_OEM_LATIN_I = 0xff

CHARSET_SYMBOL

public mixed CHARSET_SYMBOL = 0x2

CHARSET_SYSTEM_DEFAULT

public mixed CHARSET_SYSTEM_DEFAULT = 0x1

COMIC_SANS_MS

public mixed COMIC_SANS_MS = 'comic.ttf'

COMIC_SANS_MS_BOLD

public mixed COMIC_SANS_MS_BOLD = 'comicbd.ttf'

COURIER_NEW

public mixed COURIER_NEW = 'cour.ttf'

COURIER_NEW_BOLD

public mixed COURIER_NEW_BOLD = 'courbd.ttf'

COURIER_NEW_BOLD_ITALIC

public mixed COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'

COURIER_NEW_ITALIC

public mixed COURIER_NEW_ITALIC = 'couri.ttf'

DEFAULT_COLUMN_WIDTHS

How wide is a default column for a given default font and size? Empirical data found by inspecting real Excel files and reading off the pixel width in Microsoft Office Excel 2007.

public mixed DEFAULT_COLUMN_WIDTHS = ['Arial' => [1 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 2 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 3 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.0], 4 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.75], 5 => ['px' => 40, 'width' => 10.0, 'height' => 8.25], 6 => ['px' => 48, 'width' => 9.59765625, 'height' => 8.25], 7 => ['px' => 48, 'width' => 9.59765625, 'height' => 9.0], 8 => ['px' => 56, 'width' => 9.33203125, 'height' => 11.25], 9 => ['px' => 64, 'width' => 9.140625, 'height' => 12.0], 10 => ['px' => 64, 'width' => 9.140625, 'height' => 12.75]], 'Calibri' => [1 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 2 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 3 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.0], 4 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.75], 5 => ['px' => 40, 'width' => 10.0, 'height' => 8.25], 6 => ['px' => 48, 'width' => 9.59765625, 'height' => 8.25], 7 => ['px' => 48, 'width' => 9.59765625, 'height' => 9.0], 8 => ['px' => 56, 'width' => 9.33203125, 'height' => 11.25], 9 => ['px' => 56, 'width' => 9.33203125, 'height' => 12.0], 10 => ['px' => 64, 'width' => 9.140625, 'height' => 12.75], 11 => ['px' => 64, 'width' => 9.140625, 'height' => 15.0]], 'Verdana' => [1 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 2 => ['px' => 24, 'width' => 12.0, 'height' => 5.25], 3 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.0], 4 => ['px' => 32, 'width' => 10.6640625, 'height' => 6.75], 5 => ['px' => 40, 'width' => 10.0, 'height' => 8.25], 6 => ['px' => 48, 'width' => 9.59765625, 'height' => 8.25], 7 => ['px' => 48, 'width' => 9.59765625, 'height' => 9.0], 8 => ['px' => 64, 'width' => 9.140625, 'height' => 10.5], 9 => ['px' => 72, 'width' => 9.0, 'height' => 11.25], 10 => ['px' => 72, 'width' => 9.0, 'height' => 12.75]]]

Added height in points.

FONT_FILE_NAMES

public mixed FONT_FILE_NAMES = ['Arial' => ['x' => self::ARIAL, 'xb' => self::ARIAL_BOLD, 'xi' => self::ARIAL_ITALIC, 'xbi' => self::ARIAL_BOLD_ITALIC], 'Calibri' => ['x' => self::CALIBRI, 'xb' => self::CALIBRI_BOLD, 'xi' => self::CALIBRI_ITALIC, 'xbi' => self::CALIBRI_BOLD_ITALIC], 'Comic Sans MS' => ['x' => self::COMIC_SANS_MS, 'xb' => self::COMIC_SANS_MS_BOLD, 'xi' => self::COMIC_SANS_MS, 'xbi' => self::COMIC_SANS_MS_BOLD], 'Courier New' => ['x' => self::COURIER_NEW, 'xb' => self::COURIER_NEW_BOLD, 'xi' => self::COURIER_NEW_ITALIC, 'xbi' => self::COURIER_NEW_BOLD_ITALIC], 'Georgia' => ['x' => self::GEORGIA, 'xb' => self::GEORGIA_BOLD, 'xi' => self::GEORGIA_ITALIC, 'xbi' => self::GEORGIA_BOLD_ITALIC], 'Impact' => ['x' => self::IMPACT, 'xb' => self::IMPACT, 'xi' => self::IMPACT, 'xbi' => self::IMPACT], 'Liberation Sans' => ['x' => self::LIBERATION_SANS, 'xb' => self::LIBERATION_SANS_BOLD, 'xi' => self::LIBERATION_SANS_ITALIC, 'xbi' => self::LIBERATION_SANS_BOLD_ITALIC], 'Lucida Console' => ['x' => self::LUCIDA_CONSOLE, 'xb' => self::LUCIDA_CONSOLE, 'xi' => self::LUCIDA_CONSOLE, 'xbi' => self::LUCIDA_CONSOLE], 'Lucida Sans Unicode' => ['x' => self::LUCIDA_SANS_UNICODE, 'xb' => self::LUCIDA_SANS_UNICODE, 'xi' => self::LUCIDA_SANS_UNICODE, 'xbi' => self::LUCIDA_SANS_UNICODE], 'Microsoft Sans Serif' => ['x' => self::MICROSOFT_SANS_SERIF, 'xb' => self::MICROSOFT_SANS_SERIF, 'xi' => self::MICROSOFT_SANS_SERIF, 'xbi' => self::MICROSOFT_SANS_SERIF], 'Palatino Linotype' => ['x' => self::PALATINO_LINOTYPE, 'xb' => self::PALATINO_LINOTYPE_BOLD, 'xi' => self::PALATINO_LINOTYPE_ITALIC, 'xbi' => self::PALATINO_LINOTYPE_BOLD_ITALIC], 'Symbol' => ['x' => self::SYMBOL, 'xb' => self::SYMBOL, 'xi' => self::SYMBOL, 'xbi' => self::SYMBOL], 'Tahoma' => ['x' => self::TAHOMA, 'xb' => self::TAHOMA_BOLD, 'xi' => self::TAHOMA, 'xbi' => self::TAHOMA_BOLD], 'Times New Roman' => ['x' => self::TIMES_NEW_ROMAN, 'xb' => self::TIMES_NEW_ROMAN_BOLD, 'xi' => self::TIMES_NEW_ROMAN_ITALIC, 'xbi' => self::TIMES_NEW_ROMAN_BOLD_ITALIC], 'Trebuchet MS' => ['x' => self::TREBUCHET_MS, 'xb' => self::TREBUCHET_MS_BOLD, 'xi' => self::TREBUCHET_MS_ITALIC, 'xbi' => self::TREBUCHET_MS_BOLD_ITALIC], 'Verdana' => ['x' => self::VERDANA, 'xb' => self::VERDANA_BOLD, 'xi' => self::VERDANA_ITALIC, 'xbi' => self::VERDANA_BOLD_ITALIC]]

GEORGIA

public mixed GEORGIA = 'georgia.ttf'

GEORGIA_BOLD

public mixed GEORGIA_BOLD = 'georgiab.ttf'

GEORGIA_BOLD_ITALIC

public mixed GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'

GEORGIA_ITALIC

public mixed GEORGIA_ITALIC = 'georgiai.ttf'

IMPACT

public mixed IMPACT = 'impact.ttf'

LIBERATION_SANS

public mixed LIBERATION_SANS = 'LiberationSans-Regular.ttf'

LIBERATION_SANS_BOLD

public mixed LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'

LIBERATION_SANS_BOLD_ITALIC

public mixed LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'

LIBERATION_SANS_ITALIC

public mixed LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'

LUCIDA_CONSOLE

public mixed LUCIDA_CONSOLE = 'lucon.ttf'

LUCIDA_SANS_UNICODE

public mixed LUCIDA_SANS_UNICODE = 'l_10646.ttf'

MICROSOFT_SANS_SERIF

public mixed MICROSOFT_SANS_SERIF = 'micross.ttf'

PALATINO_LINOTYPE

public mixed PALATINO_LINOTYPE = 'pala.ttf'

PALATINO_LINOTYPE_BOLD

public mixed PALATINO_LINOTYPE_BOLD = 'palab.ttf'

PALATINO_LINOTYPE_BOLD_ITALIC

public mixed PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'

PALATINO_LINOTYPE_ITALIC

public mixed PALATINO_LINOTYPE_ITALIC = 'palai.ttf'

SYMBOL

public mixed SYMBOL = 'symbol.ttf'

TAHOMA

public mixed TAHOMA = 'tahoma.ttf'

TAHOMA_BOLD

public mixed TAHOMA_BOLD = 'tahomabd.ttf'

TIMES_NEW_ROMAN

public mixed TIMES_NEW_ROMAN = 'times.ttf'

TIMES_NEW_ROMAN_BOLD

public mixed TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'

TIMES_NEW_ROMAN_BOLD_ITALIC

public mixed TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'

TIMES_NEW_ROMAN_ITALIC

public mixed TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'

TREBUCHET_MS

public mixed TREBUCHET_MS = 'trebuc.ttf'

TREBUCHET_MS_BOLD

public mixed TREBUCHET_MS_BOLD = 'trebucbd.ttf'

TREBUCHET_MS_BOLD_ITALIC

public mixed TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'

TREBUCHET_MS_ITALIC

public mixed TREBUCHET_MS_ITALIC = 'trebucit.ttf'

VERDANA

public mixed VERDANA = 'verdana.ttf'

VERDANA_BOLD

public mixed VERDANA_BOLD = 'verdanab.ttf'

VERDANA_BOLD_ITALIC

public mixed VERDANA_BOLD_ITALIC = 'verdanaz.ttf'

VERDANA_ITALIC

public mixed VERDANA_ITALIC = 'verdanai.ttf'

AUTOSIZE_METHODS

private mixed AUTOSIZE_METHODS = [self::AUTOSIZE_METHOD_APPROX, self::AUTOSIZE_METHOD_EXACT]

Properties

$autoSizeMethod

AutoSize method.

private static string $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX

$extraFontArray

Array that can be used to supplement FONT_FILE_NAMES for calculating exact width.

private static array<string, array<string, string>> $extraFontArray = []

$paddingAmountExact

Pad amount for exact in pixels; use best guess if null.

private static null|float|int $paddingAmountExact = null

$trueTypeFontPath

Path to folder containing TrueType font .ttf files.

private static string $trueTypeFontPath = ''

Methods

calculateColumnWidth()

Calculate an (approximate) OpenXML column width, based on font size and text contained.

public static calculateColumnWidth(Font $font[, null|RichText|string $cellText = '' ][, int $rotation = 0 ][, null|Font $defaultFont = null ][, bool $filterAdjustment = false ][, int $indentAdjustment = 0 ]) : float
Parameters
$font : Font

Font object

$cellText : null|RichText|string = ''

Text to calculate width

$rotation : int = 0

Rotation angle

$defaultFont : null|Font = null

Font object

$filterAdjustment : bool = false

Add space for Autofilter or Table dropdown

$indentAdjustment : int = 0
Return values
float

centimeterSizeToPixels()

Calculate an (approximate) pixel size, based on centimeter size.

public static centimeterSizeToPixels(float|int $sizeInCm) : float
Parameters
$sizeInCm : float|int

Font size (in centimeters)

Return values
float

Size (in pixels)

fontSizeToPixels()

Calculate an (approximate) pixel size, based on a font points size.

public static fontSizeToPixels(float|int $fontSizeInPoints) : int
Parameters
$fontSizeInPoints : float|int

Font size (in points)

Return values
int

Font size (in pixels)

getAutoSizeMethod()

Get autoSize method.

public static getAutoSizeMethod() : string
Return values
string

getCharsetFromFontName()

Returns the associated charset for the font name.

public static getCharsetFromFontName(string $fontName) : int
Parameters
$fontName : string

Font name

Return values
int

Character set code

getDefaultColumnWidthByFont()

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).

public static getDefaultColumnWidthByFont(Font $font[, bool $returnAsPixels = false ]) : mixed
Parameters
$font : Font

The workbooks default font

$returnAsPixels : bool = false

true = return column width in pixels, false = return in OOXML units

Return values
mixed

Column width

getDefaultRowHeightByFont()

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.

public static getDefaultRowHeightByFont(Font $font) : float
Parameters
$font : Font

The workbooks default font

Return values
float

Row height in points

getExtraFontArray()

public static getExtraFontArray() : array<string, array<string, string>>
Return values
array<string, array<string, string>>

getPaddingAmountExact()

Get pad amount for exact in pixels; or null if using best guess.

public static getPaddingAmountExact() : null|float|int
Return values
null|float|int

getTextWidthPixelsApprox()

Get approximate width in pixels for a string of text in a certain font at a certain rotation angle.

public static getTextWidthPixelsApprox(string $columnText, Font $font[, int $rotation = 0 ]) : int
Parameters
$columnText : string
$font : Font
$rotation : int = 0
Return values
int

Text width in pixels (no padding added)

getTextWidthPixelsExact()

Get GD text width in pixels for a string of text in a certain font at a certain rotation angle.

public static getTextWidthPixelsExact(string $text, Font $font[, int $rotation = 0 ]) : float
Parameters
$text : string
$font : Font
$rotation : int = 0
Return values
float

getTrueTypeFontFileFromFont()

Returns the font path given the font.

public static getTrueTypeFontFileFromFont(Font $font[, bool $checkPath = true ]) : string
Parameters
$font : Font
$checkPath : bool = true
Return values
string

Path to TrueType font file

getTrueTypeFontPath()

Get the path to the folder containing .ttf files.

public static getTrueTypeFontPath() : string
Return values
string

inchSizeToPixels()

Calculate an (approximate) pixel size, based on inch size.

public static inchSizeToPixels(float|int $sizeInInch) : float|int
Parameters
$sizeInInch : float|int

Font size (in inch)

Return values
float|int

Size (in pixels)

setAutoSizeMethod()

Set autoSize method.

public static setAutoSizeMethod(string $method) : bool
Parameters
$method : string

see self::AUTOSIZE_METHOD_*

Return values
bool

Success or failure

setExtraFontArray()

public static setExtraFontArray(array<string, array<string, string>> $extraFontArray) : void
Parameters
$extraFontArray : array<string, array<string, string>>

setPaddingAmountExact()

Set pad amount for exact in pixels; use best guess if null.

public static setPaddingAmountExact(null|float|int $paddingAmountExact) : void
Parameters
$paddingAmountExact : null|float|int

setTrueTypeFontPath()

Set the path to the folder containing .ttf files. There should be a trailing slash.

public static setTrueTypeFontPath(string $folderPath) : void

Path will be recursively searched for font file. Typical locations on various platforms:

  • C:/Windows/Fonts/
  • /usr/share/fonts/truetype/
  • ~/.fonts/
.
Parameters
$folderPath : string

findFontFile()

private static findFontFile(string $startDirectory, string $desiredFont) : string|null
Parameters
$startDirectory : string
$desiredFont : string
Return values
string|null

        
On this page

Search results