Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Image_Captcha
  • Image_Converter
  • Image_DegradeCouleur
  • Image_Font
  • Image_Gauge
  • Image_Image
  • Image_Traitement

Exceptions

  • Image_Exception
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Pry Framework
 4:  *
 5:  * LICENSE
 6:  *
 7:  * This source file is subject to the new BSD license that is bundled
 8:  * with this package in the file LICENSE.txt.
 9:  * 
10:  * @version $Revision: 276 $
11:  */
12: 
13: define('FONTFOLDER',dirname(__FILE__).DIRECTORY_SEPARATOR.'font');
14: 
15: /**
16:  * Retourne la police choisie
17:  * @category Pry
18:  * @package Image
19:  * @version 1.0.1 
20:  * @author Olivier ROGER <oroger.fr>
21:  *
22:  */
23: class Image_Font
24: {
25:     private $fontname;
26:     
27:     /**
28:      * Constructeur
29:      *
30:      * @param string $name Nom ou chemin de la font
31:      */
32:     public function __construct($name)
33:     {
34:         $this->fontname = $name;
35:         $this->checkName();
36:     }
37:     
38:     /**
39:      * Vérifie l'existance de la police , sinon essai de la trouver dans le dossier font
40:      *
41:      */
42:     private function checkName()
43:     {
44:         $fileInfo = pathinfo($this->fontname);
45:         if(!file_exists($this->fontname))
46:         {
47:             $this->fontname = FONTFOLDER.DIRECTORY_SEPARATOR.$fileInfo['basename'];
48:             if(!isset($fileInfo['extension']))
49:                 $this->fontname.='.ttf';
50:         }
51:     }
52:     
53:     /**
54:      * Retourne le nom de la police et son chemin complet
55:      *
56:      * @return string
57:      */
58:     public function utilise()
59:     {
60:         return $this->fontname;
61:     }
62:     
63:     /**
64:      * Liste toutes les polices disponibles dans le dossier font sous forme d'une image
65:      *<code>echo Image_Font::listFont()</code>
66:      * @return image
67:      */
68:     public static function listFont()
69:     {
70:         $file   = new File_FolderManager(FONTFOLDER.DIRECTORY_SEPARATOR);        
71:         $listeFont = $file->listFile();
72:         
73:         $nbPolice = count($listeFont);
74:         $image  = new Image_ImgTraitement(null,200,($nbPolice*14)+14);
75:         $image->setType(Image_ImgTraitement::IMG_JPG);
76:         $image->setBgColor(255,255,255);
77:         $image->setColor(0,0,0);
78:         
79:         for($i=0;$i<$nbPolice;$i++)
80:         {
81:             $image->setFont($listeFont[$i]['name']);
82:             $image->setText($listeFont[$i]['name'],14,0,(18*$i));
83:         }
84:         
85:         //return $image->save('listeFont.jpg');
86:         return $image->display();
87:     }
88: }
89:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1