简体   繁体   中英

Calculate height of a block of text with a fixed width in php

I'm working with a php library that outputs PPT files and have a problem with calculating the height of a box that is populated with text dynamically. What I am thinking of doing is creating a php function that will calculate the height of a block of text given a fixed width and font size.

I've done a bit of research and got some ideas such as use imagettfbbox but for the amount of text I need to process on the fly this solution would not be wise. Another was to store an array of all characters with size properties but this sounds rather tedious but might be the best solution I will go with, however before I do I wanted to see if anybody else has any ideas on how I could achieve this.

Thanks in advance. Steve

您可以通过Imagick尝试字体指标: http ://valokuva.org/?p = 17更多信息请访问: http ://php.net/manual/en/function.imagick-queryfontmetrics.php

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