Skip to content
Merged
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: LGPL-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
4 changes: 2 additions & 2 deletions src/Widgets/MultitaskingView/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Gala.Tooltip : Clutter.Actor {
/**
* Actor to display the Tooltip text.
*/
private Clutter.Text text_actor;
private Gala.Text text_actor;

construct {
#if HAS_MUTTER47
Expand All @@ -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
6 changes: 2 additions & 4 deletions src/Widgets/WindowSwitcher/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
public const int WRAPPER_PADDING = 12;

private const string CAPTION_FONT_NAME = "Inter";
private const int MIN_OFFSET = 64;
private const double GESTURE_STEP = 0.1;

Expand All @@ -24,7 +23,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
private Gala.ModalProxy modal_proxy = null;
private Drawing.StyleManager style_manager;
private Clutter.Actor container;
private Clutter.Text caption;
private Gala.Text caption;
private ShadowEffect shadow_effect;
private BackgroundBlurEffect blur_effect;

Expand Down Expand Up @@ -81,8 +80,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
get_accessible ().accessible_name = _("Window switcher");
container.get_accessible ().accessible_role = LIST;

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