Without doing any actual testing:
The vertical alignment stuff looks right to me.
Horizontal alignment is suspicious. If the world transform rotates the text 90 degrees, DrawTextW can't be getting enough information to center the text. Then again, I'm not sure if rotation works properly with GdipDrawString in general. I'd write a test program for rotated text.
Naw, it should still work normally. I've done aligned & rotated text under windows before with DrawTextW, you still pass the rect like you would if it wasn't rotated and set the alignment flags. The world transform should take care of getting it all rotated to where it is supposed to be with the alignments in the right place.
But I agree with you though, a test with rotated text is needed. If necessary though it isn't a big deal for me to change things to align without using DT_CENTER and DT_RIGHT. I'd want to test with the alignment flags first though as it keeps the code simpler if I can stick with those.
I would probably send this as a series of 2 patches with vertical alignment first.
Ok question then, how do I separate this into two patches? Never done anything with patches like this before so this is a first for me.
In spite Paul Vriens' comments, don't change the formatting of code you're not changing. I guess the existing if's are already inconsistent enough that you can get away with either style (and that might actually be my fault).
Without looking at it, I think it was only two if statements that weren't mine that I modified formatting on. Figured my changes to the function were major enough to where getting those two consistent with everything else wouldn't matter much. Up to you all if you want me to just leave those untouched or get their formatting in line with everything else. Either way's fine by me. =)
Stephan