aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2022-06-27 09:41:31 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2022-06-27 09:41:35 +0200
commitb49b1c1a6595a00d93e9e904d6723034b6f12530 (patch)
tree4229c816e50f87291339405a82e10cd8f31a4606
parentaa7bb9a1447f65df2dc9c0f20cc21bee0d142763 (diff)
downloadarctica-greeter-b49b1c1a6595a00d93e9e904d6723034b6f12530.tar.gz
arctica-greeter-b49b1c1a6595a00d93e9e904d6723034b6f12530.tar.bz2
arctica-greeter-b49b1c1a6595a00d93e9e904d6723034b6f12530.zip
src/prompt-box.vala: Use regular expression to split KEY_FONT_NAME into font_family and font_size.
This now also supports font family names containing blanks. Fixes: https://github.com/ArcticaProject/arctica-greeter/issues/34
-rw-r--r--src/prompt-box.vala15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/prompt-box.vala b/src/prompt-box.vala
index 43e6cf4..1a0007f 100644
--- a/src/prompt-box.vala
+++ b/src/prompt-box.vala
@@ -28,9 +28,8 @@ public class PromptBox : FadableBox
public signal void name_clicked ();
public static string font = AGSettings.get_string (AGSettings.KEY_FONT_NAME);
- public static string font_family = font.split_set(" ")[0];
- public static int font_size = int.parse(font.split_set(" ")[1]);
-
+ public static string font_family = "sans";
+ public static int font_size = 11;
public bool has_errors { get; set; default = false; }
public string id { get; construct; }
@@ -175,6 +174,16 @@ public class PromptBox : FadableBox
fixed.add (small_box_widget);
fixed.add (box_grid);
+
+ /* Split font family and size via regular expression. */
+ Regex font_regexp = new Regex ("^([[:blank:]]*)(?<font_family>[ a-zA-Z0-9]+) (?<font_size>[0-9]+)([[:blank:]]*)$");
+ MatchInfo font_info;
+ if (font_regexp.match(font, 0, out font_info)) {
+ font_family = font_info.fetch_named("font_family");
+ font_size = int.parse(font_info.fetch_named("font_size"));
+ }
+ debug ("Using font family '%s'.", font_family);
+ debug ("Using font size base '%d'.", font_size);
}
protected virtual Gtk.Grid create_name_grid ()