Reputation: 19
I am using PHP to generate images containing only text. Using a variety of different fonts, i.e. Adler, Arial, Vladimir etc.
However I want to be able to specify the height of the image before hand, i.e. 100 pixels and then have the text set to that height and continue as wide as need be.
But I am having issues with using the font size parameter, i.e. font size 100 isn't the same across all my font files and I am not sure how to set the size to get the desired result in pixels.
Is there a way around this, so that I can call imagettfbox with a font size that will result in a box of 100 pixels height (or any other size for that matter)?
Upvotes: 0
Views: 297
Reputation: 2583
Different fonts will render at different sizes for the same size parameter. You need to call imagettfbbox over a range of text sizes until you find a size with the bounding box you like.
Upvotes: 1