I have a function that takes a font (ttf or otf file) and generates the text image in different fonts is.
The problem is that I am trying to work on how I can fit the text in the image regardless of the font size, type of font and text.
I have tried to create an image rectangle variable so that the image is not included in the text of different fonts, because the image is not long or wide.
Here I have the function that I have, I have tried to use the number of characters to set the width of the image, but in some cases for some fonts and sizes, it is still cut goes.
function gener_image ($ save_path, $ text, $ Font_path) {$ length = Stellon ($ text) * 15; // Create image $ im = imagecreatetruecolor ($ length, 40); $ White = imagecolorallocate ($ im, 255, 255, 255); $ Gray = imagecolorallocate ($ im, 128, 128, 128); $ Black = imagecolorallocate ($ im, 0, 0, 0); ImageFilterTagon ($ im, 0, 0, $ length, 40, $ white); $ Font = $ font_path; False image ($ im, 30, 0, 0, 25, $ black, $ font, $ text); If (imagepng ($ im, $ save_path)) {$ status = true; } And {$ status = false; } Imagedestroy ($ im); Return status; }
Thanks to all of you for any help
Comments
Post a Comment