Direct2D widthIncludingTrailingWhitespace == 0 while width > 0?

93 Views Asked by At

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.

1

There are 1 best solutions below

0
Viktor Be On

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.