X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=src%2Fwindow.c;h=d27e04ddda5f8c9f9b6eabc3bb5b15c097d819ab;hb=94d7ec6174c7240bd4c5994d9ee241b0dac922e5;hp=364cc140c7d69d696e6ea0b200b4d697f0b1eb6e;hpb=f4dde3bc7531f005ea8589ed0df7d2c75a156a71;p=projects%2Fchimara%2Fchimara.git diff --git a/src/window.c b/src/window.c index 364cc14..d27e04d 100644 --- a/src/window.c +++ b/src/window.c @@ -140,15 +140,6 @@ glk_window_get_root() return (winid_t)glk_data->root_window->data; } -/* Determine the size of a "0" character in pixels */ -static void -text_window_get_char_size(GtkWidget *textview, int *width, int *height) -{ - PangoLayout *zero = gtk_widget_create_pango_layout(textview, "0"); - pango_layout_get_pixel_size(zero, width, height); - g_object_unref(zero); -} - /** * glk_window_open: * @split: The window to split to create the new window. Must be 0 if there @@ -385,14 +376,16 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, gtk_widget_show_all(scrolledwindow); /* Set the window's font */ - /* TODO: Use Pango to pick out a monospace font on the system */ - PangoFontDescription *font = pango_font_description_from_string("Monospace"); - gtk_widget_modify_font(textview, font); - pango_font_description_free(font); + gtk_widget_modify_font(textview, glk_data->monospace_font_desc); win->widget = textview; win->frame = scrolledwindow; - text_window_get_char_size( textview, &(win->unit_width), &(win->unit_height) ); + + /* Determine the size of a "0" character in pixels */ + PangoLayout *zero = gtk_widget_create_pango_layout(textview, "0"); + pango_layout_set_font_description(zero, glk_data->monospace_font_desc); + pango_layout_get_pixel_size(zero, &(win->unit_width), &(win->unit_height)); + g_object_unref(zero); /* Set the other parameters (width and height are set later) */ win->window_stream = window_stream_new(win); @@ -419,9 +412,17 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, gtk_container_add( GTK_CONTAINER(scrolledwindow), textview ); gtk_widget_show_all(scrolledwindow); + /* Set the window's font */ + gtk_widget_modify_font(textview, glk_data->default_font_desc); + win->widget = textview; win->frame = scrolledwindow; - text_window_get_char_size( textview, &(win->unit_width), &(win->unit_height) ); + + /* Determine the size of a "0" character in pixels */ + PangoLayout *zero = gtk_widget_create_pango_layout(textview, "0"); + pango_layout_set_font_description(zero, glk_data->default_font_desc); + pango_layout_get_pixel_size(zero, &(win->unit_width), &(win->unit_height)); + g_object_unref(zero); /* Set the other parameters */ win->window_stream = window_stream_new(win);