From 60f069d54015fec66e63f1ff7e6ff26ddb349976 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 4 Jan 2025 00:25:01 +0100 Subject: groupbar: fix missing ellipsize for text fixes #8938 --- src/render/OpenGL.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/render/OpenGL.cpp') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 68baf48e..1b51acbf 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -2555,7 +2555,7 @@ SP CHyprOpenGLImpl::loadAsset(const std::string& filename) { return tex; } -SP CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily) { +SP CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily, int maxWidth) { SP tex = makeShared(); static auto FONT = CConfigValue("misc:font_family"); @@ -2580,6 +2580,12 @@ SP CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col int textW = 0, textH = 0; pango_layout_set_text(layoutText, text.c_str(), -1); + + if (maxWidth > 0) { + pango_layout_set_width(layoutText, maxWidth * PANGO_SCALE); + pango_layout_set_ellipsize(layoutText, PANGO_ELLIPSIZE_END); + } + pango_layout_get_size(layoutText, &textW, &textH); textW /= PANGO_SCALE; textH /= PANGO_SCALE; -- cgit v1.2.3