From 1cb37fad68dff5f5840010c314fed5809b4ee66f Mon Sep 17 00:00:00 2001 From: Justin Dickey Date: Tue, 19 May 2026 12:46:45 -0400 Subject: [PATCH] hyprbars: add bar_text_weight config option (#669) Hyprland's renderText() accepts a Pango weight parameter, but hyprbars never passed one, so titles always rendered at weight 400. The font family alone cannot disambiguate weight for variable fonts (e.g. Adwaita Sans) where every weight shares the same family name and pango_font_description_set_family_static() ignores style tokens in the family string. Add a bar_text_weight config (default 400 = Regular) and plumb it through to renderText(). --- hyprbars/README.md | 1 + hyprbars/barDeco.cpp | 3 ++- hyprbars/globals.hpp | 16 +++++++++------- hyprbars/main.cpp | 2 ++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hyprbars/README.md b/hyprbars/README.md index 7224107..d23b005 100644 --- a/hyprbars/README.md +++ b/hyprbars/README.md @@ -34,6 +34,7 @@ plugin { `col.text` | color | bar's title text color `bar_title_enabled` | bool | whether to render the title | `true` `bar_text_size` | int | bar's title text font size | `10` +`bar_text_weight` | font weight | bar's title text weight. Named (`thin`, `light`, `normal`, `medium`, `semibold`, `bold`, `ultrabold`, `heavy`, ...) or integer 100-1000 | `400` `bar_text_font` | str | bar's title text font | `Sans` `bar_text_align` | left, center | bar's title text alignment | `center` `bar_buttons_alignment` | right, left | bar's buttons alignment | `right` diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index 257c4c9..895f7e8 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -286,6 +286,7 @@ bool CHyprBar::doButtonPress(Config::INTEGER barPadding, Config::INTEGER barButt void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) { const auto COLORVAL = g_pGlobalState->config.textColor->value(); const auto SIZE = g_pGlobalState->config.barTextSize->value(); + const auto WEIGHT = g_pGlobalState->config.barTextWeight->value(); const auto FONT = g_pGlobalState->config.barTextFont->value(); const auto ALIGN = g_pGlobalState->config.barTextAlign->value(); const auto BARPADDING = g_pGlobalState->config.barPadding->value(); @@ -308,7 +309,7 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) { } const CHyprColor COLOR = m_bForcedTitleColor.value_or(configColor(COLORVAL)); - m_pTextTex = g_pHyprRenderer->renderText(m_szLastTitle, COLOR, scaledSize, false, FONT, maxWidth); + m_pTextTex = g_pHyprRenderer->renderText(m_szLastTitle, COLOR, scaledSize, false, FONT, maxWidth, WEIGHT.m_value); } size_t CHyprBar::getVisibleButtonCount(Config::INTEGER barButtonPadding, Config::INTEGER barPadding, const Vector2D& bufferSize, const float scale) { diff --git a/hyprbars/globals.hpp b/hyprbars/globals.hpp index 9a44e9f..0ef19ae 100644 --- a/hyprbars/globals.hpp +++ b/hyprbars/globals.hpp @@ -6,6 +6,7 @@ #include #include #include +#include inline HANDLE PHANDLE = nullptr; @@ -29,13 +30,14 @@ struct SGlobalState { uint32_t titleColorRuleIdx = 0; struct { - SP barColor, textColor, inactiveButtonColor; - SP barHeight; - SP barTextSize; - SP barPadding; - SP barButtonPadding; - SP barBlur, barTitleEnabled, barPartOfWindow, barPrecedenceOverBorder, enabled, iconOnHover; - SP barTextFont, barTextAlign, barButtonsAlignment, onDoubleClick; + SP barColor, textColor, inactiveButtonColor; + SP barHeight; + SP barTextSize; + SP barTextWeight; + SP barPadding; + SP barButtonPadding; + SP barBlur, barTitleEnabled, barPartOfWindow, barPrecedenceOverBorder, enabled, iconOnHover; + SP barTextFont, barTextAlign, barButtonsAlignment, onDoubleClick; } config; }; diff --git a/hyprbars/main.cpp b/hyprbars/main.cpp index a49de79..a7be701 100644 --- a/hyprbars/main.cpp +++ b/hyprbars/main.cpp @@ -215,6 +215,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { "plugin:hyprbars:inactive_button_color", "Change the inactive button's color. 0x00000000 means unset", 0x00000000); g_pGlobalState->config.barHeight = makeShared("plugin:hyprbars:bar_height", "Change the bar's height", 15); g_pGlobalState->config.barTextSize = makeShared("plugin:hyprbars:bar_text_size", "Change the bar's text size", 10); + g_pGlobalState->config.barTextWeight = makeShared("plugin:hyprbars:bar_text_weight", "Bar's title text weight (e.g. \"bold\" or an integer 100-1000)", 400); g_pGlobalState->config.barTitleEnabled = makeShared("plugin:hyprbars:bar_title_enabled", "Whether to enable titles in the bar", true); g_pGlobalState->config.barBlur = makeShared("plugin:hyprbars:bar_blur", "Whether to enable blur of the bar", false); g_pGlobalState->config.barTextFont = makeShared("plugin:hyprbars:bar_text_font", "Bar's text font", "Sans"); @@ -235,6 +236,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.inactiveButtonColor); HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.barHeight); HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.barTextSize); + HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.barTextWeight); HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.barTitleEnabled); HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.barBlur); HyprlandAPI::addConfigValueV2(PHANDLE, g_pGlobalState->config.barTextFont);