\PHPExcel_Shared_Font

PHPExcel_Shared_Font

Summary

Methods
Properties
Constants
setAutoSizeMethod()
getAutoSizeMethod()
setTrueTypeFontPath()
getTrueTypeFontPath()
calculateColumnWidth()
getTextWidthPixelsExact()
getTextWidthPixelsApprox()
fontSizeToPixels()
inchSizeToPixels()
centimeterSizeToPixels()
getTrueTypeFontFileFromFont()
getCharsetFromFontName()
getDefaultColumnWidthByFont()
getDefaultRowHeightByFont()
$defaultColumnWidths
AUTOSIZE_METHOD_APPROX
AUTOSIZE_METHOD_EXACT
CHARSET_ANSI_LATIN
CHARSET_SYSTEM_DEFAULT
CHARSET_SYMBOL
CHARSET_APPLE_ROMAN
CHARSET_ANSI_JAPANESE_SHIFTJIS
CHARSET_ANSI_KOREAN_HANGUL
CHARSET_ANSI_KOREAN_JOHAB
CHARSET_ANSI_CHINESE_SIMIPLIFIED
CHARSET_ANSI_CHINESE_TRADITIONAL
CHARSET_ANSI_GREEK
CHARSET_ANSI_TURKISH
CHARSET_ANSI_VIETNAMESE
CHARSET_ANSI_HEBREW
CHARSET_ANSI_ARABIC
CHARSET_ANSI_BALTIC
CHARSET_ANSI_CYRILLIC
CHARSET_ANSI_THAI
CHARSET_ANSI_LATIN_II
CHARSET_OEM_LATIN_I
ARIAL
ARIAL_BOLD
ARIAL_ITALIC
ARIAL_BOLD_ITALIC
CALIBRI
CALIBRI_BOLD
CALIBRI_ITALIC
CALIBRI_BOLD_ITALIC
COMIC_SANS_MS
COMIC_SANS_MS_BOLD
COURIER_NEW
COURIER_NEW_BOLD
COURIER_NEW_ITALIC
COURIER_NEW_BOLD_ITALIC
GEORGIA
GEORGIA_BOLD
GEORGIA_ITALIC
GEORGIA_BOLD_ITALIC
IMPACT
LIBERATION_SANS
LIBERATION_SANS_BOLD
LIBERATION_SANS_ITALIC
LIBERATION_SANS_BOLD_ITALIC
LUCIDA_CONSOLE
LUCIDA_SANS_UNICODE
MICROSOFT_SANS_SERIF
PALATINO_LINOTYPE
PALATINO_LINOTYPE_BOLD
PALATINO_LINOTYPE_ITALIC
PALATINO_LINOTYPE_BOLD_ITALIC
SYMBOL
TAHOMA
TAHOMA_BOLD
TIMES_NEW_ROMAN
TIMES_NEW_ROMAN_BOLD
TIMES_NEW_ROMAN_ITALIC
TIMES_NEW_ROMAN_BOLD_ITALIC
TREBUCHET_MS
TREBUCHET_MS_BOLD
TREBUCHET_MS_ITALIC
TREBUCHET_MS_BOLD_ITALIC
VERDANA
VERDANA_BOLD
VERDANA_ITALIC
VERDANA_BOLD_ITALIC
No protected methods found
No protected properties found
N/A
No private methods found
$_autoSizeMethods
$autoSizeMethod
$trueTypeFontPath
N/A

Constants

AUTOSIZE_METHOD_APPROX

AUTOSIZE_METHOD_APPROX = 'approx'

AUTOSIZE_METHOD_EXACT

AUTOSIZE_METHOD_EXACT = 'exact'

CHARSET_ANSI_LATIN

CHARSET_ANSI_LATIN = 0

Character set codes used by BIFF5-8 in Font records

CHARSET_SYSTEM_DEFAULT

CHARSET_SYSTEM_DEFAULT = 1

CHARSET_SYMBOL

CHARSET_SYMBOL = 2

CHARSET_APPLE_ROMAN

CHARSET_APPLE_ROMAN = 77

CHARSET_ANSI_JAPANESE_SHIFTJIS

CHARSET_ANSI_JAPANESE_SHIFTJIS = 128

CHARSET_ANSI_KOREAN_HANGUL

CHARSET_ANSI_KOREAN_HANGUL = 129

CHARSET_ANSI_KOREAN_JOHAB

CHARSET_ANSI_KOREAN_JOHAB = 130

