Centered text in custom entity subWorldDraw

Centered text in custom entity subWorldDraw

Anonymous
Not applicable
604 Views
2 Replies
Message 1 of 3

Centered text in custom entity subWorldDraw

Anonymous
Not applicable
Hello,

I have a custom entity for marking rebars. Part of the entity displays rebar designation in a circle. I want to center the designation text inside the circle. How can I do this inside the entities subWorldDraw? I am using mode->geometry()->text(); but couldn't find any setting for adjusting text alignment.

Thanks,
Ozgur Ozcitak
0 Likes
605 Views
2 Replies
Replies (2)
Message 2 of 3

alex_b
Advocate
Advocate
You have to call extents() on the text style (after setting the font and text height) with your string. Depending upon the text justification you want, you then transform the text insert point by a matrix whose components are extents.x and extents.y, each multiplied by appropiate factors. For Centered text, the components are [-extents.x*0.5, 0] i.e. you move it left by half the text length. You do this before aplying any other transforms (rotations etc.).
alex
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks a lot.
0 Likes