Your code works for me, the "A" rotates around its origin. What's "wrong" is that the origin is not at the center of the letter, but this is expected because text has special alignment rules and the bounding box of a Text object is usually larger than what you see.
Makes sense, but drawing the bounding box as a polygon is really not intuitive, look:
(https://dl.dropbox.com/u/3724424/bug2.png)
The following code displays that image. The origin is displayed in the center of the letter - the user expects the letter to rotate around its origin.
private static void Main
(){ var renderWindow
= new RenderWindow
(new VideoMode
(1024,
768),
"Text Bug"); var font
= new Font
("akz.ttf"); var text
= new Text
("A", font,
60); text
.Position = new Vector2f
(1024 / 2f,
768 / 2f
); text
.Color = Color
.Black; text
.Origin = new Vector2f
(text
.GetGlobalBounds().Width / 2f, text
.GetGlobalBounds().Height / 2f
); while (true) { renderWindow
.Clear(Color
.White); text
.Rotation += 0
.01f
; renderWindow
.Draw(text
); var x
= text
.GetGlobalBounds().Left; var y
= text
.GetGlobalBounds().Top; var width
= text
.GetGlobalBounds().Width; var height
= text
.GetGlobalBounds().Height; var origin
= new Vector2f
(width
/ 2f, height
/ 2f
); var originS
= new Vector2f
(x, y
) + origin
- new Vector2f
(3,
3); var originE
= new Vector2f
(x, y
) + origin
+ new Vector2f
(3,
3); var originColor
= new Color
(255,
0,
0,
255); var originVertices
= new Vertex
[4]; originVertices
[0] = new Vertex
(new Vector2f
(originS
.X, originS
.Y), originColor
); originVertices
[1] = new Vertex
(new Vector2f
(originE
.X, originS
.Y), originColor
); originVertices
[2] = new Vertex
(new Vector2f
(originE
.X, originE
.Y), originColor
); originVertices
[3] = new Vertex
(new Vector2f
(originS
.X, originE
.Y), originColor
); var boundsColor
= new Color
(0,
255,
0,
75); var boundsVertices
= new Vertex
[4]; boundsVertices
[0] = new Vertex
(new Vector2f
(x, y
), boundsColor
); boundsVertices
[1] = new Vertex
(new Vector2f
(x
+ width, y
), boundsColor
); boundsVertices
[2] = new Vertex
(new Vector2f
(x
+ width, y
+ height
), boundsColor
); boundsVertices
[3] = new Vertex
(new Vector2f
(x, y
+ height
), boundsColor
); renderWindow
.Draw(originVertices, PrimitiveType
.Quads); renderWindow
.Draw(boundsVertices, PrimitiveType
.Quads); renderWindow
.Display(); } }
Also, for my project, I actually need letters to rotate around their center. How can I achieve that?