diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-08-09 14:19:03 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-08-09 14:21:09 +0300 |
commit | bf1cc6326a3d9422a880e470a1a3c2950ec1a419 (patch) | |
tree | 43fc951dc5be88fc92ae6df2f723e8297f739899 /modules/text_server_adv | |
parent | c2eaaef1497f8ad557aea9a14e2b3e0582fcfe54 (diff) |
Allow MSDF rendering for system fonts, fix crash on loading damaged / unsupported font files.
Diffstat (limited to 'modules/text_server_adv')
-rw-r--r-- | modules/text_server_adv/text_server_adv.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 73dbf2f443..c0cff08f13 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -1313,12 +1313,14 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontAdvanced *p_f fargs.stream = &fd->stream; int max_index = 0; - FT_Face tmp_face; + FT_Face tmp_face = nullptr; error = FT_Open_Face(ft_library, &fargs, -1, &tmp_face); - if (error == 0) { + if (tmp_face && error == 0) { max_index = tmp_face->num_faces - 1; } - FT_Done_Face(tmp_face); + if (tmp_face) { + FT_Done_Face(tmp_face); + } error = FT_Open_Face(ft_library, &fargs, CLAMP(p_font_data->face_index, 0, max_index), &fd->face); if (error) { |