zoukankan      html  css  js  c++  java
  • php 使用imagettftext()函数出问题的原因

    <?php
    header('Content-type: image/png');
    $im = imagecreatetruecolor(400, 300); //创建画布
    $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);    //输出一个白色填充的矩形背景
    //
    ////string iconv  ( string $in_charset  , string $out_charset  , string $str  )
    ////将字符串 str 从 in_charset 转换编码到 out_charset。
    //
    $text = iconv('gb2312','utf-8','show');
    //
    ////设置字体
    $font = 'C:WindowsFontsmsyh.ttc';
    //
    imagettftext($im, 20, 0, 12, 21, $grey, $font, $text); //输出一个灰色字符串作为阴影
    //imagettftext($im, 20, 0, 10, 20, $black, $font, $text); //输出一个黑色字符串
    //ob_clean();
    imagepng($im);
    imagedestroy($im);

    设置字体的时候要写路径,不然就画不出来了

  • 相关阅读:
    C++ 四种cast 用法
    Wannafly挑战赛1 B Xorto
    python里的闭包
    编译器对类的编译顺序
    class和struct
    typedef类型别名
    decltype类型指示符
    左值和右值
    const限定符
    hdu5678 树上第k小
  • 原文地址:https://www.cnblogs.com/tumio/p/4891834.html
Copyright © 2011-2022 走看看