Sgss_Font_Manager_Abstract 
Abstract class for managing fonts using database

Description

Implements:
Sgss_Font_Manager_Interface
Author:
Matsuda Shota
Copyright:
(c) 2007-2008 Matsuda Shota
License:
http://creativecommons.org/licenses/GPL/2.0/
Located in:
/Font/Manager/Abstract.php (line 91)

Direct descendant

Sgss_Font_Manager The default class for managing fonts using database

Class overview

Variables

protected string $_cacheDirectory

Default font cache directory

protected Sgss_Font_Manager_Table_Coverage $_coverages

Coverage table

protected Zend_Db_Adapter_Abstract $_db

Database handle

protected string $_dbAdapter

Database adapter name

protected array|Zend_Config $_dbConfig

Database configurations

protected string $_fontDirectory

Default font file directory

protected Sgss_Font_Manager_Table_Font $_fonts

Font table

protected array $_fontsDerived

Fonts already created

protected Sgss_Font_Manager_Table_Format $_formats

Format font table

protected Sgss_Font_Manager_Table_Profile $_profiles

Profile table

Methods

boolean addFont (Sgss_Font_Interface $font)

Adds the specified font to this manager

string|null getCacheDirectory ()

Returns the default font cache directory of this manager

Zend_Db_Adapter_Abstract|null getConnection ()

Returns the database handle used by this manager

Sgss_Font_Interface|null getFont (string $family, [string|null $subfamily = null], [int|string|null $style = null], [int|string|null $weight = null], [int|string|null $stretch = null])

Returns the font that matches the specified parameters

string|null getFontDirectory ()

Returns the default font file directory of this manager

boolean hasFont (Sgss_Font_Interface|string $family, [string|null $subfamily = null], [int|string|null $style = null], [int|string|null $weight = null], [int|string|null $stretch = null])

Determines this manager contains the font that matches the specified parameters

array listFont ([string|null $locale = null])

Returns the list of all fonts in this manager

boolean removeFont (Sgss_Font_Interface|string $family, [string|null $subfamily = null], [int|string|null $style = null], [int|string|null $weight = null], [int|string|null $stretch = null])

Removes the font that matches the specified parameters

void setCacheDirectory (Sgss_File|string $directory)

Sets the default font cache directory to the specified value

void setFontDirectory (Sgss_File|string $directory)

Sets the default font file directory to the specified value

protected boolean _addFormat (Sgss_Font_Format_Interface $font)

Inserts the specified format font to this manager

protected mixed _ensureStretch (int|string $stretch)

Converts the specified stretch expressions the corresponding stretch value

protected mixed _ensureStyle (int|string $style)

Converts the specified style expression to the corresponding style identifier

protected mixed _ensureWeight (int|string $weight)

Converts the specified weight expressions the corresponding weight value

protected array|null _findFont (string $family, string $subfamily, int|string $style, int|string $weight, int|string $stretch)

Returns an array containing the font identifier and type that matches the specified parameters

protected Sgss_Font_Format_Interface _getFormat (int $fontId)

Returns the format font corresponding to the specified identifier

protected void _init ()

Initializes this manager

protected boolean _removeFormat (Sgss_Font_Format_Interface $font)

Removes the specified format font from this manager

protected string|boolean _resolvePath (string $file, string|null $defaultDirectory)

Converts the specified file path to a relative one based on the default directory

protected string|boolean|null _searchFile (string $file, string|null $defaultDirectory)

Searches file with the specified path and default directory

Constant

TYPE_FORMAT = 'format' Font type identifier

Variable detail

$_cacheDirectory 

Default font cache directory

Signature:
protected string $_cacheDirectory = null


$_coverages 

Coverage table

Signature:
protected Sgss_Font_Manager_Table_Coverage $_coverages


$_db 

Database handle

Signature:
protected Zend_Db_Adapter_Abstract $_db


$_dbAdapter 

Database adapter name

