windows用户到 C:\WINDOWS\Fonts 目录下找一个你要用的中文的字体 ttf文件。

我用的是华文宋体(TrueType) 放到你要运行的php文件的目录下,这个你随便放,路径不写错就可以

 

<?php
// set up image 
$im = ImageCreateTrueColor(200, 200);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);

$wenben = "简体中文";
ImageFill(
$im, 0, 0, $black);
ImageLine(
$im, 0, 0, 200, 200, $white);
$font = "E:\\xampp\\htdocs\\test\\gd\\STSONG.TTF";

imagettftext(
$im, 12, 0, 50, 150, $white , $font, $wenben);

// output image
Header ('Content-type: image/png');
ImagePng(
$im);
// clean up 
ImageDestroy($im);
?>

相关文章:

  • 2021-12-24
  • 2021-04-05
  • 2021-10-05
  • 2021-12-04
  • 2021-07-01
  • 2021-08-17
  • 2021-08-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-08-14
  • 2021-07-14
  • 2022-12-23
相关资源
相似解决方案