diff --git a/lib/irrlicht/include/GlyphLayout.h b/lib/irrlicht/include/GlyphLayout.h index c866ed72a..6f82c948f 100644 --- a/lib/irrlicht/include/GlyphLayout.h +++ b/lib/irrlicht/include/GlyphLayout.h @@ -24,6 +24,7 @@ enum ShapeFlag { SF_DISABLE_CACHE = 1, /* Disable caching glyph layouts. */ SF_DISABLE_URL_HIGHLIGHT = 2, /* Disable URL highlight. */ +SF_ENABLE_CLUSTER_TEST = 4, /* If on getCluster will work on these layouts, which the original string will be stored, it will be turned on too if any URL is found. */ }; enum GlyphLayoutFlag diff --git a/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp b/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp index 9e66f4509..bd2ca7235 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp @@ -469,6 +469,8 @@ s32 CGUIStaticText::getCluster(int x, int y, std::shared_ptr* ou return -1; std::shared_ptr s = m_glyph_layouts[idx].orig_string; + if (!s) + return -1; unsigned cluster = m_glyph_layouts[idx].cluster.front(); if (cluster > s->size()) return -1; diff --git a/src/font/font_manager.cpp b/src/font/font_manager.cpp index a0fa67cf2..284b54af6 100644 --- a/src/font/font_manager.cpp +++ b/src/font/font_manager.cpp @@ -332,6 +332,8 @@ void FontManager::shape(const std::u32string& text, } return 0; }; + + bool save_orig_string = (shape_flag & gui::SF_ENABLE_CLUSTER_TEST) != 0; if ((shape_flag & gui::SF_DISABLE_URL_HIGHLIGHT) == 0) { size_t pos = text.find(U"http://", 0); @@ -376,6 +378,8 @@ void FontManager::shape(const std::u32string& text, pos = text.find(U"https://", pos + 1); } } + if (!http_pos.empty()) + save_orig_string = true; int start = 0; std::shared_ptr orig_string = @@ -595,7 +599,8 @@ void FontManager::shape(const std::u32string& text, gl.flags |= gui::GLF_RTL_CHAR; if (FT_HAS_COLOR(glyphs[idx].ftface)) gl.flags |= gui::GLF_COLORED; - gl.orig_string = orig_string; + if (save_orig_string) + gl.orig_string = orig_string; cur_line.push_back(gl); } // Sort glyphs in logical order diff --git a/src/states_screens/online/networking_lobby.cpp b/src/states_screens/online/networking_lobby.cpp index 9fd3d8c4b..7be8715cd 100644 --- a/src/states_screens/online/networking_lobby.cpp +++ b/src/states_screens/online/networking_lobby.cpp @@ -347,7 +347,7 @@ void NetworkingLobby::addMoreServerInfo(core::stringw info) const float box_height = m_text_bubble->getDimension().Height; std::vector cur_info; font_manager->initGlyphLayouts(info, cur_info, gui::SF_DISABLE_CACHE | - gui::SF_DISABLE_URL_HIGHLIGHT); + gui::SF_DISABLE_URL_HIGHLIGHT | gui::SF_ENABLE_CLUSTER_TEST); gui::IGUIFont* font = GUIEngine::getFont(); gui::breakGlyphLayouts(cur_info, box_width, font->getInverseShaping(), font->getScale());