$font = 5; $tekst = "Proba"; $img = imagecreatetruecolor(300, 300); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $red = imagecolorallocate($img, 255, 0, 0); imagefill($img, 0, 0, $red); $tekst_x = (300 - $width_tekst) / 2; $tekst_y = (100 - imagefontheight($font)) / 2; imagestring($img, $font, $tekst_x, $tekst_y, $tekst, $white); imagegif($img); imagedestroy($img);
to wszystko dziala jak nalezy, ale gdy zmienie imagestring, na imagettftext i $font zamiast 5 bedzie rowny 'arial.ttf';, to funkcje imagefontwidth i height nie dzialaja.
$font = 'arial.ttf'; $tekst = "Proba"; $img = imagecreatetruecolor(300, 300); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $red = imagecolorallocate($img, 255, 0, 0); imagefill($img, 0, 0, $red); $tekst_x = (300 - $width_tekst) / 2; $tekst_y = (100 - imagefontheight($font)) / 2; imagettftext($img, 20, 0, $tekst_x, $tekst_y, $white, $fontTTF, $tekst); imagegif($img); imagedestroy($img);
oczywiscie plik arial.ttf jest tam gdzie powinien byc, bo gdy pomine funkcje imagefontwidth i height, to wszystko jest ok, ale sa mi one niezbedne do centrowania tekstu w pionie i poziomie, wiec co mam zrobic? Sa jakies podobne funkcje dla fontow ttf?
Moglbym oczywiscie pozostac przy imagestring zamiast imagettftext, ale nawet jesli uda mi sie znalesc interesujace mnie kroje czcionek w formacie gdf, to i tak nie wiem jak zmieniac rozmiar tych czcionek, bo szukajac w manualu nic na ten temat nie znalazlem.
Takze najprosciej jest uzyc do tego imagettftext, tylko jak te funkcje imagefontwidth i height "przystosowac" do czcionek tff?
Ps. nie moge edytowac, bo dziwne krzaczki mi sie pokazauja, zamiast mojego tekstu.
