使用自己的字体呈现php图像

使用自己的字体呈现php图像,php,image,fonts,rendering,truetype,Php,Image,Fonts,Rendering,Truetype,我想在此代码中使用自己的字体True类型: <?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"); $backg

我想在此代码中使用自己的字体True类型:

<?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);
?>

如何更改:Open Sans Semibold中的字体?路径为../fonts/opensans\u semibold\u macroman/opensans semibold webfont.ttf。

不要使用imagestring函数使用imagettftext,此函数允许使用ttf字体

$font_file = "../fonts/opensans_semibold_macroman/OpenSans-Semibold-webfont.ttf";
imagettftext ($im, 3, 0, 5, 2, $text_color, $font_file, $email);