Ticket #14489 (closed defect: fixed)
Incorrect SVG text coordinates in wxSVGFileDC
|Reported by:||neilc||Owned by:|
|Keywords:||wxDC SVG text descent||Cc:|
When using DrawRotatedText() drawing to wxSVGFileDC, the SVG coordinates generated in the SVG XML do not properly take into account the text descent (in wxSVGFileDCImpl::DoDrawRotatedText() ). Furthermore, the calls to CalcBoundingBox() use the wrong trigonometry transforms for the bottom-right point and also for the rectangle when the background mode in solid. Patch to fix the issue attached including a test in the SVG sample which draws boxes around where the text should be.
A bit more detail:
When using wxDC::DrawRotatedText(), the position coordinates refer to the top-left of the text. In SVG, the position coordinates refer to the left (thinking of unrotated text) of the text baseline. (info here: http://commons.oreilly.com/wiki/index.php/SVG_Essentials/Text)`wxSVGFileDCImpl::DoDrawRotatedText()` was previously setting the SVG position coordinates to the bottom left of the text rather than the baseline. i.e. it wasn't taking the text descent into account.
The incorrect bottom-right point stands out if you follow through the code assuming no rotation (angle of 0).
For when the background mode is solid, the text descent is used in the y-coordinate calculation but this coordinate is incorrect.
It would be useful if these modifications were double-checked.