summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-12-14 17:38:53 +0100
committerYuri Sizov <yuris@humnom.net>2023-12-14 17:38:53 +0100
commitf79f2ef801c5c0b8089c91e70219276b2f65ebe6 (patch)
treea28e9337c611471f86f776fca7b932bff81803e5 /modules
parent9d280f8b1c826b635ea3bff69267cbf7782b5199 (diff)
parent575e1201cb34dcdec6817a7c4ec35e95ce95445c (diff)
downloadredot-engine-f79f2ef801c5c0b8089c91e70219276b2f65ebe6.tar.gz
Merge pull request #86065 from bruvzg/non_vis_no_draw
[TextServer] Do not draw non-visual characters.
Diffstat (limited to 'modules')
-rw-r--r--modules/text_server_adv/text_server_adv.cpp12
-rw-r--r--modules/text_server_fb/text_server_fb.cpp12
2 files changed, 24 insertions, 0 deletions
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index d93aa1fcd8..bcc7bff909 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -3504,6 +3504,9 @@ void TextServerAdvanced::_font_render_glyph(const RID &p_font_rid, const Vector2
}
void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const {
+ if (p_index == 0) {
+ return; // Non visual character, skip.
+ }
FontAdvanced *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
@@ -3541,6 +3544,9 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
if (gl.found) {
+ if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
+ return; // Nothing to draw.
+ }
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
if (gl.texture_idx != -1) {
@@ -3608,6 +3614,9 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
}
void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const {
+ if (p_index == 0) {
+ return; // Non visual character, skip.
+ }
FontAdvanced *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
@@ -3645,6 +3654,9 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
if (gl.found) {
+ if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
+ return; // Nothing to draw.
+ }
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
if (gl.texture_idx != -1) {
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 9f21642a17..8fc7694aa4 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -2439,6 +2439,9 @@ void TextServerFallback::_font_render_glyph(const RID &p_font_rid, const Vector2
}
void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const {
+ if (p_index == 0) {
+ return; // Non visual character, skip.
+ }
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
@@ -2476,6 +2479,9 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
if (gl.found) {
+ if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
+ return; // Nothing to draw.
+ }
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
if (gl.texture_idx != -1) {
@@ -2543,6 +2549,9 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
}
void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const {
+ if (p_index == 0) {
+ return; // Non visual character, skip.
+ }
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
@@ -2580,6 +2589,9 @@ void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const R
const FontGlyph &gl = fd->cache[size]->glyph_map[index];
if (gl.found) {
+ if (gl.uv_rect.size.x <= 2 || gl.uv_rect.size.y <= 2) {
+ return; // Nothing to draw.
+ }
ERR_FAIL_COND(gl.texture_idx < -1 || gl.texture_idx >= fd->cache[size]->textures.size());
if (gl.texture_idx != -1) {