【发布时间】:2014-12-10 10:27:48
【问题描述】:
有什么方法,或者一些Flash插件或php脚本可以将字体文本呈现为位图图形吗?
透明会很棒,但即使您可以定义前景色或背景色。
原因是我需要一些动态数据以 html 字体显示,最好以实际字体显示,而不是网络安全字体。
谢谢 乔什
【问题讨论】:
-
你试过Embedding fonts吗?
标签: javascript php flash font-face
有什么方法,或者一些Flash插件或php脚本可以将字体文本呈现为位图图形吗?
透明会很棒,但即使您可以定义前景色或背景色。
原因是我需要一些动态数据以 html 字体显示,最好以实际字体显示,而不是网络安全字体。
谢谢 乔什
【问题讨论】:
标签: javascript php flash font-face
PHP 与 GD 库(通常安装在 PHP Web 主机上)一起能够将 True Type 字体呈现为多种图像格式(包括 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。
搜索引擎很容易找到免费的 True Type 字体。
【讨论】: