Я работаю с моим маленьким проектом, который необходимо следующее:PHP шрифт изменение ImageString()
- Там должен быть текст на передней части изображения.
- Текст находится по центру.
Мой код следует наставлениям, но я хочу, чтобы изменить шрифт текста ..
ImageString($background, $font_size, $position_center, $position_middle, $text, $textcolor);
Вот мой полный код:
header('Content-type: image/png');
$background1 = "files/bg.png";
$background = imagecreatefrompng($background1);
$width = 630;
$height = 315;
$text = "EXAMPLE TEXT";
$font_size = 50;
$font_family = "files/tahoma.ttf";
$font_width = ImageFontWidth($font_size);
$font_height = ImageFontHeight($font_size);
$text_width = $font_width * strlen($text);
$position_center = ceil(($width - $text_width)/2); //CENTER THE TEXT
$text_height = $font_height;
$position_middle = ceil(($height - $text_height)/2); // MIDDLE THE TEXT
$textcolor = ImageColorAllocate($background, 255, 255, 255);
$image_string = ImageString($background, $font_size, $position_center, $position_middle, $text, $textcolor);
imagepng($background);
imagedestroy($background);