ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Shared_Font Class Reference
+ Collaboration diagram for PHPExcel_Shared_Font:

Static Public Member Functions

static setAutoSizeMethod ($pValue= 'approx')
 Set autoSize method.
static getAutoSizeMethod ()
 Get autoSize method.
static setTrueTypeFontPath ($pValue= '')
 Set the path to the folder containing .ttf files.
static getTrueTypeFontPath ()
 Get the path to the folder containing .ttf files.
static calculateColumnWidth (PHPExcel_Style_Font $font, $cellText= '', $rotation=0, PHPExcel_Style_Font $defaultFont=null)
 Calculate an (approximate) OpenXML column width, based on font size and text contained.
static getTextWidthPixelsExact ($text, PHPExcel_Style_Font $font, $rotation=0)
 Get GD text width in pixels for a string of text in a certain font at a certain rotation angle.
static getTextWidthPixelsApprox ($columnText, PHPExcel_Style_Font $font=null, $rotation=0)
 Get approximate width in pixels for a string of text in a certain font at a certain rotation angle.
static fontSizeToPixels ($fontSizeInPoints=11)
 Calculate an (approximate) pixel size, based on a font points size.
static inchSizeToPixels ($sizeInInch=1)
 Calculate an (approximate) pixel size, based on inch size.
static centimeterSizeToPixels ($sizeInCm=1)
 Calculate an (approximate) pixel size, based on centimeter size.
static getTrueTypeFontFileFromFont ($font)
 Returns the font path given the font.
static getCharsetFromFontName ($name)
 Returns the associated charset for the font name.
