Define bold, italics and mono fonts in editor log for print_rich()

This is also used by the number indicator for message grouping,
as it uses a bold font.

Mono font does not actually turn proportional fonts into monospace.
Instead, it's a more faint version of the regular font, intended
to emulate the look of the "faint" ANSI escape code (and make `[code]`
distinguishable from regular text).

The custom code font will be used to generate the bold/italic/mono
variants if specified in the Editor Settings.
This commit is contained in:
Hugo Locurcio
2022-07-09 19:16:48 +02:00
parent d26442e709
commit 3e7bcc4755
2 changed files with 42 additions and 5 deletions

View File

@ -62,19 +62,34 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f
}
void EditorLog::_update_theme() {
Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts"));
const Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts"));
if (normal_font.is_valid()) {
log->add_theme_font_override("normal_font", normal_font);
}
log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts")));
log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
const Ref<Font> bold_font = get_theme_font(SNAME("output_source_bold"), SNAME("EditorFonts"));
if (bold_font.is_valid()) {
log->add_theme_font_override("bold_font", bold_font);
}
const Ref<Font> italics_font = get_theme_font(SNAME("output_source_italic"), SNAME("EditorFonts"));
if (italics_font.is_valid()) {
log->add_theme_font_override("italics_font", italics_font);
}
const Ref<Font> bold_italics_font = get_theme_font(SNAME("output_source_bold_italic"), SNAME("EditorFonts"));
if (bold_italics_font.is_valid()) {
log->add_theme_font_override("bold_italics_font", bold_italics_font);
}
const Ref<Font> mono_font = get_theme_font(SNAME("output_source_mono"), SNAME("EditorFonts"));
if (mono_font.is_valid()) {
log->add_theme_font_override("mono_font", mono_font);
}
log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts")));
log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons")));
type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")));
type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")));