简体   繁体   中英

Bold text using imagefttext() in PHP

I have the below code and I want to bold the output.

Example:

This code;

$info['users_online']);

Outputs the users online count from my database. I want the number that is being output on the image to be bold.

Full code:

<?php
/db info all here/
    $getInfo = mysql_query("SELECT users_online FROM server_status");
$info = mysql_fetch_array($getInfo);
{

$image = imagecreatefrompng("banner.png"); 
$black = imagecolorallocate($image, 1, 1, 1); 
imagefttext($image, 6.5, 1, 293, 68, $black, 'volter.ttf', $info['users_online']);
header('Content-type: image/png'); 
imagepng($image); 
imagedestroy($image); 
}
?>

Don't mind the "/db info all here/" part. I just need the users_online to be bold when it is outputted on the image. Right now, it's not bold.

Thanks.

Use a bold font. For example a bold version of volter.ttf.

You'll want to replace the font file you're currently using ( volter.ttf ) with one which contains the same font, but in bold weight. If you're unable to do so, you might be able to produce a "pseudo-bold" effect by writing the string several times with a slight X-coordinate offset each time, but frankly at that point it's a lot easier just to change the font to something you can find in bold.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM