php中用GD库的imagettftext()函数生成图片失败怎么办?
PHPz
PHPz 2017-04-10 17:30:11
[PHP讨论组]

我想根据输入的文字,生成特定字体的图片,根据php.net上的样例,并不能生成正确的图片,请问该怎么办?

样例中的图片:

我的图片:

代码:


我用的lnmp一键包搭的环境,编译里有--with-free-type-dir,

'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--with-xsl'

另外也支持free type:


更新:
在我改成用simhei.ttf(黑体 常规)字体后就可以正常显示了,为什么呢。。。

PHPz
PHPz

学习是最好的投资!

全部回复(1)
大家讲道理

imagettftext支持TrueType类型的字体,imagepstext支持 PostScript Type1 字体。所以需要找到对应的字体,才会生效。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号