PHP GD Font Test
PHP
Download (.zip)
<?php // sample to print out the buildin GD fonts as png picture. // to view source call with: gd_fonttest.php?viewsource=1 // call f.e. with: gd_fonttest.php?trans=1 // v0.11 20-Sep-2004, by G. Knauf <efash@gmx.net> if ($_GET['viewsource']) { echo highlight_string(file_get_contents($_SERVER['SCRIPT_FILENAME'])); die; } extension_loaded('gd') or die ("Error: GD extension not loaded!");
function charmap($im, $font, $title, $topoffset, $lineskip, $tcolor, $ccolor) { ImageString($im, $font, 16, $topoffset, $title.':', $tcolor); $ix = ImageFontWidth($font); for ($line = 0; $line < 4; $line++) { for ($row = 0; $row < 64; $row++) { ImageString($im, $font, 16 + ($row * $ix), $topoffset + (1 + $line) * $lineskip, chr($line * 64 + $row), $ccolor); } } }
$im = @ImageCreate (640, 500); $bg_color = ImageColorAllocate ($im, 250, 255, 205); $f1_color = ImageColorAllocate ($im, 0, 0, 255); $f2_color = ImageColorAllocate ($im, 233, 14, 91); if ($_GET['trans']) ImageColorTransparent($im, $bg_color);
define ("gdTinyFont", 1); define ("gdSmallFont", 2); define ("gdMediumBoldFont", 3); define ("gdLargeFont", 4); define ("gdGiantFont", 5); charmap($im, gdGiantFont, "GiantFont 9x15", 20, 16, $f1_color, $f2_color); charmap($im, gdLargeFont, "LargeFont 8x16", 120, 16, $f1_color, $f2_color); charmap($im, gdMediumBoldFont, "MediumBoldFont 7x13b", 220, 13, $f1_color, $f2_color); charmap($im, gdSmallFont, "SmallFont 6x13", 320, 13, $f1_color, $f2_color); charmap($im, gdTinyFont, "TinyFont 5x8", 420, 8, $f1_color, $f2_color);
Header("Content-type: image/png"); ImagePng($im); ImageDestroy($im); ?>
|