Php 如何在CONTENT-TYPE:image/png中显示粗体或更改某些文本的颜色?

Php 如何在CONTENT-TYPE:image/png中显示粗体或更改某些文本的颜色?,php,image,content-type,Php,Image,Content Type,我有像“K代表King”这样的字符串。我已经将其转换为图像,现在我必须加粗的“国王”或更改为任何颜色。可能吗 header ('Content-Type: image/png'); $string = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ev

我有像“K代表
King”这样的字符串。我已经将其转换为图像,现在我必须加粗的“国王”或更改为任何颜色。可能吗

   header ('Content-Type: image/png');
    $string         = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. <b>It was popularised in the 1960s<b> with the release of <b>Letraset<b> sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";       

    $fontSize       = 14;
    $lines          = explode("\n", wordwrap($string, 100, "\n"));

    $margin         = 5;
    $heightImage    = count($lines) * $maring  + $margin;

    $image  = imagecreatetruecolor (400, $heightImage);
    $white  = imagecolorallocate ($image,255,255,255);
    $black  = imagecolorallocate ($image,0,0,0);
    $blue   = imagecolorallocate ($image,0,0,266);

    $fontPath = '../css/fonts/font/OpenSans-Regular.ttf';
    imagefill($image,0,0,$white);

    foreach ($lines as $line) {

        imagettftext($image, $fontSize, 0, 0, $margin, $black, $fontPath, $line);
        $margin += 5      
    }


    imagepng ($image);
    imagedestroy($image);
header('Content-Type:image/png');
$string=“Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布(包括Lorem Ipsum版本)而流行。”;
$fontSize=14;
$lines=explode(“\n”,字包装($string,100,“\n”);
$margin=5;
$heightImage=计数($line)*$maring+$margin;
$image=imagecreatetruecolor(400,$heightImage);
$white=imagecolorallocate($Image255255);
$black=imagecolorallocate($image,0,0,0);
$blue=图像颜色分配($image,0,0266);
$fontPath='../css/fonts/font/OpenSans Regular.ttf';
图像填充($image,0,0,$white);
foreach($line作为$line){
imagettftext($image,$fontSize,0,0,$margin,$black,$fontPath,$line);
$margin+=5
}
imagepng($image);
图像销毁($图像);

您是如何将文本转换为图像的?编辑问题您对此有何看法???