'fpdf getStringHeight equivalent to getStringWidth
I am trying to implement (in PHP using fpdf, https://www.fpdf.org) a getStringHeight($string) method, giving me back the height in pixel of the passed string
fpdf has the very useful getStringWidth method but, even looking into the source code, I couldn't find anything like getStringHeight.
The only possible idea that I have, is that I would render it somewhere, and then I would check in the bitmap itself when I see some pixels... With something like this (with some more ifs...):
y = yCoordinateOfTheString
while thisRowOfPixelsIsTotallyEmpty(y)
++y
start = y
while thereIsAtLeastOnePixelInThisRow(y)
++y
end = y
height = end - start + 1
Of course, this would be crazy inefficient, so... Is there another way? Thank you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
