Drawing Text at a given point using WPainter
Added by Vaidehi Chhajer over 13 years ago
I need to use WPainter's drawText function to label the parts.. bt i need to do it in a way that the center of the text(variable lenght) is anchored at the given point.
Also inorder to check for overlapping of such labels i need to know their co-ordinates and the area it spans (the width, and height). Is there ny way to do it? since WPainter only allows for drawing text in a given Wrect and aligning accordingly instead at a given point.
Replies (2)
RE: Drawing Text at a given point using WPainter - Added by Rob Van Dyck over 13 years ago
The drawing at a point can be simulated by drawing the text (aligned center/middle!) in a rectangle around the point [when the coordinates of the point are (x,y), set the rectangle to (x-10, y-10),(x+10, y+10)].
I don't know how to check for the overlapping.
RE: Drawing Text at a given point using WPainter - Added by Wim Dumon over 13 years ago
Since every browser uses different fonts on every platform, it's not possible for Wt to calculate text metrics server-side. You'll have to use a heuristic approach to detect overlapping.
Wim.