Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/Text.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

/*
* Clutter.Text that automatically changes font-name to the system one
*/
public class Gala.Text : Clutter.Text {
private static GLib.Settings gnome_interface_settings;

static construct {
gnome_interface_settings = new GLib.Settings ("org.gnome.desktop.interface");
}

construct {
set_system_font_name ();
gnome_interface_settings.changed["font-name"].connect (set_system_font_name);
}

private void set_system_font_name () {
var name = gnome_interface_settings.get_string ("font-name").split (" ");
var last_element_index = name.length - 1;

if (int.try_parse (name[last_element_index])) { // if last element is a font-size
name[last_element_index] = "12"; // hardcode size (can be changed later if needed)
} else {
name += "12";
}

font_name = string.joinv (" ", name);
}
}
1 change: 1 addition & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gala_lib_sources = files(
'Plugin.vala',
'RoundedCornersEffect.vala',
'ShadowEffect.vala',
'Text.vala',
'Utils.vala',
'WindowIcon.vala',
'WindowManager.vala',
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/MultitaskingView/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Gala.Tooltip : Clutter.Actor {
(uint8) Drawing.Color.TOOLTIP_TEXT_COLOR.alpha * uint8.MAX,
};

text_actor = new Clutter.Text () {
text_actor = new Gala.Text () {
margin_left = 6,
margin_top = 6,
margin_bottom = 6,
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/WindowSwitcher/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
get_accessible ().accessible_name = _("Window switcher");
container.get_accessible ().accessible_role = LIST;

caption = new Clutter.Text () {
caption = new Gala.Text () {
font_name = CAPTION_FONT_NAME,
ellipsize = END,
line_alignment = CENTER
Expand Down