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

Zhivko-2008 20 Reputation points
2023-10-31T04:07:19.9133333+00:00

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 development | Windows API - Win32
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2023-10-31T07:19:16.5433333+00:00

    Hello,

    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.

    Jeanine


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.