From d5716d8956425475f0162338a3400fe873de9121 Mon Sep 17 00:00:00 2001
From: Hugo Locurcio <hugo.locurcio@hugo.pro>
Date: Sat, 6 Feb 2021 19:24:05 +0100
Subject: [PATCH] Improve editor text appearance in (un)zoomed GraphEdit-based
 editors

Enabling filtering and mipmaps on the editor fonts makes the text
look slightly better. While not as good as SDF-based fonts, it should be
more usable already.
This change impacts the visual script and visual shader editors.

This partially addresses #16220.
---
 editor/editor_fonts.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 3ab05458006..39a825ea73c 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -45,11 +45,18 @@
 	m_name->add_fallback(FontJapanese); \
 	m_name->add_fallback(FontFallback);
 
+// Enable filtering and mipmaps on the editor fonts to improve text appearance
+// in editors that are zoomed in/out without having dedicated fonts to generate.
+// This is the case in GraphEdit-based editors such as the visual script and
+// visual shader editors.
+
 // the custom spacings might only work with Noto Sans
 #define MAKE_DEFAULT_FONT(m_name, m_size)                       \
 	Ref<DynamicFont> m_name;                                    \
 	m_name.instance();                                          \
 	m_name->set_size(m_size);                                   \
+	m_name->set_use_filter(true);                               \
+	m_name->set_use_mipmaps(true);                              \
 	if (CustomFont.is_valid()) {                                \
 		m_name->set_font_data(CustomFont);                      \
 		m_name->add_fallback(DefaultFont);                      \
@@ -64,6 +71,8 @@
 	Ref<DynamicFont> m_name;                                    \
 	m_name.instance();                                          \
 	m_name->set_size(m_size);                                   \
+	m_name->set_use_filter(true);                               \
+	m_name->set_use_mipmaps(true);                              \
 	if (CustomFontBold.is_valid()) {                            \
 		m_name->set_font_data(CustomFontBold);                  \
 		m_name->add_fallback(DefaultFontBold);                  \
@@ -78,6 +87,8 @@
 	Ref<DynamicFont> m_name;                                    \
 	m_name.instance();                                          \
 	m_name->set_size(m_size);                                   \
+	m_name->set_use_filter(true);                               \
+	m_name->set_use_mipmaps(true);                              \
 	if (CustomFontSource.is_valid()) {                          \
 		m_name->set_font_data(CustomFontSource);                \
 		m_name->add_fallback(dfmono);                           \