mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-25 12:09:50 +01:00
parent
2e6e0e9278
commit
60f069d540
3 changed files with 27 additions and 21 deletions
|
@ -2555,7 +2555,7 @@ SP<CTexture> CHyprOpenGLImpl::loadAsset(const std::string& filename) {
|
|||
return tex;
|
||||
}
|
||||
|
||||
SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily) {
|
||||
SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily, int maxWidth) {
|
||||
SP<CTexture> tex = makeShared<CTexture>();
|
||||
|
||||
static auto FONT = CConfigValue<std::string>("misc:font_family");
|
||||
|
@ -2580,6 +2580,12 @@ SP<CTexture> 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;
|
||||
|
|
|
@ -218,7 +218,7 @@ class CHyprOpenGLImpl {
|
|||
void bindBackOnMain();
|
||||
|
||||
SP<CTexture> loadAsset(const std::string& file);
|
||||
SP<CTexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "");
|
||||
SP<CTexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0);
|
||||
|
||||
void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {});
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
|
|||
const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR);
|
||||
const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT;
|
||||
|
||||
tex = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE, false, FONTFAMILY);
|
||||
tex = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE, false, FONTFAMILY, bufferSize.x - 2 /* some padding yk */);
|
||||
|
||||
if (tex)
|
||||
texSize = tex->m_vSize;
|
||||
|
|
Loading…
Reference in a new issue