CHARSET_ANSI_CHINESE_SIMIPLIFIED

CHARSET_ANSI_CHINESE_SIMIPLIFIED = 134

CHARSET_ANSI_CHINESE_TRADITIONAL

CHARSET_ANSI_CHINESE_TRADITIONAL = 136

CHARSET_ANSI_GREEK

CHARSET_ANSI_GREEK = 161

CHARSET_ANSI_TURKISH

CHARSET_ANSI_TURKISH = 162

CHARSET_ANSI_VIETNAMESE

CHARSET_ANSI_VIETNAMESE = 163

CHARSET_ANSI_HEBREW

CHARSET_ANSI_HEBREW = 177

CHARSET_ANSI_ARABIC

CHARSET_ANSI_ARABIC = 178

CHARSET_ANSI_BALTIC

CHARSET_ANSI_BALTIC = 186

CHARSET_ANSI_CYRILLIC

CHARSET_ANSI_CYRILLIC = 204

CHARSET_ANSI_THAI

CHARSET_ANSI_THAI = 221

CHARSET_ANSI_LATIN_II

CHARSET_ANSI_LATIN_II = 238

CHARSET_OEM_LATIN_I

CHARSET_OEM_LATIN_I = 255

ARIAL

ARIAL = 'arial.ttf'

Font filenames

ARIAL_BOLD

ARIAL_BOLD = 'arialbd.ttf'

ARIAL_ITALIC

ARIAL_ITALIC = 'ariali.ttf'

ARIAL_BOLD_ITALIC

ARIAL_BOLD_ITALIC = 'arialbi.ttf'

CALIBRI

CALIBRI = 'CALIBRI.TTF'

CALIBRI_BOLD

CALIBRI_BOLD = 'CALIBRIB.TTF'

CALIBRI_ITALIC

CALIBRI_ITALIC = 'CALIBRII.TTF'

CALIBRI_BOLD_ITALIC

CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF'

COMIC_SANS_MS

COMIC_SANS_MS = 'comic.ttf'

COMIC_SANS_MS_BOLD

COMIC_SANS_MS_BOLD = 'comicbd.ttf'

COURIER_NEW

COURIER_NEW = 'cour.ttf'

COURIER_NEW_BOLD

COURIER_NEW_BOLD = 'courbd.ttf'

COURIER_NEW_ITALIC

COURIER_NEW_ITALIC = 'couri.ttf'

COURIER_NEW_BOLD_ITALIC

COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'

GEORGIA

GEORGIA = 'georgia.ttf'

GEORGIA_BOLD

GEORGIA_BOLD = 'georgiab.ttf'

GEORGIA_ITALIC

GEORGIA_ITALIC = 'georgiai.ttf'

GEORGIA_BOLD_ITALIC

GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'

IMPACT

IMPACT = 'impact.ttf'

LIBERATION_SANS

LIBERATION_SANS = 'LiberationSans-Regular.ttf'

LIBERATION_SANS_BOLD

LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'

LIBERATION_SANS_ITALIC

LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'

LIBERATION_SANS_BOLD_ITALIC

LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'

LUCIDA_CONSOLE

LUCIDA_CONSOLE = 'lucon.ttf'

LUCIDA_SANS_UNICODE

LUCIDA_SANS_UNICODE = 'l_10646.ttf'

MICROSOFT_SANS_SERIF

MICROSOFT_SANS_SERIF = 'micross.ttf'

PALATINO_LINOTYPE

PALATINO_LINOTYPE = 'pala.ttf'

PALATINO_LINOTYPE_BOLD

PALATINO_LINOTYPE_BOLD = 'palab.ttf'

PALATINO_LINOTYPE_ITALIC

PALATINO_LINOTYPE_ITALIC = 'palai.ttf'

PALATINO_LINOTYPE_BOLD_ITALIC

PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'

SYMBOL

SYMBOL = 'symbol.ttf'

TAHOMA

TAHOMA = 'tahoma.ttf'

TAHOMA_BOLD

TAHOMA_BOLD = 'tahomabd.ttf'

TIMES_NEW_ROMAN

TIMES_NEW_ROMAN = 'times.ttf'

TIMES_NEW_ROMAN_BOLD

TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'

TIMES_NEW_ROMAN_ITALIC

TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'

TIMES_NEW_ROMAN_BOLD_ITALIC

TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'

TREBUCHET_MS

TREBUCHET_MS = 'trebuc.ttf'

