0

In a sample application DWriteSimpleHelloWorld I render a text

wszText_ = L"Hello World using Direct\u00ADWrite!";

to a DWrite HwndRenderTarget -- effectively, to a window of my application. I render text with a DrawText method of ID2D1HwndRenderTarget. I expect a behavior conformant to a rendering of text strings containing entity ­ (soft or syllable hyphen) in web browsers.

If a window is wide enough to fit the width of the rendered phrase, I see a text like

Hello World using DirectWrite!

But when I resize my window so that the tail of a phrase fails to fit into the window, I see :

Hello World using Direct
Write!

while web browsers would render this text with a hyphen at the end of a first line:

Hello World using Direct-
Write!

My purpose is to let users insert hyphenation hints for long words in my DWrite application, but what I see is as if \u00AD works as a "hidden" whitespace.

I have read of subtleties concerning a soft hyphen definition and usage (for example, https://www.cs.tut.fi/~jkorpela/shy.html), so I humbly ask : is the observed behavior of DWrite "by design"? If so, how one can implement hyphenation hints that would produce hyphens at the end of lines when needed?

Notice that when I use glyph indices of my wszText_ string to draw text as a geometry created with a method GetGlyphRunOutline of IDWriteFontFace, I see a string containing a hyphen in its due position:

Hello World using Direct-Write!
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
V.V.T
  • 231
  • 1
  • 7
  • @Bertrand Martel: thanks for formatting my text. – V.V.T Dec 22 '16 at 03:20
  • I finally tested this myself, and I can confirm, on Windows 8.1 SHY acts as breaking point, but does not produce visible hyphen. I would say, if you need to render them you'll have to implement layout logic yourself. – bunglehead Jan 14 '17 at 23:49

0 Answers0