用户评论:

soletan at toxa dot de (2010-08-15 07:35:46)

As of PHP 5.2.13 with bundled GD (2.0.34) antialiasing_steps mustn't be "4 to 16", but "4 or 16". Values from 5 to 15 result in a warning.

whitemarker dot blogspot dot com (2007-09-19 11:28:21)

The documentation above is bad. It says $font:

"Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont()."

But it can't. When I put in 1,2,3,4,5 I get

"Warning: imagepstext() expects parameter 3 to be resource, integer given"

I get the same thing when using imageloadfont() because imageloadfont() also returns an integer. The documentation should instead say:

"resource returned from imagepsloadfont()."

chrislewis60 at hotmail dot com (2007-07-23 07:45:18)

imagepstext() appears to be quite memory intensive and we had a problem where about 50% of the time the script would error. You need to make sure PHP has enough memory assigned to it - we had to increase PHP's allocation from 8MB to 16MB for a simple "hello world" example to work smoothly.

If the png header was commented out it would sometimes error with a message like:

Warning: imagepstext() [function.imagepstext]: T1Lib Error 11 or 14

and if the png header was there it would sometimes say:

The image [...] cannot be displayed, because it contains errors.

honza dot bartos at gmail dot com (2006-10-24 04:38:41)

The coordinates given by x, y represent actually a starting point of the text baseline. They represent the lower left corner of the first character only in case that any part of the character doesn't lie below baseline (it works for "Hello" but for "Howdy" it does not - because of letter y). There may be some small differences according to the font and size chosen.

heckp at uni-trier.de (2003-07-10 05:11:29)

It is important so make shure that the "text" really is a string.

imagepstext ($im, $text, $font, $textsize, $black, $white, 10, 10);

won't work if $text is undefined, so PHP will quit with an error.

so always write it like this:

imagepstext ($im, "$text", $font, $textsize, $black, $white, 10, 10);

m.confalonieri(at)mclink.it (2003-06-04 06:00:32)

I found a way to let imagepstext understand 32-bit colors (RGBA) by replacing in gd.c:PHP_FUNCTION(imagepstext)

int _fg, _bg, x, y, size, space = 0, aa_steps = 4, width = 0;

with

unsigned int _fg, _bg, x, y, size, space = 0, aa_steps = 4, width = 0;

Jeroen dot Straahof at newego dot nl (2003-02-06 18:12:18)

I made a function that makes it easy to align text to the right

of an image. Below you can find the code because for me it

works great. You can also use it to center text as well, if you

like to have that simply remove the -10 and split the result

of $imgwidth and $texwidth

function AlignRight($string, $font, $imgwidth, $fontsize) {

list($lx,$ly,$rx,$ry) = imagepsbbox($string,$font,$fontsize,0,0,0);

$textwidth = $rx - $lx;

$imw = ($imgwidth-10-$textwidth);

return $imw;

}

johan (at) 1way2print.net (2002-11-06 02:17:48)

If you use fonts with special chars, remeber to read in the encoded file *.enc with imagepsencodefont ... etc. for Danish, Swedish, German.....

a at url dot de (2002-02-18 06:16:42)

a note on kernnig:

t1lib tries to load a corresponding afm file in the directory of the font file.

it does this by replacing the extension (.PFB .pfb) with ".afm". note that this has to be a lowercase afm! usually windows-ps-fonts have file names in all-uppercase, so try renaming the *.AFM file to *.afm.

i also noticed that sometimes this gives an error -2. it seems like t1lib chokes on windows-linebreaks in the afm file.

try 'recode dos..lat1 fontfile.afm' and check again.

if it all works, combinations like "Ta" or "Te" should show the second letter slightly moved to the capital T (on normal fonts like Times anyway).

npdavis at hotmail dot com (2001-05-24 09:09:35)

If you have a programming error in your code, using ImagePsText, sometimes t1lib crashes with an unrecoverable error. Because of this, httpd needs to be restarted.

