Ok was playing a bit with DrawString on sunday trying to get string alignments 
to work. I've got horizontal alignments working by simply setting 
drawcoord.right which currently is left uninitialized and then passing 
DT_CENTER and DT_RIGHT as needed to DrawTextW.

So far, that worked.

However, I can't do that for vertical alignments because the code manually does 
the line breaking and therefore draws each line individually.

So my question is, why? Why aren't we letting DrawTextW do the line breaking 
and just letting it draw with the appropriate rect? Is the linebreaking 
different? Or does DrawTextW not have the proper support for rotations?

As it stands right now, if necessary, I can easily enough calculate the offsets 
myself for doing horizontal alignments instead of using DT_CENTER and DT_RIGHT.

But for vertical, this is a bit problematic. I don't know how many lines of 
text there are going to be until the text has already been drawn. Kind of a 
prerequisite for vertical alignment however.

That means that if I just want to brute force it, I'd have to duplicate the 
drawing loop and once only have it measure the string / count lines. That then 
allows me to calculate the proper offset and I could then just rerun the thing 
again with the new position and it'd work. A bit more better solution would be 
to store the line break info in a small array (indices into the string should 
do that tell me where each line ends) to simply the drawing loop. That would 
require a dynamic array though which brings me to another question, what should 
I use? is stuff like std::vector ok or should I use something else?

If of course there's a way we can just have DrawTextW handle the line breaking, 
I don't even need to care about any of the above. Can then just calculate the 
proper bounding rect and hand all the issues off to DrawTextW.

Thoughts?

Thanks,

Stephan


Reply via email to