Hyprbars: center button text (#291)

This commit is contained in:
elviosak 2025-02-03 16:50:36 -03:00 committed by GitHub
parent 557e7b4e11
commit 6d525bcfea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -238,8 +238,12 @@ void CHyprBar::renderText(SP<CTexture> out, const std::string& text, const CHypr
cairo_set_source_rgba(CAIRO, color.r, color.g, color.b, color.a);
int layoutWidth, layoutHeight;
pango_layout_get_size(layout, &layoutWidth, &layoutHeight);
PangoRectangle ink_rect, logical_rect;
pango_layout_get_extents(layout, &ink_rect, &logical_rect);
const int layoutWidth = ink_rect.width;
const int layoutHeight = logical_rect.height;
const double xOffset = (bufferSize.x / 2.0 - layoutWidth / PANGO_SCALE / 2.0);
const double yOffset = (bufferSize.y / 2.0 - layoutHeight / PANGO_SCALE / 2.0);