Overridden by:
Signature:
protected string $_dbAdapter = null


$_dbConfig 

Database configurations

Overridden by:
Signature:
protected array|Zend_Config $_dbConfig = null


$_fontDirectory 

Default font file directory

Signature:
protected string $_fontDirectory = null


$_fonts 

Font table

Signature:
protected Sgss_Font_Manager_Table_Font $_fonts


$_fontsDerived 

Fonts already created

Signature:
protected array $_fontsDerived = array()


$_formats 

Format font table

Signature:
protected Sgss_Font_Manager_Table_Format $_formats


$_profiles 

Profile table

Signature:
protected Sgss_Font_Manager_Table_Profile $_profiles


Method detail

addFont

Adds the specified font to this manager

Parameters:
Returns:
boolean -- True when the operation changed this manager
Specified by:
Related subject:
Sgss_Font_Manager_Interface::addFont()
Signature:
public boolean addFont (Sgss_Font_Interface $font)


getCacheDirectory

Returns the default font cache directory of this manager

Returns:
string|null -- Path to the cache directory
Signature:
public string|null getCacheDirectory ()


getConnection

Returns the database handle used by this manager

Returns:
Zend_Db_Adapter_Abstract|null -- Database handle
Signature:
public Zend_Db_Adapter_Abstract|null getConnection ()


getFont

Returns the font that matches the specified parameters

Parameters:
  • string $family

    Family name

  • string|null $subfamily

    Subfamily name

  • int|string|null $style

    Style identifier or name

  • int|string|null $weight

    Weight value or name

  • int|string|null $stretch

    Stretch value or name

Returns:
Sgss_Font_Interface|null -- Font that matches the specified parameters, or null when nothing matched
Throws:
  • Sgss_Font_Manager_Exception

    When unexpected error occurred

Specified by:
Used by:
Sgss_Graphics_Font::composite(), Sgss_Graphics_Font::getHandle()
Related subject:
Sgss_Font_Manager_Interface::getFont()
Signature:
public Sgss_Font_Interface|null getFont (string $family, [string|null $subfamily = null], [int|string|null $style = null], [int|string|null $weight = null], [int|string|null $stretch = null])


getFontDirectory

Returns the default font file directory of this manager

Returns:
string|null -- Path to the font directory
Signature:
public string|null getFontDirectory ()


hasFont

Determines this manager contains the font that matches the specified parameters

Parameters:
  • Sgss_Font_Interface|string $family

    Font instance or family name

  • string|null $subfamily

    Subfamily name

  • int|string|null $style

    Style identifier or name

  • int|string|null $weight

    Weight value or name

  • int|string|null $stretch

    Stretch value or name

Returns:
boolean -- True when this manager contains the font
Specified by:
Related subject:
Sgss_Font_Manager_Interface::hasFont()
Signature:
public boolean hasFont (Sgss_Font_Interface|string $family, [string|null $subfamily = null], [int|string|null $style = null], [int|string|null $weight = null], [int|string|null $stretch = null])


listFont

Returns the list of all fonts in this manager

Parameters:
  • string|null $locale

    Locale of profile to be listed

Specified by:
Related subject:
Sgss_Font_Manager_Interface::listFont()
Signature:
public array listFont ([string|null $locale = null])


removeFont

Removes the font that matches the specified parameters

Parameters:
  • Sgss_Font_Interface|string $family

    Font instance or family name

  • string|null $subfamily

    Subfamily name

  • int|string|null $style

    Style identifier or name

  • int|string|null $weight

    Weight value or name

  • int|string|null $stretch

    Stretch value or name

Returns:
boolean -- True when the operation changed this manager
Specified by:
Related subject:
Sgss_Font_Manager_Interface::removeFont()
Signature:
public boolean removeFont (Sgss_Font_Interface|string $family, [string|null $subfamily = null], [int|string|null $style = null], [int|string|null $weight = null], [int|string|null $stretch = null])


