summaryrefslogtreecommitdiff
path: root/src/render/decorations/CHyprGroupBarDecoration.cpp
diff options
context:
space:
mode:
authorgiskard <rtgiskard@gmail.com>2024-05-22 16:09:36 +0800
committerGitHub <noreply@github.com>2024-05-22 10:09:36 +0200
commit93fea890433ec11d7a915f5e0466b2e8b513e895 (patch)
treecee3c8acde01dd29c45d4184917f3596622edeac /src/render/decorations/CHyprGroupBarDecoration.cpp
parente419ef1873de01b0762f7f1a411994170a4d8cab (diff)
renderer: render fonts with pango, add global `font_family` config option (#6138)
Diffstat (limited to 'src/render/decorations/CHyprGroupBarDecoration.cpp')
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 318999ed..04f69aaa 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -209,11 +209,13 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bufferSize.x, bufferSize.y);
const auto CAIRO = cairo_create(CAIROSURFACE);
+ static auto FALLBACKFONT = CConfigValue<std::string>("misc:font_family");
static auto PTITLEFONTFAMILY = CConfigValue<std::string>("group:groupbar:font_family");
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
static auto PTEXTCOLOR = CConfigValue<Hyprlang::INT>("group:groupbar:text_color");
- const CColor COLOR = CColor(*PTEXTCOLOR);
+ const CColor COLOR = CColor(*PTEXTCOLOR);
+ const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT;
// clear the pixmap
cairo_save(CAIRO);
@@ -225,7 +227,8 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
PangoLayout* layout = pango_cairo_create_layout(CAIRO);
pango_layout_set_text(layout, szContent.c_str(), -1);
- PangoFontDescription* fontDesc = pango_font_description_from_string((*PTITLEFONTFAMILY).c_str());
+ PangoFontDescription* fontDesc = pango_font_description_new();
+ pango_font_description_set_family_static(fontDesc, FONTFAMILY.c_str());
pango_font_description_set_size(fontDesc, *PTITLEFONTSIZE * PANGO_SCALE * monitorScale);
pango_layout_set_font_description(layout, fontDesc);
pango_font_description_free(fontDesc);