1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace Pry\Image;
14:
15: define('FONTFOLDER', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'font');
16:
17: 18: 19: 20: 21: 22: 23: 24:
25: class Font
26: {
27:
28: private $fontname;
29:
30: 31: 32: 33: 34:
35: public function __construct($name)
36: {
37: $this->fontname = $name;
38: $this->checkName();
39: }
40:
41: 42: 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: 58: 59: 60:
61: public function utilise()
62: {
63: return $this->fontname;
64: }
65:
66: 67: 68: 69: 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:
88: return $image->display();
89: }
90:
91: }
92:
93: ?>