我有这么小的请求,因为我有一个PHP代码,我不知道如何添加一个字体,我知道我必须添加一个imageloadfont但是当它添加生成器只是不起作用。我已经在脑子里尝试过所有的东西而且什么都没有。
<?php
if( isSet( $_GET[ 'Address' ] ) )
{
$szAddress = $_GET[ 'Address' ];
$szExploded = explode( ":", $szAddress );
$szServerIP = $szExploded[ 0 ];
$szServerPort = $szExploded[ 1 ];
$Query = new SourceQuery( );
$Info = Array( );
$Rules = Array( );
$Players = Array( );
try
{
$Query -> Connect( $szServerIP, $szServerPort, DEF__TIME_OUT);
$Info = $Query -> GetInfo( );
$Players = $Query -> GetPlayers( );
$Rules = $Query -> GetRules( );
}
catch( Exception $e )
{
$Exception = $e;
}
$Query -> Disconnect( );
header( "Content-type: image/png" );
$rImage = imagecreatefrompng( DEF__IMAGE_NAME );
$iColor = imagecolorallocate( $rImage, DEF__COLOR_RED, DEF__COLOR_GREEN, DEF__COLOR_BLUE );
// bool imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color )
imagestring( $rImage, DEF__ADDRESS_TEXT_SIZE, DEF__ADDRESS_X, DEF__ADDRESS_Y, $szAddress, $iColor );
if( $Info[ 'MaxPlayers' ] != 0 )
{
$szHostName = MIRAGE;
$szMapName = $Info[ 'Map' ];
if( strlen( $szHostName ) > DEF__HOSTNAME_MAX_TEXT_LEN )
{
$szHostName = substr( $Info[ 'HostName' ], 0, DEF__HOSTNAME_MAX_TEXT_LEN ). ' ...';
}
if( strlen( $szMapName ) > DEF__MAP_MAX_TEXT_LEN )
{
$szMapName = substr( $szMapName, 0, DEF__MAP_MAX_TEXT_LEN ). '..';
}
imagestring( $rImage, DEF__HOSTNAME_TEXT_SIZE, DEF__HOSTNAME_X, DEF__HOSTNAME_Y, $szHostName, $iColor );
imagestring( $rImage, DEF__MAP_TEXT_SIZE, DEF__MAP_X, DEF__MAP_Y, $szMapName, $iColor );
imagestring( $rImage, DEF__PLAYERS_TEXT_SIZE, DEF__PLAYERS_X, DEF__PLAYERS_Y, $Info[ 'Players' ]. '/' .$Info[ 'MaxPlayers' ], $iColor );
}
else
{
imagestring( $rImage, DEF__PLAYERS_TEXT_SIZE, DEF__PLAYERS_X, DEF__PLAYERS_Y, "SERVER OFF", $iColor );
}
$font_width = ImageFontWidth(5);
imagepng( $rImage );
imagedestroy( $rImage );
}
?>