是否有某种方式,或一些闪存插件或php脚本,可以将字体面板文本渲染成位图图形?
透明将是伟大的,但即使你可以定义前景颜色或背景颜色。
原因是我需要一些动态数据以html字体显示,最好是以实际字体显示,而不是web安全字体。
谢谢乔希
发布于 2015-01-18 22:12:01
PHP和GD库(通常安装在PHP主机上)能够将真正类型的字体呈现为多种图像格式(包括GIF、PNG和JPG)。具有透明背景的简单示例如下:
<?php
$text = 'My imaged words'; // The text to draw
$font = 'PORCELAIN'; // Replace path by your own font path
$im = imagecreatetruecolor(250, 50); // Create the image
// Create some colors
$red= imagecolorallocate($im, 255, 0, 0);
$black = imagecolorallocate($im, 0, 0, 0);
imagecolortransparent($im, $black); // Choose transparent color
imagettftext($im, 20, 0, 10, 30, $red, $font, $text); // Add the text
imagegif($im, 'wordimage.gif'); // save image
imagedestroy($im); // clear memory
?>更高级的例子可以在http://php.net/manual/en/function.imagettfbbox.php上找到。
GD库是开源的,可以在http://libgd.bitbucket.org上找到。
免费的真正类型的字体很容易找到搜索工程。
https://stackoverflow.com/questions/27398641
复制相似问题