Search code examples
c++cwinapigdiwin32gui

What is the effect of the DT_NOFULLWIDTHCHARBREAK when calling DrawText?


The MSDN documentation for DrawText isn't particularly clear regarding the DT_NOFULLWIDTHCHARBREAK flag.

Does it still allow DT_WORDBREAK to work with non CJK languages? How does it break CJK languages? If I understand correctly, those languages don't use whitespace like English for example. Does DT_NOFULLWIDTHCHARBREAK have special rules to recognize CJK words or will it break in the middle of a Katakana word?


Solution

  • The docs say what it does, though it uses old terminology. "Prevents a line break at a DBCS (double-wide character string), so that the line-breaking rule is equivalent to SBCS strings." DBCS is old terminology carried over from the code page days. You can think of it as meaning "full width characters". Examples of full width characters are CJK unified ideographs, hiragana, katakana, and Hangul characters.

    By default, full-width characters are considered valid word break points. Use DT_NOFULLWIDTHCHARBREAK to disable this behavior.

    In other words:

    • DT_WORDBREAK not set: No word breaking occurs.
    • DT_WORDBREAK is set, but DT_NOFULLWIDTHCHARBREAK is not set: Word breaks are made at whitespace and at full-width characters.
    • DT_WORDBREAK and DT_NOFULLWIDTHCHARBREAK both set: Word breaks are made only at whitespace.

    The code does not do any linguistic analysis to recognize where katakana words begin and end.