Create transparent png with custom font family from scratch in php

I convert text to image using PHP with transparent images. I am trying to add a custom font family but I don't know how to add can anyone please help me.

my code:-

$randomNumber = rand(0, 999999999);
$randomNumber = str_replace(0, 1, $randomNumber);
$healthy = [1, 2, 3, 4, 5, 6, 7, 8, 9];
$yummy   = ["I ", "II ", "III ", "IV ", "V ", "VI ", "VII ", "VIII ", "IX "];
$text = str_replace($healthy, $yummy, $randomNumber);

$my_img = imagecreate(300, 80);                             //width & height
$background  = imagecolorallocate($my_img, 0, 0, 0);
$black = imagecolorallocate($im, 0, 0, 0);
$text_colour = imagecolorallocate($my_img, 255,0,255);
imagecolortransparent($my_img, $black);
imagestring($my_img, 30, 30, 25, $text,$text_colour);
imagesetthickness($my_img, 5);
imageline($my_img, 0, 0, 0, 0);

header("Content-type: image/png");
imagecolordeallocate($line_colour);
imagecolordeallocate('red');
imagecolordeallocate($background);
imagepng($my_img);
imagedestroy($my_img);

result:- enter image description here