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

Code before:
		ur->add_undo_method(edited_control, "add_theme_constant_override", "outline_size", edited_control->get_theme_constant("outline_size"));
	} else {
		ur->add_undo_method(edited_control, "remove_theme_constant_override", "outline_size");
	}

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

	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();

Review comment (suggestion):
Same here:
```suggestion
		StringName edited_font;
		if (Object::cast_to<RichTextLabel>(edited_control)) {
			edited_font = SNAME("normal_font");
		} else {
			edited_font = SNAME("font");
```

Code after:

void TextControlEditor::_font_selected(int p_id) {
	_set_font();
}

void TextControlEditor::_font_style_selected(int p_id) {
	_set_font();
}

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);
				}
			}