class PHPExcel_Shared_Font

PHPExcelSharedFont

Constants

AUTOSIZE_METHOD_APPROX

AUTOSIZE_METHOD_EXACT

CHARSET_ANSI_LATIN

Character set codes used by BIFF5-8 in Font records

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

Font filenames

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

Properties

static array $defaultColumnWidths 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.

Methods

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

Set autoSize method

static string
getAutoSizeMethod()

Get autoSize method

static 
setTrueTypeFontPath(string $pValue = '')

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

static string
getTrueTypeFontPath()

Get the path to the folder containing .ttf files.

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

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

static int
getTextWidthPixelsExact(string $text, PHPExcel_Style_Font $font, int $rotation)

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

static int
getTextWidthPixelsApprox(string $columnText, PHPExcel_Style_Font $font = null, int $rotation)

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

static int
fontSizeToPixels(int $fontSizeInPoints = 11)

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

static int
inchSizeToPixels(int $sizeInInch = 1)

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

static int
centimeterSizeToPixels(int $sizeInCm = 1)

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

static string
getTrueTypeFontFileFromFont(PHPExcel_Style_Font $font)

Returns the font path given the font

static int
getCharsetFromFontName(string $name)

Returns the associated charset for the font name.

static mixed
getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, boolean $pPixels = false)

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)

static float
getDefaultRowHeightByFont(PHPExcel_Style_Font $font)

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

Details

at line 206
static boolean setAutoSizeMethod(string $pValue = self::AUTOSIZE_METHOD_APPROX)

Set autoSize method

Parameters

string $pValue

Return Value

boolean Success or failure

at line 221
static string getAutoSizeMethod()

Get autoSize method

Return Value

string

at line 237
static 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/fonts/truetype/
  • ~/.fonts/

Parameters

string $pValue

at line 247
static string getTrueTypeFontPath()

Get the path to the folder containing .ttf files.

Return Value

string

at line 261
static integer calculateColumnWidth(PHPExcel_Style_Font $font, PHPExcel_RichText|string $cellText = '', integer $rotation, PHPExcel_Style_Font $defaultFont = null)

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 $defaultFont Font object

Return Value

integer Column width

at line 314
static int getTextWidthPixelsExact(string $text, PHPExcel_Style_Font $font, int $rotation)

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
int $rotation

Return Value

int

Exceptions

PHPExcel_Exception

at line 349
static int getTextWidthPixelsApprox(string $columnText, PHPExcel_Style_Font $font = null, int $rotation)

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
int $rotation

Return Value

int Text width in pixels (no padding added)

at line 405
static int fontSizeToPixels(int $fontSizeInPoints = 11)

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

Parameters

int $fontSizeInPoints Font size (in points)

Return Value

int Font size (in pixels)

at line 416
static int inchSizeToPixels(int $sizeInInch = 1)

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

Parameters

int $sizeInInch Font size (in inch)

Return Value

int Size (in pixels)

at line 427
static int centimeterSizeToPixels(int $sizeInCm = 1)

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

Parameters

int $sizeInCm Font size (in centimeters)

Return Value

int Size (in pixels)

at line 438
static string getTrueTypeFontFileFromFont(PHPExcel_Style_Font $font)

Returns the font path given the font

Parameters

PHPExcel_Style_Font $font

Return Value

string Path to TrueType font file

at line 550
static int getCharsetFromFontName(string $name)

Returns the associated charset for the font name.

Parameters

string $name Font name

Return Value

int Character set code

at line 575
static mixed getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, boolean $pPixels = false)

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

Return Value

mixed Column width

at line 607
static float getDefaultRowHeightByFont(PHPExcel_Style_Font $font)

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

Return Value

float Row height in points