+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+ GtkTextTag *tag;
+
+ switch(win->type) {
+ case wintype_TextBuffer:
+ tag = g_hash_table_lookup( glk_data->current_styles->text_buffer, get_tag_name(styl) );
+ if(result)
+ *result = query_tag(tag, win->type, hint);
+ break;
+ case wintype_TextGrid:
+ tag = g_hash_table_lookup( glk_data->current_styles->text_grid, get_tag_name(styl) );
+ if(result)
+ *result = query_tag(tag, win->type, hint);
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Internal function returning the current default font for a window type
+ * This can be used later for size calculations. Only wintype_TextGrid and wintype_TextBuffer are
+ * supported for now */
+PangoFontDescription *
+get_current_font(guint32 wintype)
+{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+ GtkTextTag *normal;
+
+ switch(wintype) {
+ case wintype_TextGrid:
+ normal = g_hash_table_lookup(glk_data->current_styles->text_grid, "normal");
+ break;
+ case wintype_TextBuffer:
+ normal = g_hash_table_lookup(glk_data->current_styles->text_buffer, "normal");
+ break;
+ default:
+ return NULL;
+ }
+
+ PangoFontDescription *font;
+ g_object_get( G_OBJECT(normal), "font-desc", &font, NULL );
+
+ return font;
+}
+
+/* Internal function copying the attributes of a text tag to a pango attribute list */
+static void
+text_tag_to_attr_list(GtkTextTag *tag, PangoAttrList *list)
+{
+ gboolean set;
+ GdkColor *foreground, *background;
+ gchar *string;
+ PangoFontDescription *font_desc;
+ gboolean strikethrough;
+ PangoUnderline underline;
+
+ g_object_get(tag, "foreground-set", &set, "foreground-gdk", &foreground, NULL);
+ if(set) {
+ pango_attr_list_insert(
+ list,
+ pango_attr_foreground_new(foreground->red, foreground->green, foreground->blue)
+ );
+ }
+ g_object_get(tag, "background-set", &set, "background-gdk", &background, NULL);
+ if(set) {
+ pango_attr_list_insert(
+ list,
+ pango_attr_background_new(background->red, background->green, background->blue)
+ );
+ }
+ g_object_get(tag, "language-set", &set, "language", &string, NULL);
+ if(set) {
+ pango_attr_list_insert(
+ list,
+ pango_attr_language_new( pango_language_from_string(string) )
+ );
+ }
+
+ /* Font description updates the following properties simultaniously:
+ * family, style, weight, variant, stretch, size
+ */
+ g_object_get(tag, "font-desc", &font_desc, NULL);
+ pango_attr_list_insert(
+ list,
+ pango_attr_font_desc_new(font_desc)
+ );
+
+ g_object_get(tag, "strikethrough-set", &set, "strikethrough", &strikethrough, NULL);
+ if(set) {
+ pango_attr_list_insert(
+ list,
+ pango_attr_strikethrough_new(strikethrough)
+ );
+ }
+ g_object_get(tag, "underline-set", &set, "underline", &underline, NULL);
+ if(set) {
+ pango_attr_list_insert(
+ list,
+ pango_attr_underline_new(underline)
+ );
+ }