Repository: godotengine/godot
File: editor/plugins/text_control_editor_plugin.cpp (C++)

Code before:
	ur->commit_action();
}

void TextControlEditor::_font_color_changed(const Color &p_color) {
	if (!edited_control) {
		return;
	}

	UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
	ur->create_action(TTR("Set Font Color"), UndoRedo::MERGE_ENDS);

	ur->add_do_method(edited_control, "add_theme_color_override", edited_color, p_color);
	if (edited_control->has_theme_color_override(edited_color)) {
		ur->add_undo_method(edited_control, "add_theme_color_override", edited_color, edited_control->get_theme_color(edited_color));
	} else {
		ur->add_undo_method(edited_control, "remove_theme_color_override", edited_color);
	}

	ur->add_do_method(this, "_update_control");
	ur->add_undo_method(this, "_update_control");

	ur->commit_action();
}

void TextControlEditor::_outline_color_changed(const Color &p_color) {
	if (!edited_control) {
		return;
	}

	UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
	ur->create_action(TTR("Set Font Outline Color"), UndoRedo::MERGE_ENDS);

	ur->add_do_method(edited_control, "add_theme_color_override", "font_outline_color", p_color);
	if (edited_control->has_theme_color_override("font_outline_color")) {
		ur->add_undo_method(edited_control, "add_theme_color_override", "font_outline_color", edited_control->get_theme_color("font_outline_color"));
	} else {
		ur->add_undo_method(edited_control, "remove_theme_color_override", "font_outline_color");
	}

	ur->add_do_method(this, "_update_control");
	ur->add_undo_method(this, "_update_control");

	ur->commit_action();
}

void TextControlEditor::_clear_formatting() {
	if (!edited_control) {
		return;
	}

	UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();

Review comment (suggestion):
```suggestion
			ur->add_do_method(edited_control, SNAME("remove_theme_font_override"), edited_font);
		} else if (font_list->get_selected_id() == FONT_INFO_USER_CUSTOM) {
			// Restore "custom_font".
			ur->add_do_method(edited_control, SNAME("add_theme_font_override"), edited_font, custom_font);
```

Code after:

void TextControlEditor::_set_font() {
	if (edited_controls.is_empty()) {
		return;
	}

	UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
	ur->create_action(TTR("Set Font"));

	int count = edited_controls.size();
	for (int i = 0; i < count; ++i) {
		Control *edited_control = edited_controls[i];

		String edited_font;
		if (edited_control->is_class("RichTextLabel")) {
			edited_font = "normal_font";
		} else {
			edited_font = "font";
		}

		if (font_list->get_selected_id() == FONT_INFO_THEME_DEFAULT) {
			// Remove font override.
			ur->add_do_method(edited_control, "remove_theme_font_override", edited_font);
		} else if (font_list->get_selected_id() == FONT_INFO_USER_CUSTOM) {
			// Restore "custom_font".
			ur->add_do_method(edited_control, "add_theme_font_override", edited_font, custom_font);
		} else {
			// Load new font resource using selected name and style.
			String name = font_list->get_item_text(font_list->get_selected());
			String style = font_style_list->get_item_text(font_style_list->get_selected());
			if (style.is_empty()) {
				style = "Default";
			}

			if (fonts.has(name)) {
				Ref<FontData> fd = ResourceLoader::load(fonts[name][style]);
				if (fd.is_valid()) {
					Ref<Font> font;
					font.instantiate();
					font->add_data(fd);
					ur->add_do_method(edited_control, "add_theme_font_override", edited_font, font);
				}
			}
		}

		if (edited_control->has_theme_font_override(edited_font)) {
			ur->add_undo_method(edited_control, "add_theme_font_override", edited_font, edited_control->get_theme_font(edited_font));
		} else {
			ur->add_undo_method(edited_control, "remove_theme_font_override", edited_font);
		}
	}