Bonjour!
Voilà ma source (prise de phpfrance.com):
<?
Header("Content-type: image/png");
$size=$_GET['size'];
$text = $_GET['text'];
$font = ".\arial.ttf";
// on obtient la grandeur du texte
$box = imagettfbbox($size,0,$font,$text);
$dx = abs($box[2]-$box[0]);
$dy = abs($box[5]-$box[3]);
$xpad=9;
$ypad=9;
// crée l'image avec ses coordonnées
$im = imagecreate($dx+$xpad,$dy+$ypad);
// création des différentes couleurs
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
// dessin d'un rectangle
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
//on écrit le texte
ImageTTFText($im, $size, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, $font, $text);
ImageTTFText($im, $size, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, $font, $text);
// création finale en png
ImagePNG($im);
// destruction de la ressource
ImageDestroy($im);
?>
Le problème est qu'il ne trouve pas la police alors que je l'ai copié dans le rep de mon .cpp
Tout fonctionne si je fais, par exemple:
$font = "c:\windows\fonts\arial.ttf";
Mais bon, c'est pas top du tout.
Quelqu'un a une idée?
Merci