What are the limitations of using non-proportional fonts with GDLib in PHP for creating circular text?

When using non-proportional fonts with GDLib in PHP for creating circular text, the main limitation is that the characters will not align properly on the circular path due to varying character widths. To solve this issue, you can calculate the spacing between characters based on the font size and adjust the positioning accordingly.

// Set the font size and type
$font_size = 20;
$font = 'arial.ttf';

// Text to display
$text = 'Circular Text';

// Calculate the spacing between characters
$spacing = $font_size * 0.6;

// Initialize variables for positioning
$angle = 0;
$radius = 100;

// Create image
$image = imagecreatetruecolor(400, 400);
$white = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image, 0, 0, 400, 400, $white);

// Loop through each character and position on the circle
for($i = 0; $i < strlen($text); $i++) {
    $char = $text[$i];
    $bbox = imagettfbbox($font_size, $angle, $font, $char);
    $x = 200 + cos(deg2rad($angle)) * $radius - ($bbox[2] - $bbox[0]) / 2;
    $y = 200 + sin(deg2rad($angle)) * $radius - ($bbox[5] - $bbox[1]) / 2;
    imagettftext($image, $font_size, $angle, $x, $y, 0, $font, $char);
    $angle += $spacing;
}

// Output image
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);