Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am converting between GDI (Win32 API) and different drawing format that also supports text and glyph rotation. Text output in GDI is specified with a reference point (and vertical alignment), but it is easy to take that into account when the text is not rotated. Different story when the selected font is requested with custom escapement and/or orientation.
When escapement equals orientation, the baseline start point is rotated around the reference point and baseline direction is according to the given angle. Each character is positioned along the baseline. In other words, the whole text is simply rotated on given angle and transitioned to the baseline start point.
But when escapement does not equal orientation, neither the baseline start point nor character widths are that easy.

Does anybody know how GDI rotates text in the non-trivial case?

What I have tried:

Unfortunately, there is no Win32 API or documentation that provides this information, neither could find any other online source. Asking around hasn't helped so far either.
Posted
Comments
[no name] 13-Nov-23 17:48pm    
"Escapement and/or orientation"; i.e. "rotation". You seem to imply these are different properties. IMO they're all the same. There is rotation, translation (offset), skewing and scaling. In your case, you're dealing with rotation and possibly translation.
zhivot 13-Nov-23 18:14pm    
They are actually different. Escapement is the angle for the text baseline, while orientation is the angle for each character (independent of text rotation). E.g. you can use orientation to simulate italic text for font that does not provide it. Or use escapement 90 degrees to output vertical text with normal horizontal characters.
[no name] 13-Nov-23 20:20pm    
Italic is a "font"; not something you "program" other than specifying the font family. You're still talking "rotation"; either a string; or individual characters. Or you're talking "skewing"; still not the same thing.
zhivot 13-Nov-23 21:56pm    
Italic fonts usually have characters that look slightly skewed (on angle). Some font families don't have such fonts, so one can use the "normal" font and request it with not zero orientation to make it look like it is Italic. Hence "simulate", but this is just example how one can use this GDI functionality. I need to handle the general case.
And yes, it is rotation, 2 rotations to be exact, but simply rotating does not match. You can think of it as GDI adding some offsets after rotating when those 2 angles don't align (not parallel or perpendicular to each other). These "adjustments" are changing both the text starting point and character widths (or distance between characters).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900