php - 怎么计算gd 函数库中类似于 imagettftext imagestring 这样的函数设置的字体大小的像素高宽??
PHP中文网
PHP中文网 2017-04-10 18:11:23
0
1
413
怎么计算 imagestring($source,$font_size,$x,$y,$string,$color) 中$font_size(除去预置的1-5)设置的字体大小所对应的像素值??
这边的$font_size(除去预置的1-5)设置的字体大小的单位是什么?? 即若是$font_size=15,那是指字体大小为15px??
PHP中文网
PHP中文网

认证0级讲师

répondre à tous(1)
大家讲道理

你可以使用 imagettfbbox 函数来计算TTF字体的字符串的高度宽度, 并且用 imagettftext 来写入图像

http://php.net/manual/zh/function.imagettfbbox.php
http://php.net/manual/zh/function.imagettftext.php

补充:
你提到的 imagestring 函数, 第二个参数不是什么 fontsize 而是 font, 是GD预制的5个字体, 大小你是不能修改的, 如果你希望采用额外的字体, 需要用 imageloadfont 函数来加载, 加载的也并不是ttf字体, 所以你期望的效果如果通过这两个函数是不行的

http://php.net/manual/zh/function.imagestring.php
http://php.net/manual/zh/function.imageloadfont.php

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!