You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-30 18:30:54 +00:00
Merge pull request #110310 from bruvzg/check_gl_cache
[TextServer] Check if texture cache is valid when loading glyph.
This commit is contained in:
@@ -1230,8 +1230,22 @@ bool TextServerAdvanced::_ensure_glyph(FontAdvanced *p_font_data, const Vector2i
|
||||
|
||||
HashMap<int32_t, FontGlyph>::Iterator E = fd->glyph_map.find(p_glyph);
|
||||
if (E) {
|
||||
r_glyph = E->value;
|
||||
return E->value.found;
|
||||
bool tx_valid = true;
|
||||
if (E->value.texture_idx >= 0) {
|
||||
if (E->value.texture_idx < fd->textures.size()) {
|
||||
tx_valid = fd->textures[E->value.texture_idx].image.is_valid();
|
||||
} else {
|
||||
tx_valid = false;
|
||||
}
|
||||
}
|
||||
if (tx_valid) {
|
||||
r_glyph = E->value;
|
||||
return E->value.found;
|
||||
#ifdef DEBUG_ENABLED
|
||||
} else {
|
||||
WARN_PRINT(vformat("Invalid texture cache for glyph %x in font %s, glyph will be re-rendered. Re-import this font to regenerate textures.", glyph_index, p_font_data->font_name));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (glyph_index == 0) { // Non graphical or invalid glyph, do not render.
|
||||
|
||||
@@ -651,8 +651,22 @@ bool TextServerFallback::_ensure_glyph(FontFallback *p_font_data, const Vector2i
|
||||
|
||||
HashMap<int32_t, FontGlyph>::Iterator E = fd->glyph_map.find(p_glyph);
|
||||
if (E) {
|
||||
r_glyph = E->value;
|
||||
return E->value.found;
|
||||
bool tx_valid = true;
|
||||
if (E->value.texture_idx >= 0) {
|
||||
if (E->value.texture_idx < fd->textures.size()) {
|
||||
tx_valid = fd->textures[E->value.texture_idx].image.is_valid();
|
||||
} else {
|
||||
tx_valid = false;
|
||||
}
|
||||
}
|
||||
if (tx_valid) {
|
||||
r_glyph = E->value;
|
||||
return E->value.found;
|
||||
#ifdef DEBUG_ENABLED
|
||||
} else {
|
||||
WARN_PRINT(vformat("Invalid texture cache for glyph %x in font %s, glyph will be re-rendered. Re-import this font to regenerate textures.", glyph_index, p_font_data->font_name));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (glyph_index == 0) { // Non graphical or invalid glyph, do not render.
|
||||
|
||||
Reference in New Issue
Block a user