0

I am using the DirectWrite API and I am implementing my own layout and text rendering engine. I have already created my IDWriteTextLayout object successfully. When I make the following call I receive an Access Violation error and I have no idea why:

DWRITE_LINE_METRICS m_lineMetrics;
UINT32 m_lineCount;

DX::ThrowIfFailed(
   m_textLayout->GetLineMetrics(&m_lineMetrics,31,&m_lineCount)
);
joce
  • 9,624
  • 19
  • 56
  • 74
James Pack
  • 824
  • 1
  • 10
  • 19
  • 1
    You promised that the first argument is a pointer to an array with 31 elements. It is not, you've only got one. Kaboom. – Hans Passant Mar 10 '13 at 23:53
  • That is what I was thinking. The documentation is confusing for it. It says that when the function returns there will be a pointer to an array of DWRITE_LINE_METRICS structures. When I try to pass a pointer to an array with 31 elements it breaks the function signature – James Pack Mar 10 '13 at 23:55
  • How would I pass a pointer to an array with 31 elements without breaking the signature – James Pack Mar 11 '13 at 00:01
  • I figured it out. I was reading the documentation for the function wrong I guess. You can pass either a pointer to a single DWRITE_LINE_METRICS structure or an array of DWRITE_LINE_METRICS structures. I can't answer my own question because I am a newb. – James Pack Mar 11 '13 at 00:14
  • It's a pointer either way. The problem is that array it points to has to be large enough as second argument indicates. – bunglehead May 21 '16 at 09:43

1 Answers1

0

I figured it out. I guess I was interpreting the documentation for the function incorrectly. You can pass either a pointer to a single DWRITE_LINE_METRICS structure or an array of DWRITE_LINE_METRICS structures.

James Pack
  • 824
  • 1
  • 10
  • 19