static getDefaultColumnWidthByFont (PHPExcel_Style_Font $font, $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 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.

Data Fields

const AUTOSIZE_METHOD_APPROX = 'approx'
const AUTOSIZE_METHOD_EXACT = 'exact'
const CHARSET_ANSI_LATIN = 0x00
 Character set codes used by BIFF5-8 in Font records.
const CHARSET_SYSTEM_DEFAULT = 0x01
const CHARSET_SYMBOL = 0x02
const CHARSET_APPLE_ROMAN = 0x4D
const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80
const CHARSET_ANSI_KOREAN_HANGUL = 0x81
const CHARSET_ANSI_KOREAN_JOHAB = 0x82
const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86
const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88
const CHARSET_ANSI_GREEK = 0xA1
const CHARSET_ANSI_TURKISH = 0xA2
const CHARSET_ANSI_VIETNAMESE = 0xA3
const CHARSET_ANSI_HEBREW = 0xB1
const CHARSET_ANSI_ARABIC = 0xB2
const CHARSET_ANSI_BALTIC = 0xBA
const CHARSET_ANSI_CYRILLIC = 0xCC
const CHARSET_ANSI_THAI = 0xDE
const CHARSET_ANSI_LATIN_II = 0xEE
const CHARSET_OEM_LATIN_I = 0xFF
const ARIAL = 'arial.ttf'
 Font filenames.
const ARIAL_BOLD = 'arialbd.ttf'
const ARIAL_ITALIC = 'ariali.ttf'
const ARIAL_BOLD_ITALIC = 'arialbi.ttf'
const CALIBRI = 'CALIBRI.TTF'
const CALIBRI_BOLD = 'CALIBRIB.TTF'
const CALIBRI_ITALIC = 'CALIBRII.TTF'
const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF'
const COMIC_SANS_MS = 'comic.ttf'
const COMIC_SANS_MS_BOLD = 'comicbd.ttf'
const COURIER_NEW = 'cour.ttf'
const COURIER_NEW_BOLD = 'courbd.ttf'
const COURIER_NEW_ITALIC = 'couri.ttf'
const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'
const GEORGIA = 'georgia.ttf'
const GEORGIA_BOLD = 'georgiab.ttf'
const GEORGIA_ITALIC = 'georgiai.ttf'
const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'
const IMPACT = 'impact.ttf'
const LIBERATION_SANS = 'LiberationSans-Regular.ttf'
const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'
const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'
const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'
const LUCIDA_CONSOLE = 'lucon.ttf'
const LUCIDA_SANS_UNICODE = 'l_10646.ttf'
const MICROSOFT_SANS_SERIF = 'micross.ttf'
const PALATINO_LINOTYPE = 'pala.ttf'
const PALATINO_LINOTYPE_BOLD = 'palab.ttf'
const PALATINO_LINOTYPE_ITALIC = 'palai.ttf'
const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'
const SYMBOL = 'symbol.ttf'
const TAHOMA = 'tahoma.ttf'
const TAHOMA_BOLD = 'tahomabd.ttf'
const TIMES_NEW_ROMAN = 'times.ttf'
const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'
const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'
const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'
const TREBUCHET_MS = 'trebuc.ttf'
const TREBUCHET_MS_BOLD = 'trebucbd.ttf'
const TREBUCHET_MS_ITALIC = 'trebucit.ttf'
const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'
const VERDANA = 'verdana.ttf'
const VERDANA_BOLD = 'verdanab.ttf'
const VERDANA_ITALIC = 'verdanai.ttf'
const VERDANA_BOLD_ITALIC = 'verdanaz.ttf'

Static Public Attributes

static $defaultColumnWidths

Static Private Attributes

static $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX
static $trueTypeFontPath = null

Detailed Description

Definition at line 36 of file Font.php.

Member Function Documentation

static PHPExcel_Shared_Font::calculateColumnWidth ( PHPExcel_Style_Font  $font,
  $cellText = '',
  $rotation = 0,
PHPExcel_Style_Font  $defaultFont = null 
)
static

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

Parameters
int$fontSizeFont size (in pixels or points)
bool$fontSizeInPixelsIs the font size specified in pixels (true) or in points (false) ?
string$cellTextText to calculate width
int$rotationRotation angle
Returns
int Column width

Definition at line 241 of file Font.php.

References getTextWidthPixelsApprox(), getTextWidthPixelsExact(), and PHPExcel_Shared_Drawing\pixelsToCellDimension().

Referenced by PHPExcel_Worksheet\calculateColumnWidths().

{
// If it is rich text, use plain text
if ($cellText instanceof PHPExcel_RichText) {
$cellText = $cellText->getPlainText();
}
// Special case if there are one or more newline characters ("\n")
if (strpos($cellText, "\n") !== false) {
$lineTexts = explode("\n", $cellText);
$lineWitdhs = array();
foreach ($lineTexts as $lineText) {
$lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
}
return max($lineWidths); // width of longest line in cell
}
// Try to get the exact text width in pixels
try {
// If autosize method is set to 'approx', use approximation
if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) {
throw new Exception('AutoSize method is set to approx');
}
// Width of text in pixels excl. padding
$columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation);
// Excel adds some padding, use 1.07 of the width of an 'n' glyph
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
} catch (Exception $e) {
// Width of text in pixels excl. padding, approximation
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
// Excel adds some padding, just use approx width of 'n' glyph
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
}
// Convert from pixel width to column width
$columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
// Return
return round($columnWidth, 6);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::centimeterSizeToPixels (   $sizeInCm = 1)
static

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

Parameters
int$sizeInCmFont size (in centimeters)
Returns
int Size (in pixels)

Definition at line 404 of file Font.php.

Referenced by PHPExcel_Reader_Excel2007\toCSSArray().

