fix(win32 gui): avoid a panic on invalid utf-8
This commit is contained in:
parent
27f256a7c5
commit
9cc5c9711b
1 changed files with 4 additions and 1 deletions
|
@ -359,7 +359,10 @@ fn generateGlyph(
|
||||||
grapheme_utf8: []const u8,
|
grapheme_utf8: []const u8,
|
||||||
texture: *win32.ID3D11Texture2D,
|
texture: *win32.ID3D11Texture2D,
|
||||||
) u32 {
|
) u32 {
|
||||||
const codepoint = std.unicode.wtf8Decode(grapheme_utf8) catch std.unicode.replacement_character;
|
const codepoint = if (std.unicode.utf8ValidateSlice(grapheme_utf8))
|
||||||
|
std.unicode.wtf8Decode(grapheme_utf8) catch std.unicode.replacement_character
|
||||||
|
else
|
||||||
|
std.unicode.replacement_character;
|
||||||
switch (glyph_index_cache.reserve(
|
switch (glyph_index_cache.reserve(
|
||||||
global.glyph_cache_arena.allocator(),
|
global.glyph_cache_arena.allocator(),
|
||||||
codepoint,
|
codepoint,
|
||||||
|
|
Loading…
Add table
Reference in a new issue