Page MenuHome

FONT_OT_text_insert Error In Windows
ClosedPublic

Authored by Harley Acheson (harley) on Sun, Jun 21, 1:44 AM.

Details

Summary

This is a two-line patch, the short description first:

insert_text_exec() dies on the Windows platform for utf8 characters U+0800 and above. This is because wchar_t is 16-bit on Windows, so this patch fixes this by explicit use of char32_t.

Long story:

In insert_text_exec() we are moving utf8 characters to a buffer of char32_t (32-bit) characters, yet doing so with a data type of wchar_t. There is a temporary array of wchar_t and the use of BLI_strncpy_wchar_from_utf8() which returns wchar_t.

Unfortunately wchar_t on Windows is 16-bit, not 32. The result of this is that it breaks if a uft8 character sequence requires more than 2 bytes, which is all those above U+0800, because this is assumed to overflow wchar_t (even if they would not).

This patch just uses an explicit 32-bit character array, char32_t, and uses BLI_str_utf8_as_utf32() which returns 32-bit characters.

Testing notes:

Best way to test this is to insert a text object into the scene and then select Text / Special Characters / Promillage. This character is U+2030 and so will break. Note however that you will have to select a font that can show this character, like either of our regular fonts such as our droidsans or bmonofont. Strangely, the default font for text objects is still the old "bfont.pfb" for some reason.

Diff Detail

Repository
rB Blender