Below through a piece of code for you to introduce the next PHP technology to implement loading fonts and save as a picture.
Set the Content-type header ("Content-type:image/png"); Create the image $im = Imagecreatetruecolor (+); Create some colors $white = imagecolorallocate ($im, 255, 255, 255); $grey = Imagecolorallocate ($im, 128, 128, 128); $black = imagecolorallocate ($im, 0, 0, 0); Imagefilledrectangle ($im, 0, 0, 399, N, $white); The text to draw $text = ' dictionary net '; Replace path by your own font path $font = ' Fontname.ttf '; Add some shadow to the text//imagettftext ($im, 0, one, one, $grey, $font, $text); Add the text imagettftext ($im, 0, 0, $black, $font, $text); Using imagepng () results in clearer text compared with imagejpeg () imagepng ($im); Imagedestroy ($im);
If you want to save the diagram, use the following code
Ob_start (); Imagejpeg ($im); $img = Ob_get_contents (); Ob_end_clean (); $size = strlen ($img); $fp 2= @fopen (' tst.jpg ', ' a '); Fwrite ($fp 2, $img); Fclose ($fp 2);
The above code can be finished loading fonts and save as a picture, I hope you will like