问题
I want to use a own font (True Type) in this code:
<?php
header("Content-type: image/png");
// Email adres renderen
$email = "mail@mail.nl";
$length = (strlen($email)*8);
$im = @ImageCreate ($length, 20)
or die ("Kan geen nieuwe afbeelding genereren");
$background_color = ImageColorAllocate ($im, 53, 88, 121); // Container BG: 53,88,121
$text_color = ImageColorAllocate ($im, 194, 212, 229);
imagestring($im, 3,5,2,$email, $text_color);
imagepng ($im);
?>
How can i change the font in: Open Sans Semibold? The path is ../fonts/opensans_semibold_macroman/OpenSans-Semibold-webfont.ttf.
回答1:
Do not use imagestring function use imagettftext, this function allow use TTF fonts.
$font_file = "../fonts/opensans_semibold_macroman/OpenSans-Semibold-webfont.ttf";
imagettftext ($im, 3, 0, 5, 2, $text_color, $font_file, $email);
来源:https://stackoverflow.com/questions/26454455/render-php-image-with-own-font