From 4da5377e17b50a9ee65a9a6f0aa81dd402850487 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 5 Mar 2025 01:09:53 +0100 Subject: [PATCH] Fix #135421: BLF Show Most Control Characters as Space Prior versions of Blender showed control characters as spaces, but since we recently made fallback optional they are no longer visible. This is because with fallback we are guaranteed to return a glyph, but without fallback the current font will not have entries for these. This PR just shows them as spaces, just like before. But does not do so for carriage return and line feed. Pull Request: https://projects.blender.org/blender/blender/pulls/135484 --- source/blender/blenfont/intern/blf_glyph.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/blenfont/intern/blf_glyph.cc b/source/blender/blenfont/intern/blf_glyph.cc index 5d60ce830b6..cf7bf82f0f4 100644 --- a/source/blender/blenfont/intern/blf_glyph.cc +++ b/source/blender/blenfont/intern/blf_glyph.cc @@ -1352,8 +1352,13 @@ static FT_GlyphSlot blf_glyph_render(FontBLF *settings_font, GlyphBLF *blf_glyph_ensure(FontBLF *font, GlyphCacheBLF *gc, const uint charcode, uint8_t subpixel) { if (charcode < 32) { - /* Do not render C0 controls (U+0000 - U+001F) characters. #134972 */ - return nullptr; + if (ELEM(charcode, 0x10, 0x13)) { + /* Do not render line feed or carriage return. #134972. */ + return nullptr; + } + /* Other C0 controls (U+0000 - U+001F) can show as space. #135421. */ + /* TODO: Return all but TAB as ".notdef" character when we have our own. */ + return blf_glyph_cache_find_glyph(gc, ' ', 0); } GlyphBLF *g = blf_glyph_cache_find_glyph(gc, charcode, subpixel);