locked
DirectWrite, get space width.

    Question

  • I am using the IDWriteTextLayout::GetMetrics method to measure words for rendering. However, if I try to measure the width of a space character (the " " string), the GetMetrics returns zero width. What is the reason for this? How can I measure the width of a space then?

    I also tried it with non breaking space but that also returns zero.

    Wednesday, June 13, 2012 9:32 AM

Answers

  • Sorry for the delay.

    It seems that the width of the space character is not included in the "width" field of the DWRITE_TEXT_METRICS struct. But it has a field called  widthIncludingTrailingWhitespace, which includes the width of the space character as well.

    • Marked as answer by MarkVincze Friday, July 6, 2012 10:25 AM
    Friday, July 6, 2012 10:25 AM

All replies

  • Hello,

     

    Would you please provide us the whole codes to reproduce this issue,

     

    You can upload your project to skydriver

    http://skydrive.live.com/

     

    It is not necessary that you send out the whole of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business details from it.

    Did you test this on RP or CP?

     

    Best regards,

    Jesse



    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, June 14, 2012 11:18 AM
  • Sorry for the delay.

    It seems that the width of the space character is not included in the "width" field of the DWRITE_TEXT_METRICS struct. But it has a field called  widthIncludingTrailingWhitespace, which includes the width of the space character as well.

    • Marked as answer by MarkVincze Friday, July 6, 2012 10:25 AM
    Friday, July 6, 2012 10:25 AM