ILIAS  Release_4_0_x_branch Revision 61816
 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 calculateColumnWidth ($fontSize=9, $fontSizeInPixels=false, $columnText= '', $rotation=0)
 Calculate an (approximate) OpenXML column width, based on font size and text contained.
static fontSizeToPixels ($fontSizeInPoints=12)
 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 getCharsetFromFontName ($name)
 Returns the associated charset for the font name.

Data Fields

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

Detailed Description

Definition at line 36 of file Font.php.

Member Function Documentation

static PHPExcel_Shared_Font::calculateColumnWidth (   $fontSize = 9,
  $fontSizeInPixels = false,
  $columnText = '',
  $rotation = 0 
)
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$columnTextText to calculate width
int$rotationRotation angle
Returns
int Column width

Definition at line 68 of file Font.php.

References fontSizeToPixels().

Referenced by PHPExcel_Worksheet\calculateColumnWidths().

{
if (!$fontSizeInPixels) {
// Translate points size to pixel size
}
// If it is rich text, use rich text...
if ($columnText instanceof PHPExcel_RichText) {
$columnText = $columnText->getPlainText();
}
// Only measure the part before the first newline character
if (strpos($columnText, "\r") !== false) {
$columnText = substr($columnText, 0, strpos($columnText, "\r"));
}
if (strpos($columnText, "\n") !== false) {
$columnText = substr($columnText, 0, strpos($columnText, "\n"));
}
// Calculate column width
// values 1.025 and 0.584 found via interpolation by inspecting real Excel files with
// Calibri font. May need further adjustment
$columnWidth = 1.025 * strlen($columnText) + 0.584; // Excel adds some padding
// 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
}
}
// 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 134 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 = 12)
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 114 of file Font.php.

Referenced by calculateColumnWidth(), and PHPExcel_Reader_Excel2007\toCSSArray().

{
return ((16 / 12) * $fontSizeInPoints);
}

+ Here is the caller graph for this function:

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 144 of file Font.php.

References $name, CHARSET_ANSI_LATIN, and CHARSET_SYMBOL.

Referenced by PHPExcel_Writer_Excel5_Font\writeFont().

{
switch ($name) {
// Add more cases. Check FONT records in real Excel files.
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::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 124 of file Font.php.

Referenced by PHPExcel_Reader_Excel2007\toCSSArray().

{
return ($sizeInInch * 96);
}

+ Here is the caller graph for this function:

Field Documentation

const PHPExcel_Shared_Font::CHARSET_ANSI_ARABIC = 0xB2

Definition at line 52 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_BALTIC = 0xBA

Definition at line 53 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86

Definition at line 46 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88

Definition at line 47 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_CYRILLIC = 0xCC

Definition at line 54 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_GREEK = 0xA1

Definition at line 48 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_HEBREW = 0xB1

Definition at line 51 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80

Definition at line 43 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_KOREAN_HANGUL = 0x81

Definition at line 44 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_KOREAN_JOHAB = 0x82

Definition at line 45 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 39 of file Font.php.

Referenced by getCharsetFromFontName().

const PHPExcel_Shared_Font::CHARSET_ANSI_LATIN_II = 0xEE

Definition at line 56 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_THAI = 0xDE

Definition at line 55 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_TURKISH = 0xA2

Definition at line 49 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_ANSI_VIETNAMESE = 0xA3

Definition at line 50 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_APPLE_ROMAN = 0x4D

Definition at line 42 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_OEM_LATIN_I = 0xFF

Definition at line 57 of file Font.php.

const PHPExcel_Shared_Font::CHARSET_SYMBOL = 0x02

Definition at line 41 of file Font.php.

Referenced by getCharsetFromFontName().

const PHPExcel_Shared_Font::CHARSET_SYSTEM_DEFAULT = 0x01

Definition at line 40 of file Font.php.


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