{
return ($sizeInCm * 37.795275591);
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::fontSizeToPixels (   $fontSizeInPoints = 11)
static

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

Parameters
int$fontSizeInPointsFont size (in points)
Returns
int Font size (in pixels)

Definition at line 384 of file Font.php.

Referenced by PHPExcel_Shared_Excel5\sizeRow(), and PHPExcel_Reader_Excel2007\toCSSArray().

{
return (int) ((4 / 3) * $fontSizeInPoints);
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getAutoSizeMethod ( )
static

Get autoSize method.

Returns
string

Definition at line 201 of file Font.php.

References $autoSizeMethod.

{
}
static PHPExcel_Shared_Font::getCharsetFromFontName (   $name)
static

Returns the associated charset for the font name.

Parameters
string$nameFont name
Returns
int Character set code

Definition at line 541 of file Font.php.

References $name, CHARSET_ANSI_LATIN, CHARSET_ANSI_THAI, and CHARSET_SYMBOL.

Referenced by PHPExcel_Writer_Excel5_Font\writeFont().

{
switch ($name) {
// Add more cases. Check FONT records in real Excel files.
case 'EucrosiaUPC': return self::CHARSET_ANSI_THAI;
case 'Wingdings': return self::CHARSET_SYMBOL;
case 'Wingdings 2': return self::CHARSET_SYMBOL;
case 'Wingdings 3': return self::CHARSET_SYMBOL;
default: return self::CHARSET_ANSI_LATIN;
}
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getDefaultColumnWidthByFont ( PHPExcel_Style_Font  $font,
  $pPixels = false 
)
static

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$fontThe workbooks default font
boolean$pPixelstrue = return column width in pixels, false = return in OOXML units
Returns
mixed Column width

Definition at line 561 of file Font.php.

References PHPExcel_Style_Font\getName(), and PHPExcel_Style_Font\getSize().

Referenced by PHPExcel_Writer_Excel5_Worksheet\close(), and PHPExcel_Shared_Excel5\sizeCol().

{
if (isset(self::$defaultColumnWidths[$font->getName()][$font->getSize()])) {
// Exact width can be determined
$columnWidth = $pPixels ?
self::$defaultColumnWidths[$font->getName()][$font->getSize()]['px']
: self::$defaultColumnWidths[$font->getName()][$font->getSize()]['width'];
} else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$columnWidth = $pPixels ?
self::$defaultColumnWidths['Calibri'][11]['px']
: self::$defaultColumnWidths['Calibri'][11]['width'];
$columnWidth = $columnWidth * $font->getSize() / 11;
// Round pixels to closest integer
if ($pPixels) {
$columnWidth = (int) round($columnWidth);
}
}
return $columnWidth;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getDefaultRowHeightByFont ( PHPExcel_Style_Font  $font)
static

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$fontThe workbooks default font
Returns
float Row height in points

Definition at line 593 of file Font.php.

References PHPExcel_Style_Font\getName(), and PHPExcel_Style_Font\getSize().

Referenced by PHPExcel_Writer_HTML\buildCSS(), and PHPExcel_Shared_Excel5\sizeRow().

{
switch ($font->getName()) {
case 'Arial':
switch ($font->getSize()) {
case 10:
// inspection of Arial 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
break;
case 9:
// inspection of Arial 9 workbook says 12.00pt ~16px
$rowHeight = 12;
break;
case 8:
// inspection of Arial 8 workbook says 11.25pt ~15px
$rowHeight = 11.25;
break;
case 7:
// inspection of Arial 7 workbook says 9.00pt ~12px
$rowHeight = 9;
break;
case 6:
case 5:
// inspection of Arial 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
break;
case 4:
// inspection of Arial 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
break;
case 3:
// inspection of Arial 3 workbook says 6.00pt ~8px
$rowHeight = 6;
break;
case 2:
case 1:
// inspection of Arial 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
break;
default:
// use Arial 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10;
break;
}
break;
case 'Calibri':
switch ($font->getSize()) {
case 11:
// inspection of Calibri 11 workbook says 15.00pt ~20px
$rowHeight = 15;
break;
case 10:
// inspection of Calibri 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
break;
case 9:
// inspection of Calibri 9 workbook says 12.00pt ~16px
$rowHeight = 12;
break;
case 8:
// inspection of Calibri 8 workbook says 11.25pt ~15px
$rowHeight = 11.25;
break;
case 7:
// inspection of Calibri 7 workbook says 9.00pt ~12px
$rowHeight = 9;
break;
case 6:
case 5:
// inspection of Calibri 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
break;
case 4:
// inspection of Calibri 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
break;
case 3:
// inspection of Calibri 3 workbook says 6.00pt ~8px
$rowHeight = 6.00;
break;
case 2:
case 1:
// inspection of Calibri 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
break;
default:
// use Calibri 11 workbook as an approximation, extrapolation
$rowHeight = 15 * $font->getSize() / 11;
break;
}
break;
case 'Verdana':
switch ($font->getSize()) {
case 10:
// inspection of Verdana 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
break;
case 9:
// inspection of Verdana 9 workbook says 11.25pt ~15px
$rowHeight = 11.25;
break;
case 8:
// inspection of Verdana 8 workbook says 10.50pt ~14px
$rowHeight = 10.50;
break;
case 7:
// inspection of Verdana 7 workbook says 9.00pt ~12px
$rowHeight = 9.00;
break;
case 6:
case 5:
// inspection of Verdana 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
break;
case 4:
// inspection of Verdana 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
break;
case 3:
// inspection of Verdana 3 workbook says 6.00pt ~8px
$rowHeight = 6;
break;
case 2:
case 1:
// inspection of Verdana 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
break;
default:
// use Verdana 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10;
break;
}
break;
default:
// just use Calibri as an approximation
$rowHeight = 15 * $font->getSize() / 11;
break;
}
return $rowHeight;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getTextWidthPixelsApprox (   $columnText,
PHPExcel_Style_Font  $font = null,
  $rotation = 0 
)
static

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
Returns
int Text width in pixels (no padding added)

Definition at line 329 of file Font.php.

References PHPExcel_Shared_String\CountCharacters().

Referenced by calculateColumnWidth().

{
$fontName = $font->getName();
$fontSize = $font->getSize();
// Calculate column width in pixels. We assume fixed glyph width. Result varies with font name and size.
switch ($fontName) {
case 'Calibri':
// value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font.
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
break;
case 'Arial':
// value 7 was found via interpolation by inspecting real Excel files with Arial 10 font.
$columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break;
case 'Verdana':
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
$columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break;
default:
// just assume Calibri
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
break;
}
// Calculate approximate rotated column width
if ($rotation !== 0) {
if ($rotation == -165) {
// stacked text
$columnWidth = 4; // approximation
} else {
// rotated text
$columnWidth = $columnWidth * cos(deg2rad($rotation))
+ $fontSize * abs(sin(deg2rad($rotation))) / 5; // approximation
}
}
// pixel width is an integer
$columnWidth = (int) $columnWidth;
return $columnWidth;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getTextWidthPixelsExact (   $text,
PHPExcel_Style_Font  $font,
  $rotation = 0 
)
static

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
int$rotation
Returns
int
Exceptions
Exception

Definition at line 295 of file Font.php.

References PHPExcel_Style_Font\getSize(), and getTrueTypeFontFileFromFont().

Referenced by calculateColumnWidth().

{
if (!function_exists('imagettfbbox')) {
throw new Exception('GD library needs to be enabled');
}
// font size should really be supplied in pixels in GD2,
// but since GD2 seems to assume 72dpi, pixels and points are the same
$textBox = imagettfbbox($font->getSize(), $rotation, $fontFile, $text);
// Get corners positions
$lowerLeftCornerX = $textBox[0];
$lowerLeftCornerY = $textBox[1];
$lowerRightCornerX = $textBox[2];
$lowerRightCornerY = $textBox[3];
$upperRightCornerX = $textBox[4];
$upperRightCornerY = $textBox[5];
$upperLeftCornerX = $textBox[6];
$upperLeftCornerY = $textBox[7];
// Consider the rotation when calculating the width
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
return $textWidth;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getTrueTypeFontFileFromFont (   $font)
static

Returns the font path given the font.

Parameters
PHPExcel_Style_Font
Returns
string Path to TrueType font file

Definition at line 414 of file Font.php.

References $name, ARIAL_BOLD, CALIBRI_BOLD, COMIC_SANS_MS, COURIER_NEW_BOLD, GEORGIA_BOLD, IMPACT, LIBERATION_SANS_BOLD, LUCIDA_CONSOLE, LUCIDA_SANS_UNICODE, MICROSOFT_SANS_SERIF, PALATINO_LINOTYPE_BOLD, SYMBOL, TAHOMA, TIMES_NEW_ROMAN_BOLD, TREBUCHET_MS_BOLD, and VERDANA_BOLD.

Referenced by getTextWidthPixelsExact().

{
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
throw new Exception('Valid directory to TrueType Font files not specified');
}
$name = $font->getName();
$bold = $font->getBold();
$italic = $font->getItalic();
// Check if we can map font to true type font file
switch ($name) {
case 'Arial':
$fontFile = (
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
);
break;
case 'Calibri':
$fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
);
break;
case 'Courier New':
$fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
);
break;
case 'Comic Sans MS':
$fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
);
break;
case 'Georgia':
$fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
);
break;
case 'Impact':
$fontFile = self::IMPACT;
break;
case 'Liberation Sans':
$fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
);
break;
case 'Lucida Console':
$fontFile = self::LUCIDA_CONSOLE;
break;
case 'Lucida Sans Unicode':
break;
case 'Microsoft Sans Serif':
break;
case 'Palatino Linotype':
$fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
);
break;
case 'Symbol':
$fontFile = self::SYMBOL;
break;
case 'Tahoma':
$fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA
);
break;
case 'Times New Roman':
$fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
);
break;
case 'Trebuchet MS':
$fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
);
break;
case 'Verdana':
$fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
);
break;
default:
throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
break;
}
$fontFile = self::$trueTypeFontPath . $fontFile;
// Check if file actually exists
if (!file_exists($fontFile)) {
throw New Exception('TrueType Font file not found');
}
return $fontFile;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::getTrueTypeFontPath ( )
static

