The patch add-font-option adds an --font option to be able to specify a
[darcs-mirror-screen-message.debian.git] / sm.c
diff --git a/sm.c b/sm.c
index 32e4b3f..a25cb2b 100644 (file)
--- a/sm.c
+++ b/sm.c
@@ -48,6 +48,7 @@ static PangoFontDescription *font;
 static PangoLayout* layout;
 static char *foreground = NULL;
 static char *background = NULL;
+static char *fontdesc = NULL;
 
 static void realize(GtkWindow *window, GdkScreen *screen, gpointer data) {
        gdk_window_set_cursor(draw->window, cursor);
@@ -139,11 +140,12 @@ static struct option const long_options[] =
        {"version",    no_argument,       NULL, 'V'},
        {"foreground", required_argument, NULL, 'f'},
        {"background", required_argument, NULL, 'b'},
+       {"font",       required_argument, NULL, 'n'},
        {0,0,0,0}
 };
 
 static void usage(char *cmd) {
-       printf("Usage: %s [-h|--help] [-V|--version] [-f|--foreground=330033] [-b|--background=ccffcc]\n", cmd);
+       printf("Usage: %s [-h|--help] [-V|--version] [-f|--foreground=colordesc] [-b|--background=colordesc] [-n|--font=fontdesc]\n", cmd);
 }
 
 static void version() {
@@ -174,6 +176,10 @@ int main(int argc, char **argv) {
                                background = optarg;
                                break;
 
+                       case 'n':
+                               fontdesc = optarg;
+                               break;
+
                        default:
                                /* unknown switch received - at least
                                 * give usage but continue and use the
@@ -279,7 +285,11 @@ int main(int argc, char **argv) {
        gtk_container_add(GTK_CONTAINER(window), vbox);
 
        font = pango_font_description_new();
-        pango_font_description_set_family(font, "sans-serif");
+       if (fontdesc != NULL) {
+               pango_font_description_set_family(font, fontdesc);
+       } else {
+               pango_font_description_set_family(font, "sans-serif");
+       }
        pango_font_description_set_size(font, 20*PANGO_SCALE);
 
        layout=  gtk_widget_create_pango_layout(draw,get_text());