From: Marijn van Vliet Date: Thu, 3 Nov 2011 14:23:42 +0000 (+0100) Subject: fixed get_current_font to actually do something now. X-Git-Tag: v0.9~56 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=6c80b5e4e7b7ba1df1462069b5baef0d1f1fbf54;p=projects%2Fchimara%2Fchimara.git fixed get_current_font to actually do something now. Fixes #35 --- diff --git a/libchimara/style.c b/libchimara/style.c index 125dbd6..f944071 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -1097,22 +1097,44 @@ PangoFontDescription * get_current_font(guint32 wintype) { ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - GtkTextTag *tag; + GHashTable *styles, *glk_styles; + PangoFontDescription *font; switch(wintype) { case wintype_TextGrid: - tag = g_hash_table_lookup(glk_data->styles->text_grid, "default"); - return pango_font_description_from_string("Monospace"); + styles = glk_data->styles->text_grid; + glk_styles = glk_data->glk_styles->text_grid; + font = pango_font_description_from_string("Monospace"); break; case wintype_TextBuffer: - tag = g_hash_table_lookup(glk_data->styles->text_buffer, "default"); - return pango_font_description_from_string("Serif"); + styles = glk_data->styles->text_buffer; + glk_styles = glk_data->glk_styles->text_buffer; + font = pango_font_description_from_string("Serif"); break; default: return NULL; } - PangoFontDescription *font; + PangoAttrList *list = pango_attr_list_new(); + + text_tag_to_attr_list( g_hash_table_lookup(styles, "default"), list ); + PangoAttrIterator *it = pango_attr_list_get_iterator(list); + pango_attr_iterator_get_font(it, font, NULL, NULL); + + text_tag_to_attr_list( g_hash_table_lookup(styles, "normal"), list ); + it = pango_attr_list_get_iterator(list); + pango_attr_iterator_get_font(it, font, NULL, NULL); + + text_tag_to_attr_list( g_hash_table_lookup(glk_styles, "glk-normal"), list ); + it = pango_attr_list_get_iterator(list); + pango_attr_iterator_get_font(it, font, NULL, NULL); + + /* Make a copy of the family, preventing it's destruction at the end of this function. */ + pango_font_description_set_family( font, pango_font_description_get_family(font) ); + + pango_attr_iterator_destroy(it); + pango_attr_list_unref(list); + return font; }