Get the path to the folder containing .ttf files.

Returns
string

Definition at line 227 of file Font.php.

References $trueTypeFontPath.

static PHPExcel_Shared_Font::inchSizeToPixels (   $sizeInInch = 1)
static

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

Parameters
int$sizeInInchFont size (in inch)
Returns
int Size (in pixels)

Definition at line 394 of file Font.php.

Referenced by PHPExcel_Reader_Excel2007\toCSSArray().

{
return ($sizeInInch * 96);
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_Font::setAutoSizeMethod (   $pValue = 'approx')
static

Set autoSize method.

Parameters
string$pValue

Definition at line 191 of file Font.php.

{
self::$autoSizeMethod = $pValue;
}
static PHPExcel_Shared_Font::setTrueTypeFontPath (   $pValue = '')
static

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

Definition at line 217 of file Font.php.

{
self::$trueTypeFontPath = $pValue;
}

Field Documentation

PHPExcel_Shared_Font::$autoSizeMethod = self::AUTOSIZE_METHOD_APPROX
staticprivate

Definition at line 130 of file Font.php.

Referenced by getAutoSizeMethod().

PHPExcel_Shared_Font::$defaultColumnWidths
static
PHPExcel_Shared_Font::$trueTypeFontPath = null
staticprivate

Definition at line 137 of file Font.php.

Referenced by getTrueTypeFontPath().

const PHPExcel_Shared_Font::ARIAL = 'arial.ttf'

Font filenames.

Definition at line 65 of file Font.php.

const PHPExcel_Shared_Font::ARIAL_BOLD = 'arialbd.ttf'

Definition at line 66 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::ARIAL_BOLD_ITALIC = 'arialbi.ttf'

Definition at line 68 of file Font.php.

const PHPExcel_Shared_Font::ARIAL_ITALIC = 'ariali.ttf'

Definition at line 67 of file Font.php.

const PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX = 'approx'

Definition at line 39 of file Font.php.

const PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT = 'exact'

Definition at line 40 of file Font.php.

const PHPExcel_Shared_Font::CALIBRI = 'CALIBRI.TTF'

Definition at line 70 of file Font.php.

const PHPExcel_Shared_Font::CALIBRI_BOLD = 'CALIBRIB.TTF'

Definition at line 71 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF'

Definition at line 73 of file Font.php.

const PHPExcel_Shared_Font::CALIBRI_ITALIC = 'CALIBRII.TTF'

Definition at line 72 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_ARABIC = 0xB2

Definition at line 56 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_BALTIC = 0xBA

Definition at line 57 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86

Definition at line 50 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88

Definition at line 51 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_CYRILLIC = 0xCC

Definition at line 58 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_GREEK = 0xA1

Definition at line 52 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_HEBREW = 0xB1

Definition at line 55 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80

Definition at line 47 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_KOREAN_HANGUL = 0x81

Definition at line 48 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_KOREAN_JOHAB = 0x82

Definition at line 49 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_LATIN = 0x00

Character set codes used by BIFF5-8 in Font records.

Definition at line 43 of file Font.php.

Referenced by getCharsetFromFontName().

const PHPExcel_Shared_Font::CHARSET_ANSI_LATIN_II = 0xEE

Definition at line 60 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_THAI = 0xDE

Definition at line 59 of file Font.php.

Referenced by getCharsetFromFontName().

const PHPExcel_Shared_Font::CHARSET_ANSI_TURKISH = 0xA2

Definition at line 53 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_VIETNAMESE = 0xA3

Definition at line 54 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_APPLE_ROMAN = 0x4D

Definition at line 46 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_OEM_LATIN_I = 0xFF

Definition at line 61 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_SYMBOL = 0x02

Definition at line 45 of file Font.php.

Referenced by getCharsetFromFontName().

const PHPExcel_Shared_Font::CHARSET_SYSTEM_DEFAULT = 0x01

Definition at line 44 of file Font.php.

const PHPExcel_Shared_Font::COMIC_SANS_MS = 'comic.ttf'

Definition at line 75 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::COMIC_SANS_MS_BOLD = 'comicbd.ttf'

Definition at line 76 of file Font.php.

const PHPExcel_Shared_Font::COURIER_NEW = 'cour.ttf'

Definition at line 78 of file Font.php.

const PHPExcel_Shared_Font::COURIER_NEW_BOLD = 'courbd.ttf'

Definition at line 79 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'

Definition at line 81 of file Font.php.

const PHPExcel_Shared_Font::COURIER_NEW_ITALIC = 'couri.ttf'

Definition at line 80 of file Font.php.

const PHPExcel_Shared_Font::GEORGIA = 'georgia.ttf'

Definition at line 83 of file Font.php.

const PHPExcel_Shared_Font::GEORGIA_BOLD = 'georgiab.ttf'

Definition at line 84 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'

Definition at line 86 of file Font.php.

const PHPExcel_Shared_Font::GEORGIA_ITALIC = 'georgiai.ttf'

Definition at line 85 of file Font.php.

const PHPExcel_Shared_Font::IMPACT = 'impact.ttf'

Definition at line 88 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::LIBERATION_SANS = 'LiberationSans-Regular.ttf'

Definition at line 90 of file Font.php.

const PHPExcel_Shared_Font::LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'

Definition at line 91 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'

Definition at line 93 of file Font.php.

const PHPExcel_Shared_Font::LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'

Definition at line 92 of file Font.php.

const PHPExcel_Shared_Font::LUCIDA_CONSOLE = 'lucon.ttf'

Definition at line 95 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::LUCIDA_SANS_UNICODE = 'l_10646.ttf'

Definition at line 96 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::MICROSOFT_SANS_SERIF = 'micross.ttf'

Definition at line 98 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::PALATINO_LINOTYPE = 'pala.ttf'

Definition at line 100 of file Font.php.

const PHPExcel_Shared_Font::PALATINO_LINOTYPE_BOLD = 'palab.ttf'

Definition at line 101 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'

Definition at line 103 of file Font.php.

const PHPExcel_Shared_Font::PALATINO_LINOTYPE_ITALIC = 'palai.ttf'

Definition at line 102 of file Font.php.

const PHPExcel_Shared_Font::SYMBOL = 'symbol.ttf'

Definition at line 105 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::TAHOMA = 'tahoma.ttf'

Definition at line 107 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::TAHOMA_BOLD = 'tahomabd.ttf'

Definition at line 108 of file Font.php.

const PHPExcel_Shared_Font::TIMES_NEW_ROMAN = 'times.ttf'

Definition at line 110 of file Font.php.

const PHPExcel_Shared_Font::TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'

Definition at line 111 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'

Definition at line 113 of file Font.php.

const PHPExcel_Shared_Font::TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'

Definition at line 112 of file Font.php.

const PHPExcel_Shared_Font::TREBUCHET_MS = 'trebuc.ttf'

Definition at line 115 of file Font.php.

const PHPExcel_Shared_Font::TREBUCHET_MS_BOLD = 'trebucbd.ttf'

Definition at line 116 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'

Definition at line 118 of file Font.php.

const PHPExcel_Shared_Font::TREBUCHET_MS_ITALIC = 'trebucit.ttf'

Definition at line 117 of file Font.php.

const PHPExcel_Shared_Font::VERDANA = 'verdana.ttf'

Definition at line 120 of file Font.php.

const PHPExcel_Shared_Font::VERDANA_BOLD = 'verdanab.ttf'

Definition at line 121 of file Font.php.

Referenced by getTrueTypeFontFileFromFont().

const PHPExcel_Shared_Font::VERDANA_BOLD_ITALIC = 'verdanaz.ttf'

Definition at line 123 of file Font.php.

const PHPExcel_Shared_Font::VERDANA_ITALIC = 'verdanai.ttf'

Definition at line 122 of file Font.php.


The documentation for this class was generated from the following file: