Thanks for this brilliant module! Currently, the positioning for the text to canvas action only works if the angle is 0. imagettfbbox returns points relative to the text and regardless of angle, so the positioning needs to be adjusted if the angle isn't 0.

Comments

patrickharris’s picture

H'mmm - left & right partly work with an angle of 90, but Y centering is faulty. Even at an angle of 0, the Y center position doesn't seem to calculate properly, especially as the text size gets bigger. There is an interesting discussion at http://nz2.php.net/manual/en/function.imagettfbbox.php.

dman’s picture

Status: Active » Closed (works as designed)

That's actually intentional.
I have a heuristic in there which may be throwing the calculations off a bit.
IIRC, I added like 0.5em to the bottom of the text when calculating the bounding box, as it looked consistantly bad (and occasionally lost its descenders, depending on font) when aligning bottom without any margin. OTOH, it didn't hurt top alignment. and Center alignment may be off a few pixels, yeah.

In my handful of tests, this gave acceptable results in most circumstances, but I did not try text rotation too hard - As I soon decided I was better off using PNG overlas for my 'watermark' anyway. Plus, plaintext was a bit dull unless I was going to make it configurable. Basically, text is gonna suck most of the time. Plus rotated text was hard to calculate a good position for.

It is certainly a fudge - but only because of the keyword positioning. If that gets better (eg, we can say bottom-12px) then this should be revisited. In the meantime, it's actually by design.