Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Captcha
  • Converter
  • DegradeCouleur
  • Font
  • Gauge
  • Image
  • Traitement

Exceptions

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