Search code examples
textgraphicsdirectxdirect2ddirectwrite

How do I get height of DirectWrite layout?


I am aware that I can call IDWriteTextLayout::GetMetrics, but this gives me the boundaries of the text including space above and below the text for the ascender and descender, etc. However, what I'm looking for is the exact amount of space that the text actually takes up. How would I obtain or calculate this bounding box?


Solution

  • You should use GetMetrics() together with GetOverhangMetrics(), subtracting overhang metrics from layout metrics will give you ink rectangle.