imgui-java icon indicating copy to clipboard operation
imgui-java copied to clipboard

Results of getGlyphRangesChinese*() are cut-off

Open MontyHimself opened this issue 4 years ago • 0 comments

The glyph range arrays provided by the functions ImFontAtlas.getGlyphRangesChineseFull() and ImFontAtlas.getGlyphRangesChineseSimplifiedCommond() are cut-off after the first 4 ranges.

For example, with getGlyphRangesChineseFull() it is supposed to be this array (see here):

0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x2000, 0x206F, // General Punctuation
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
0x31F0, 0x31FF, // Katakana Phonetic Extensions
0xFF00, 0xFFEF, // Half-width characters
0xFFFD, 0xFFFD, // Invalid
0x4e00, 0x9FAF, // CJK Ideograms

The result from the method returns just the first four ranges, though:

0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x2000, 0x206F, // General Punctuation
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
0x31F0, 0x31FF, // Katakana Phonetic Extensions

Note that all but one of the missing values are too large for a Java short (e.g. 0xFF00). I don't know what exactly happens during a JNI call, but it looks to me like the data is cut-off because it doesn't fit into the signed short data type. If that is true, one solution would be to use a char instead of a short here, considering it is unsigned and could represent all the relevant glyph ranges necessary (the ImWchar16 used in C++ dear imgui is also an unsigned 16 bit data type).

MontyHimself avatar Jul 27 '21 10:07 MontyHimself