X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstyle.c;h=f9b231bf40bd4aff4e6a425b096b6578a12f212e;hb=7cbc2c68d146433b1d438d60406ca05e14a523ce;hp=125dbd6d38128c41032eba935b7a34a4c1d25ca7;hpb=973f25409470a04e2c1db8c4e5fc98f22144599a;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/style.c b/libchimara/style.c index 125dbd6..f9b231b 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -1097,22 +1097,46 @@ 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); + pango_attr_iterator_destroy(it); + + 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); + pango_attr_iterator_destroy(it); + + 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); + pango_attr_iterator_destroy(it); + + /* 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_list_unref(list); + return font; }