This problem only occurs if there is a programming error, but can drive you crazy when debugging, if you don't know about it. By killing the parent process(httpd) you "reset" t1lib. When debugging, if you get an error then make a code change, restart httpd before testing it again. This will save hours of frustration. Make it a habit to just restart httpd after every error, and you will be much happier.

Also, to see debugging messages, (if you are rendering x's) comment the jpeg header, and the ImageJpeg statement. You will get beautiful error messages. When you get a blank page, your ImagePsText code is working correctly. Uncomment the Header() and ImageJpeg() and see what you have. You might be passing parameters that render a white image with no text, but the code is working!

Numeric t1lib error messages can be decoded using the t1lib_doc.pdf file that comes with t1lib. PHP simply relays these errors from t1lib to the page. Please don't ask the PHP people about these errors... t1lib has beautiful documentation.... use it: )

thx,

Neil

npdavis at hotmail dot com (2001-05-24 08:56:44)

One other thing... variables. It is important to convert variables to the proper type before they hit this function. In this respect, ImageTtfText is easier to work with. IE, if you pass a font size from one page to the next, via GPC, it becomes a string type. Sooo... use IntVal() to convert it to an integer type that ImagePsText can digest. In addition you must convert HTML special characters or use chr() to represent special characters. ImagePsFont will not decode ? to represent a space, use Chr(32) or a space:

$fontsize=IntVal($fontsize);$font=ImagePsLoadFont("fonts/IntR.pfb");ImagePsText($im,$textstring,$font,$fontsize,$textcolor,$background,0,$fontsize,'','','',16);//note antialias is setImagePsFreeFont($font);?>

thx,

Neil

npdavis at hotmail dot com (2001-05-22 05:54:51)

with a font included in t1lib:

Header("Content-type: image/jpeg");$im=ImageCreate(350,45);$black=ImageColorAllocate($im,0,0,0);$white=ImageColorAllocate($im,255,255,255);$font=ImagePsLoadFont("bchbi.pfb");ImagePsText($im,"Testing... It worked!",$font,32,$white,$black,32,32);ImagePsFreeFont($font);ImageJpeg($im,"",100);//for best quality... your mileage may varyImageDestroy($im);?>

Better than using freetype, but with freetype2, the difference is marginal. To flip backround and foreground colors, alternate the order of ImageColorAllocate statements.

If you get outlines (the antialiasing produces these) reverse the $black and $white color identifiers in the ImagePsText function.

Happy PostScripting!

thx,

Neil

php 绘制图像如何设置字体,PHP 用 PostScript Type1 字体把文本字符串画在图像上相关推荐

  1. matlab中保存imagesc呈现的图像内容以及保存图像大小设置

    1.抓取imagesc绘制的图像内容: 示例: imagesc(t2+timestart-wlen/fs/2,f,abs(tfr2)); saveas(gca,strcat('C:\Users\Adm ...

  2. 教您画函数图像的方法

    函数图像是学习函数知识的一种直观展示,通过画出函数图像,就可以辨别函数图像的性质,在黑板上老师都是大概建立函数图像,并不能做到标准画出,下面就一起来学习用专业的绘图工具画函数图像的方法. 几何画板免费 ...

  3. 给几个关键词就能出摄影大片,英伟达GauGAN上新2.0:将文本转成逼真图像

    来源丨机器之心 作者丨小舟.陈萍 这么美的照片竟然不是出自摄影师之手?! 在 2019 年举办的 GTC 大会上,英伟达展示了一款新的交互应用 GauGAN:利用生成对抗网络(GAN)将分割图转换为栩 ...

  4. python图像加坐标_Python使用matplotlib模块绘制图像并设置标题与坐标轴等信息示例...

    本文实例讲述了Python使用matplotlib模块绘制图像并设置标题与坐标轴等信息.分享给大家供大家参考,具体如下: 进行图像绘制有时候需要设定坐标轴以及图像标题等信息,示例代码如下: #-*- ...

  5. matplotlib绘制图表,设置刻度标签、最大最小刻度、字体大小,label位置、刻度轴箭头等

    matplotlib绘制图表,设置刻度标签.最大最小刻度.字体大小,label位置.刻度轴箭头等 1. 效果图 2. 源码 2.1 仅使用普通轴ax + fontdict 源码 2.2 使用mpl设置 ...

  6. R语言可视化绘制及PDF使用字体参数列表:查看字体列表、可视化绘制图像中的字体参数列表、字体示例并写入pdf

    R语言可视化绘制及PDF使用字体参数列表:查看字体列表.可视化绘制图像中的字体参数列表.字体示例并写入pdf 目录 R语言可视化绘制及PDF使用字体参数列表:查看字体列表.可视化绘制图像中的字体参数列 ...

  7. python中matplotlib自定义设置图像标题使用的字体类型:获取默认的字体族及字体族中对应的字体、自定义设置图像标题使用的字体类型

    python中matplotlib自定义设置图像标题使用的字体类型:获取默认的字体族及字体族中对应的字体.自定义设置图像标题使用的字体类型 目录

  8. Python绘图之matplotlib基础教程:matplotlib库图表绘制中常规设置大全(交互模式、清除原有图像、设置横坐标显示文字/旋转角度、添加图例、绘图布局自动调整、图像显示、图像暂停)

    Python绘图之matplotlib基础教程:matplotlib库图表绘制中常规设置大全(交互模式.清除原有图像.设置横坐标显示文字/旋转角度.添加图例.绘图布局自动调整.图像显示.图像暂停) 目 ...

  9. 安卓学习笔记31:使用自定义视图绘制文本、图形与图像

    文章目录 零.学习目标 一.自定义视图 (一)自定义视图概述 (二)使用自定义视图基本步骤 (三)案例演示 - 使用自定义视图绘制圆 1.创建安卓应用[DrawCircle] 2.创建自定义视图 - ...

最新文章

  1. JVM XMX设置多大比较好,Docke容器里该怎么设置JVM呢@无界编程
  2. 思杰“个人云”翻开企业人本管理新篇章
  3. C#调用C/C++动态库Dll时几个注意事项:PInvoke错误
  4. 分数等级_志愿填报丨填报公办普通高中志愿,分数成绩和等级成绩均需关注
  5. python下载大文件-python 大文件
  6. Exchange 2013之(三)CAS部署
  7. 计算机组网技术与配置 pdf,教案计算机组网技术.pdf
  8. ueditor 不显示工具栏_Python 之Django富文本框Ueditor的使用
  9. 简单的busybox创建_用Busybox创建文件系统
  10. 开发VR游戏的基本要求
  11. spirng cloud docker部署
  12. Django后端项目----restful framework 认证源码流程
  13. 花花省淘宝客APP源码带淘宝京东拼多多唯品会优惠券自营商城本地生活CPS外卖优惠电影票话费
  14. 软件开发流程都是什么样的呢?
  15. 中兴ZXV10 B860AV1.1 全TTL操作完美破解
  16. 基于fabric的行业联盟链技术研究/司帅帅
  17. 多功能芯片——GSV2002
  18. qml中Popup元素的 aboutToShow和 opened()的区别
  19. Easy EDA #学习笔记04# |Type-C Micro USB APPLELighting 充电头
  20. 操作系统-进程调度实验报告

热门文章

  1. 恺撒密码加解密程序(Python)
  2. vue设置组件高度100%
  3. Matlab中cov函数详细解读
  4. Winpcap 4.1.3 已经支持win8
  5. 批判性思维 带你走出思维的误区 原书第9版_(美)摩尔,(美)帕克著2012.01北京:机械工业出版社_P308_完整版PDF电子书下载 带索引书签目
  6. linux rdesktop 远程,linux下rdesktop远程联接windows系统(配合xshell工具的使用及遇到的问题)...
  7. minix模拟android,MINIX NEO Z64小型PC上市,预装Android OS
  8. C语言实现二进制转十进制
  9. 放大电路中耦合电容的选择
  10. Windows远程连接linux服务器出现闪退