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