Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: problem z imagettfbbox()
Forum PHP.pl > Forum > PHP
bartu$
Witam.
Na serwerze włączonone jest php i biblioteka GD 2.0.

Wiele funkcji z GD juz przetestowalem i dziala poprawnie.
Problem mam z imagettfbbox().

Oto co zwraca :
  1. Warning: Could not find/open font in xxx_file.php on line 15


Serwer chodzi pod linuxem i nie jestem jego adminem.
Byc moze problem dotyczy sciezki do fontów TrueType.
Nie znam jej. Jaka jest standardowa sciezka dla linuxa ?

Oto fragment z phpinfo() :
  1. GD Support enabled
  2. GD Version 2.0 or higher
  3. FreeType Support enabled
  4. FreeType Linkage with freetype


Prosze o pomoc
carramba
plik czcionki ttf musi sie znajdowac w tym samym katalogu w ktorym uruchamiasz plik, względnie mozesz podac bezwzględną ścieżkę do pliku /home/w/public/var/www/twoje konto/katalog/czcionka.ttf
bartu$
Niestety dalej mam z tym problem,
i nie moge w sieci znalezc materialow jak go rozwiazac.

Plik "arial.ttf" mam w tym samym katalogu co uruchamiany skrypt .php

Blad
  1. Warning: imagettfbbox(): Could not find/open font in ......................

wystepuje zarowno :
- po podaniu sciezki na serwerze do mojego katalogu uzytkownika ze skryptem
- po podaniu samego pliku czcionki "arial.ttf"
- po podaniu adresu url do pliku czcionki.


W dalszym ciągu proszę o pomoc tych którzy korzystali z funkcji imagettfbbox()

Bart
carramba
a mozesz podac tutaj kod ktory wykonujesz ?
bartu$
Kazdy kod który ma funkcje imagettfbbox() u mnie nie działa,
niezależnie jak określe ścieżkę do pliku czcionki.

np.
  1. <?php
  2.  
  3. $imgWidth = 200;
  4. $imgHeight = 100;
  5. $imgText = 'php5.pl';
  6.  
  7. $hImage = imagecreatetruecolor($imgWidth, $imgHeight);
  8.  
  9. $box = imagettfbbox(14, 0, 'arial.ttf', $imgText);
  10. $x = (int)(($imgWidth - abs(max($box[2], $box[4]))) / 2);
  11. $y = (int)(($imgHeight + abs(max($box[5], $box[7]))) / 2);
  12.  
  13. imagecolorallocate($hImage, 0, 0, 0);
  14. $white = imagecolorallocate($hImage, 255, 255, 255);
  15. imagettftext($hImage, 14, 0, $x, $y, $white, 'arial.ttf',
  16. $imgText);
  17.  
  18. header('Content-type: image/png');
  19. imagepng($hImage);
  20.  
  21. ?>


Oto rezultat :
  1. Warning: imagettfbbox(): Could not find/open font in /usr/local/apache/www/htdocs/test2.php on line 9
  2.  
  3. Warning: imagettftext(): Could not find/open font in /usr/local/apache/www/htdocs/test2.php on line 16
  4.  
  5. Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/www/htdocs/test2.php:9) in /usr/local/apache/www/htdocs/test2.php on line 18
  6. PNG  IHDRČdLäč\PIDATxśíÁ ˙ŻnH@üęÄ|bIEND&reg;B`


Czy ktoś może mi pomóc.
Albo potwierdzi że ten kod u niego na serwerze działa prawidłowo ?

Bart
polibode
php on win32 doesn't understand long paths and it cannot open font.

Find this line in the script:

# ---------------------------- configuration starts here ---------------------

After this line add:

$script_dir = 'c:/progra~1/easyphp1-7/www/arial.ttf';
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.