setCacheDirectory

Sets the default font cache directory to the specified value

Parameters:
  • Sgss_File|string $directory

    Path to the cache directory

Signature:
public void setCacheDirectory (Sgss_File|string $directory)


setFontDirectory

Sets the default font file directory to the specified value

Parameters:
  • Sgss_File|string $directory

    Path to the font directory

Signature:
public void setFontDirectory (Sgss_File|string $directory)


_addFormat 

Inserts the specified format font to this manager

Parameters:
Returns:
boolean -- True when the operation changed this manager
Throws:
  • Sgss_Font_Manager_Exception

    When unexpected error occurred

Signature:
protected boolean _addFormat (Sgss_Font_Format_Interface $font)


_ensureStretch 

Converts the specified stretch expressions the corresponding stretch value

Parameters:
  • int|string $stretch

    Stretch expression or value

Returns:
mixed -- Stretch value
Signature:
protected mixed _ensureStretch (int|string $stretch)


_ensureStyle 

Converts the specified style expression to the corresponding style identifier

Parameters:
  • int|string $style

    Style expression or identifier

Returns:
mixed -- Style identifier
Signature:
protected mixed _ensureStyle (int|string $style)


_ensureWeight 

Converts the specified weight expressions the corresponding weight value

Parameters:
  • int|string $weight

    Weight expression or value

Returns:
mixed -- Weight value
Signature:
protected mixed _ensureWeight (int|string $weight)


_findFont 

Returns an array containing the font identifier and type that matches the specified parameters

Parameters:
  • string $family

    Family name

  • string $subfamily

    Subfamily name

  • int|string $style

    Style identifier or name

  • int|string $weight

    Weight value or name

  • int|string $stretch

    Stretch value or name

Returns:
array|null -- Array containing the font identifier and type, or null when not found
Signature:
protected array|null _findFont (string $family, string $subfamily, int|string $style, int|string $weight, int|string $stretch)


_getFormat 

Returns the format font corresponding to the specified identifier

Parameters:
  • int $fontId

    Font identifier of the font

Returns:
Sgss_Font_Format_Interface -- Format font corresponding to the identifier
Throws:
  • Sgss_Font_Manager_Exception

    When unexpected error occurred

Signature:
protected Sgss_Font_Format_Interface _getFormat (int $fontId)


_init 

Initializes this manager

Throws:
  • Sgss_Font_Manager_Exception

    When unable to create database handle or connect to the database

Uses:
Zend_Db::factory(), Sgss_Font_Manager_Table_Format, Sgss_Font_Manager_Table_Coverage, Sgss_Font_Manager_Table_Font, Sgss_Font_Manager_Table_Profile
Used by:
Sgss_Font_Manager::__construct()
Signature:
protected void _init ()


_removeFormat 

Removes the specified format font from this manager

Parameters:
Returns:
boolean -- True when the operation changed this manager
Throws:
  • Sgss_Font_Manager_Exception

    When unexpected error occurred

Signature:
protected boolean _removeFormat (Sgss_Font_Format_Interface $font)


_resolvePath 

Converts the specified file path to a relative one based on the default directory

Parameters:
  • string $file

    File path to be converted

  • string|null $defaultDirectory

    Default directory

Returns:
string|boolean -- Relative path based on the default directory, or false when the default directory does not exist despite specified
Signature:
protected string|boolean _resolvePath (string $file, string|null $defaultDirectory)


_searchFile 

Searches file with the specified path and default directory

Parameters:
  • string $file

    Path of the file to search

  • string|null $defaultDirectory

    Default directory

Returns:
string|boolean|null -- Path to the found file, or false when the default directory does not exist despite it is specified, or null when the file was not found both in the current path and the default directory
Signature:
protected string|boolean|null _searchFile (string $file, string|null $defaultDirectory)


Constant detail

TYPE_FORMAT

Font type identifier

Signature:
const TYPE_FORMAT = 'format'