diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-10-28 22:29:59 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-28 22:29:59 -0300 |
commit | 50da616eeb9e3566058983bcb29f36e36a45e9df (patch) | |
tree | 78db1fcd329a1f74a2f84f687fd4a5405a9fdf2c /scene/resources/dynamic_font.cpp | |
parent | 2eaedcf14e515eb589885025b46d0aedc492830a (diff) | |
parent | a65481dd35615a4371ca63a4661742abe182cb23 (diff) |
Merge pull request #43167 from reduz/canvas-group
Implement CanvasGroup and CanvasItem clipping
Diffstat (limited to 'scene/resources/dynamic_font.cpp')
-rw-r--r-- | scene/resources/dynamic_font.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index ad9d888480..d76d364737 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -458,8 +458,21 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp //zero texture uint8_t *w = tex.imgdata.ptrw(); ERR_FAIL_COND_V(texsize * texsize * p_color_size > tex.imgdata.size(), ret); - for (int i = 0; i < texsize * texsize * p_color_size; i++) { - w[i] = 0; + + // Initialize the texture to all-white pixels to prevent artifacts when the + // font is displayed at a non-default scale with filtering enabled. + if (p_color_size == 2) { + for (int i = 0; i < texsize * texsize * p_color_size; i += 2) { + w[i + 0] = 255; + w[i + 1] = 0; + } + } else { + for (int i = 0; i < texsize * texsize * p_color_size; i += 4) { + w[i + 0] = 255; + w[i + 1] = 255; + w[i + 2] = 255; + w[i + 3] = 0; + } } } tex.offsets.resize(texsize); |