What are the coordinates of a character origin in GDI with font with not trivial orientation?

Zhivko-2008 20 Reputation points

This question is about the internals of GDI font renderer.

I am converting from GDI (Win32 API) into different drawing format and both formats support character/glyph rotation. I need to calculate the origin of the glyph when the selected font is with orientation different from 90, 180 etc. in order to match the output of ExtTextOut() and related. (The output with degrees 90, 180 etc. does not match the other angles in GDI, this question is not about the trivial cases).

Unfortunately, in GDI font orientation is not a simple rotation, there is some horizontal offset, which likely depends on the glyph size (ink box, not character cell). The GetGlyphOutline() API can be used to get the metrics even for rotated glyphs but does not help with the coordinates of the origin for a given reference point. Other similar APIs ignore font orientation.

Also, if you know a better place to ask this question, please let me know.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,485 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,351 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    GLYPHMETRICS structure contains information about the placement and orientation of a glyph in a character cell.

    gmCellIncX:The horizontal distance from the origin of the current character cell to the origin of the next character cell.

    gmCellIncY:The vertical distance from the origin of the current character cell to the origin of the next character cell.

    You could try to use GetGlyphOutlineA function retrieves the outline or bitmap for a character.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.