How to get text width and height in DirectWrite/Direct2D

thebluetropics 1,046 Reputation points
2022-09-16T07:58:44.353+00:00

I need an approach to get the text width and height (like getBoundingClientRect() in DOM) in DirectWrite/Direct2D.

I know IDWriteTextLayout::GetMetrics() but, the width and height seems doesn't right. Is there built-in helper method to achieve this in DirectWrite?

Windows development Windows API - Win32
Developer technologies C++
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2022-09-16T08:16:31.467+00:00

    GetMetrics normally works.
    I had adapted MS code for more precise calculations with GetOverhangMetrics in
    CScrollingText.cpp
    (inside OnPaintProc)


0 additional answers

Sort by: Most helpful

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.