Only save original string in GlyphLayout if needed
This commit is contained in:
parent
5d5292787e
commit
8c3bacf769
@ -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
|
||||
|
@ -469,6 +469,8 @@ s32 CGUIStaticText::getCluster(int x, int y, std::shared_ptr<std::u32string>* ou
|
||||
return -1;
|
||||
|
||||
std::shared_ptr<std::u32string> 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;
|
||||
|
@ -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<std::u32string> orig_string =
|
||||
@ -595,6 +599,7 @@ 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;
|
||||
if (save_orig_string)
|
||||
gl.orig_string = orig_string;
|
||||
cur_line.push_back(gl);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ void NetworkingLobby::addMoreServerInfo(core::stringw info)
|
||||
const float box_height = m_text_bubble->getDimension().Height;
|
||||
std::vector<GlyphLayout> 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());
|
||||
|
Loading…
Reference in New Issue
Block a user