1

Documentation for IDWriteTextFormat1::SetLastLineWrapping() is insufficient:

Sets the wrapping mode of the last line. If [the single BOOL parameter is] set to FALSE, the last line is not wrapped. If set to TRUE, the last line is wrapped.

For IDWriteTextLayout2::SetLastLineWrapping() it is equally terse:

Set whether or not the last word on the last line is wrapped.

Some details lacking that I want to know:

  • Which one is the last line? In my tests, sometimes it is the last visible line that gets the extra word, but sometimes it is the next one, and then more lines follow. (Is it a bug in DirectWrite? In my code?) Here "visible" means (for horizontal lines, in the vertical direction) completely inside the layout rectangle.
  • How does it interact with IDWriteTextFormat::SetTrimming()? Some tests suggest that behaviour is different when trimming is set. (With SetTrimming(&DWRITE_TRIMMING{DWRITE_TRIMMING_GRANULARITY_CHARACTER,0,0}, nullptr);.)
Pablo H
  • 609
  • 4
  • 22

1 Answers1

0

It was intended for rectangular tiles where the last word of the application name would otherwise be hidden because it got wrapped to the next line. By default, this would yield:

"here is an example of a long application name" ->

<----------->.
here is an  /|\
example of a |
long        \|/
application
name

So if the tile height was short (say only 3 lines), then only none of the word "application" would be visible, but it's more useful to also show at least part of the next word.

<----------->.
here is an  /|\
example of a |
long applica\|/
name

In conjunction with ellipsis character trimming, it looks like:

enter image description here

It always means the last visible line whether trimming is enabled or not, but when trimming is enabled, any partial lines are trimmed out, making the last "visible" the last untrimmed line. So that's the difference you're seeing.

Dwayne Robinson
  • 2,034
  • 1
  • 24
  • 39