将字体文本转换为呈现的图形位图


Turn font-face text into bitmap rendered graphic?

有没有办法,或者一些flash插件或php脚本可以将字体文本呈现为位图图形?

透明会很棒,但即使你可以定义前景色或背景色。

原因是我需要一些动态数据以 html 字体显示,理想情况下以实际字体而不是 Web 安全字体显示。

谢谢乔希

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 找到。

搜索搜索很容易找到自由的真类型字体。