Forum Programmation.php Ecrire sur une image avec une police TTF

Posté par  (site web personnel) .
Étiquettes : aucune
0
26
avr.
2005
Bonjour,

J'ai un hébergement chez Amen.fr. Sur mon site, j'ai un script qui est chargé d'écrire une chaine de caractères sur une image existante, avec une police TTF se trouvant au même endroit que le script. Chez moi, cela marche parfaitement. Dans le code ci-dessous, la fonction imagestring marche bien. En revanche, imagettftext ne marche pas et ne renvoi pas de message d'erreur. Visiblement, il trouve bien la police car, lorsque je modifie le nom de fichier de la police ( tout en minuscule par ex. ), il génère une erreur. Voici le code :


$red = imagecolorallocate($src,255,0,0);
$bg = imagecolorallocate($src,255,255,255);
echo "load font..." ;
$font = "VeraBd.ttf";
imagettftext($src,18,25,10,53,$bg,$font,$value);
imagettftext($src,18,25,10,52,$red,$font,$value);
imagestring($src,3,20,30,$value,$red);
image_create($attr[2], $src, CACHE.$filename."-2");


La configuration de la librairie GD est identique chez moi et chez Amen :

GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled


Quelqu'un peut-il m'aider.
Merci.
  • # Quelques pistes ?

    Posté par  . Évalué à 2.

    As-tu jeté un oeil ici : http://fr.php.net/manual/en/function.imagettftext.php(...)
    en particulier cette partie :
    Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

    Et les commentaires, en particulier celui-ci :
    Remember!!!

    When uploading a font to your website you have to set the transfer mode to binary. It took me some time to find out :P. Tried to download the font from my website and it was spoiled.


    ???
    En espérant que ça t'aidera à résoudre ton problème, comme on dit !

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.