用imagettftext生成带文字的图片,如果控制文字的每个字符之间的间距?
查阅了很多资料没有找到解决方法,请高手指教!array imagettftext ( resource image, int size, int angle, int x, int y, int color, string fontfile, string text)另外还有一个
array imagefttext  ( resource $image  , float $size  , float $angle  , int $x  , int $y  , int $color  , string $fontfile  , string $text  [, array $extrainfo  ] )可以有额外的extrainfo,但是经过查阅发现目前只支持设置lineheight。困惑。。

解决方案 »

  1.   

    size决定间距吧
    如果还不是理想的情况,自己人为控制.
      

  2.   

    imagettfbbox -- 取得使用 TrueType 字体的文本的范围

    imagettftext 逐字书写
      

  3.   

    @xuzuning还是不行,能不能给一个简单的示例?
      

  4.   

    ͨ���ı�$font_spacing����������<?php
    // macleo 2008.9.20.Sat.
    //������д....���ɵ�....ͨ��$font_spacing����//defined ttf location and text will display
    $font_path = "font/";
    $font_name = $font_path."fzhc_GBK.ttf";
    $font_size = 50;
    $font_angle = 0 ;
    $text = array("��","��","��","д","��","��","��","��");
    $font_spacing = 25;//�ּ���������
    $picname = "CanAdjust";
    $position_x = 50;//first Character coordinate x;
    $position_y = 70;//first Character coordinate x;
    $font_shade_spacing_x = 3;
    $font_shade_spacing_y = 3;
    $im = imagecreatetruecolor(800, 100);// colors
    $white = imagecolorallocate($im, 0xff, 0xff, 0xff);
    $grey = imagecolorallocate($im, 0x98, 0x98, 0x98);
    $black = imagecolorallocate($im, 0x00, 0x00, 0x00);imagefilledrectangle($im, 0, 0, 800, 100, $white);
    // line
    imageline ( $im, 799, 0, 0, 0, $black );//top
    imageline ( $im, 799, 99, 0, 99, $black );//bottom
    imageline ( $im, 0, 99, 0, 0, $black );//left
    imageline ( $im, 799, 99, 799, 0, $black );//right// get weight of every character of Chinese
    $font_coordinate = imagettfbbox ( $font_size, $font_angle, $font_name, $text[0] );
    $font_weight = $font_coordinate[2] - $font_coordinate[0];
    $font_height = abs($font_coordinate[5]) - $font_coordinate[3];//output text from array
    for($count = 0  ; $count<=count($text) ; $count++)
    {
             $arr = imagettftext($im, $font_size, $font_angle , $position_x , $position_y, $grey, $font_name, $text[$count]);
              imagettftext($im, $font_size, $font_angle , $position_x-$font_shade_spacing_x , $position_y-$font_shade_spacing_y, $black, $font_name, $text[$count]);
             $position_x = $position_x + $font_weight + $font_spacing;
    }        header('Content-disposition: inline; filename='.$picname.'.png');
            imagepng($im);
            ImageDestroy($im);
    ?>
      

  5.   

    逐字书写....间距可调....通过$font_spacing调整
      

  6.   

    逐字书写....间距可调....通过$font_spacing调整