PHP imagechar, 图形验证码 字体太小问题

bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int$color )

imagechar() 将字符串 c 的第一个字符画在 image 指定的图像中,其左上角位于 xy(图像左上角为 0, 0),颜色为 color。如果 font 是 1,2,3,4 或 5,则使用内置的字体(更大的数字对应于更大的字体)。

Example #1 imagechar() 例子

<?php
    @header("Content-type: image/png");
    $im = imagecreatetruecolor(400, 30);

    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 399, 29, $white);

    $text = 'Testing...';
    $font = 'arialnarrow.ttf';
    $font_size=12;
    $wing=0;
    $left=5;
    $high=21;

    imagettftext($im, $font_size, $wing, $left,$high, $grey, $font, $text);
  
    imagepng($im);
    imagedestroy($im);
?>

解决方案:更换字体,例如 arialnarrow.ttf

 问题解决!