TREBUCHET_MS_BOLD

TREBUCHET_MS_BOLD = 'trebucbd.ttf'

TREBUCHET_MS_ITALIC

TREBUCHET_MS_ITALIC = 'trebucit.ttf'

TREBUCHET_MS_BOLD_ITALIC

TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'

VERDANA

VERDANA = 'verdana.ttf'

VERDANA_BOLD

VERDANA_BOLD = 'verdanab.ttf'

VERDANA_ITALIC

VERDANA_ITALIC = 'verdanai.ttf'

VERDANA_BOLD_ITALIC

VERDANA_BOLD_ITALIC = 'verdanaz.ttf'

Properties

$defaultColumnWidths

$defaultColumnWidths : array

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.

Type

array

$_autoSizeMethods

$_autoSizeMethods : 

Type

$autoSizeMethod

$autoSizeMethod : string

AutoSize method

Type

string

$trueTypeFontPath

$trueTypeFontPath : string

Path to folder containing TrueType font .ttf files

Type

string

Methods

setAutoSizeMethod()

setAutoSizeMethod(string  $pValue = self::AUTOSIZE_METHOD_APPROX) : boolean

Set autoSize method

Parameters

string $pValue

Returns

boolean —

Success or failure

getAutoSizeMethod()

getAutoSizeMethod() : string

Get autoSize method

Returns

string

setTrueTypeFontPath()

setTrueTypeFontPath(string  $pValue = '') 

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

Typical locations on variout some platforms:

  • C:/Windows/Fonts/
  • /usr/share/font/truetype/
  • ~/.font/

Parameters

string $pValue

getTrueTypeFontPath()

getTrueTypeFontPath() : string

Get the path to the folder containing .ttf files.

Returns

string

calculateColumnWidth()

calculateColumnWidth(\PHPExcel_Style_Font  $font, \PHPExcel_RichText|string  $cellText = '', integer  $rotation, \PHPExcel_Style_Font|NULL  $defaultFont = null) : integer

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

Parameters

\PHPExcel_Style_Font $font

Font object

\PHPExcel_RichText|string $cellText

Text to calculate width

integer $rotation

Rotation angle

\PHPExcel_Style_Font|NULL $defaultFont

Font object

Returns

integer —

Column width

getTextWidthPixelsExact()

getTextWidthPixelsExact(string  $text, \PHPExcel_Style_Font  $font, integer  $rotation) : integer

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

Parameters

string $text
\PHPExcel_Style_Font $font
integer $rotation

Throws

\PHPExcel_Exception

Returns

integer

getTextWidthPixelsApprox()

getTextWidthPixelsApprox(string  $columnText, \PHPExcel_Style_Font  $font = null, integer  $rotation) : integer

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

Parameters

string $columnText
\PHPExcel_Style_Font $font
integer $rotation

Returns

integer —

Text width in pixels (no padding added)

fontSizeToPixels()

fontSizeToPixels(integer  $fontSizeInPoints = 11) : integer

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

Parameters

integer $fontSizeInPoints

Font size (in points)

Returns

integer —

Font size (in pixels)

inchSizeToPixels()

inchSizeToPixels(integer  $sizeInInch = 1) : integer

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

Parameters

integer $sizeInInch

Font size (in inch)

Returns

integer —

Size (in pixels)

centimeterSizeToPixels()

centimeterSizeToPixels(integer  $sizeInCm = 1) : integer

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

Parameters

integer $sizeInCm

Font size (in centimeters)

Returns

integer —

Size (in pixels)

getTrueTypeFontFileFromFont()

getTrueTypeFontFileFromFont(  $font) : string

Returns the font path given the font

Parameters

$font

Returns

string —

Path to TrueType font file

getCharsetFromFontName()

getCharsetFromFontName(string  $name) : integer

Returns the associated charset for the font name.

Parameters

string $name

Font name

Returns

integer —

Character set code

getDefaultColumnWidthByFont()

getDefaultColumnWidthByFont(\PHPExcel_Style_Font  $font, boolean  $pPixels = false) : 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)

Parameters

\PHPExcel_Style_Font $font

The workbooks default font

boolean $pPixels

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

Returns

mixed —

Column width

getDefaultRowHeightByFont()

getDefaultRowHeightByFont(\PHPExcel_Style_Font  $font) : 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

Parameters

\PHPExcel_Style_Font $font

The workbooks default font

Returns

float —

Row height in points