GDI Text Rotation

XL Jedi

Active member
Joined
Apr 2, 2007
Messages
44
Location
Florida
Programming Experience
10+
I've developed a vector-based navigation app using the GDI.

I draw multiple vectors while using the app and I have code that assigns text to the lines I create. Presently, I'm using the Graphics.Drawstring command to create the text and before I issue the command, I hit it with Graphics.Transform to rotate properly.

The problem that I'm having is that the text (in this case Arial font) rotates fine, but the Graphics.SmoothingMode.AntiAlias doesn't seem to work on text. So I get these pretty AA rendered lines matched up with blotchy non-AA text.

Here's a picture of what I'm talking about:

MoBo_Text.png


Notice above that the degrees on my compass are kinda blotchy and the horizontal vector displaying "3121 yd" looks OK, but as I move the nodes in my app, you can see how the "3121" text gets blotchy on the next vector.

Are there any other methods for text rotation that don't look so bad?
 
Good grief man I'm not a total doof... well maybe 3-quarter doof...

Yeah, I've already eliminated the obvioius... but thanks for trying.

I think the AA only applies to vector-based line renderings. Doesn't seem to have any impact on fonts or images drawn on bitmaps. Appears iffy on filled regions as well...

As it turns out, it looks OK on higher resolutions, 1024x768 is the image above; at 1280x1024 it looks decent.
 
Try Graphics.TextRenderingHint, I think the modes ClearTypeGridFit and AntiAlias looked better after RotateTransform. You want also to check combinations with Graphics.PixelOffsetMode Half/HighQuality, maybe you find one of these aligns better.
 
Try Graphics.TextRenderingHint, I think the modes ClearTypeGridFit and AntiAlias looked better after RotateTransform. You want also to check combinations with Graphics.PixelOffsetMode Half/HighQuality, maybe you find one of these aligns better.


Sorry I didn't get back to you sooner...

I applied the TextRenderingHint with AntiAlias before the transform and it worked beautifully. Excellent suggestion! :D
 
Ya know this is typical for me...

I post a question, "Can someone give me a Text Rendering Hint?"

...and what does John come back with?

You should try TextRenderingHint.

:D

I know, it doesn't really mean Hint... but the irony made me laugh outloud.
 
Yeah, the word 'hint' in a property makes you wonder what goes on behind the scenes there... vague science :)
 
Back
Top