Repository: godotengine/godot
File: editor/inspector/editor_inspector.cpp (C++)

Code before:
			}
			w = MIN(w, get_size().width - sb->get_minimum_size().width);

			int ofs = (get_size().width - w) / 2;

			float v_margin_offset = sb->get_content_margin(SIDE_TOP) - sb->get_content_margin(SIDE_BOTTOM);

			if (icon.is_valid()) {
				Size2 rect_size = Size2(icon_size, icon_size);
				Point2 rect_pos = Point2(ofs, (get_size().height - icon_size) / 2 + v_margin_offset).round();
				if (is_layout_rtl()) {
					rect_pos.x = get_size().width - rect_pos.x - icon_size;
				}
				draw_texture_rect(icon, Rect2(rect_pos, rect_size));

				ofs += hs + icon_size;
				w -= hs + icon_size;
			}

			if (is_layout_rtl()) {
				ofs = get_size().width - ofs - w;
			}
			float font_height = font->get_height(font_size);
			float text_pos_y = get_size().height - (font_height / 2) + v_margin_offset;
			Point2 text_pos = Point2(ofs, text_pos_y).round();
			draw_string(font, text_pos, label, HORIZONTAL_ALIGNMENT_LEFT, w, font_size, theme_cache.font_color);
		} break;
	}
}

void EditorInspectorCategory::_accessibility_action_menu(const Variant &p_data) {
	_popup_context_menu(get_screen_position());
}

Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
	// If it's not a doc tooltip, fallback to the default one.
	if (doc_class_name.is_empty()) {
		return nullptr;
	}

	return EditorHelpBitTooltip::show_tooltip(const_cast<EditorInspectorCategory *>(this), p_text);
}

void EditorInspectorCategory::set_as_favorite() {
	is_favorite = true;
	_update_icon();
}

void EditorInspectorCategory::set_property_info(const PropertyInfo &p_info) {
	info = p_info;


Review comment (performance):
```c++
Ref<TextLine> tl;
tl.instantiate();
tl->add_string(label, font, font_size);
tl->set_width(w);
tl->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT);
float text_pos_y = (get_size().height - tl->get_size().height) / 2 + v_margin_offset;
Point2 text_pos = Point2(ofs, text_pos_y).round();
tl->draw(get_canvas_item(), text_pos, theme_cache.font_color);
```
Using real text metrics should always work, regardless of fonts and system font fallbacks in use.

Code after:
			}
			w = MIN(w, get_size().width - sb->get_minimum_size().width);

			int ofs = (get_size().width - w) / 2;

			float v_margin_offset = sb->get_content_margin(SIDE_TOP) - sb->get_content_margin(SIDE_BOTTOM);

			if (icon.is_valid()) {
				Size2 rect_size = Size2(icon_size, icon_size);
				Point2 rect_pos = Point2(ofs, (get_size().height - icon_size) / 2 + v_margin_offset).round();
				if (is_layout_rtl()) {
					rect_pos.x = get_size().width - rect_pos.x - icon_size;
				}
				draw_texture_rect(icon, Rect2(rect_pos, rect_size));

				ofs += hs + icon_size;
				w -= hs + icon_size;
			}

			if (is_layout_rtl()) {
				ofs = get_size().width - ofs - w;
			}

			// Use TextLine so we have access to accurate font metrics. This way,
			// we can ensure the line is vertically centered regardless of the font used
			// or its size.
			Ref<TextLine> tl;
			tl.instantiate();
			tl->add_string(label, font, font_size);
			tl->set_width(w);
			tl->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT);
			float text_pos_y = (get_size().height - tl->get_size().height) / 2 + v_margin_offset;
			Point2 text_pos = Point2(ofs, text_pos_y).round();
			tl->draw(get_canvas_item(), text_pos, theme_cache.font_color);
		} break;
	}
}

void EditorInspectorCategory::_accessibility_action_menu(const Variant &p_data) {
	_popup_context_menu(get_screen_position());
}

Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
	// If it's not a doc tooltip, fallback to the default one.
	if (doc_class_name.is_empty()) {
		return nullptr;
	}

	return EditorHelpBitTooltip::show_tooltip(const_cast<EditorInspectorCategory *>(this), p_text);
}