0

An issue with Microsoft's Direct2D framework.

How is it possible that width > widthIncludingTrailingWhitespace? Shouldn't it be

width == widthIncludingTrailingWhitespace

in the case of no trailing spaces and

width < widthIncludingTrailingWhitespace.

when the underlying string contains trailing spaces?

In my case the underlying string is " Info ". It has a trailing space in it and still the widthIncludingTrailingWhitespace is zero. See screenshot:

enter image description here

MSDN documentation states:

width

Type: FLOAT

A value that indicates the width of the formatted text, while ignoring trailing whitespace at the end of each line.

widthIncludingTrailingWhitespace

Type: FLOAT

The width of the formatted text, taking into account the trailing whitespace at the end of each line.

bunglehead
  • 1,104
  • 1
  • 14
  • 22
Viktor Be
  • 658
  • 1
  • 11
  • 25
  • 1
    I had the same issue, so I just added a test if widthIncludingTrailingWhitespace < width then widthIncludingTrailingWhitespace = width... Looks like a bug to me, this was I a big program, but IMHO you should report that to Microsoft if you have an easy reproductible test. – Simon Mourier Jun 18 '21 at 14:05

1 Answers1

0

It seems to be a MSDN bug.

The issue occurs only with

IDWriteTextLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING)

In the case of

IDWriteTextLayout->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING)

the widthIncludingTrailingWhitespace is calculated correctly.

Viktor Be
  • 658
  • 1
  • 11
  • 25