static gboolean filter_func (PangoAttribute *attribute, G_GNUC_UNUSED gpointer data) { PangoAttrType type = attribute->klass->type; return (type == go_pango_attr_superscript_get_attr_type () || type == go_pango_attr_subscript_get_attr_type ()); }
/** * go_pango_attr_superscript_new: (skip) * @val: %TRUE if the characters must be raised. * * Returns: (transfer full): a superscript attribute. **/ PangoAttribute * go_pango_attr_superscript_new (gboolean val) { GOPangoAttrSuperscript *result; static PangoAttrClass klass = { 0, go_pango_attr_superscript_copy, go_pango_attr_destroy, go_pango_attr_superscript_compare }; if (!klass.type) klass.type = go_pango_attr_superscript_get_attr_type (); result = g_new (GOPangoAttrSuperscript, 1); result->attr.klass = &klass; result->val = val; return (PangoAttribute *) result; }
PangoAttrType go_pango_attr_superscript_get_type (void) { return go_pango_attr_superscript_get_attr_type (); }
static void go_pango_translate_here (PangoAttrIterator *state_iter, PangoAttrIterator *attr_iter, PangoAttrList *attrs) { double font_scale = 1.; double scale = 1.; int rise = 0; PangoAttribute *pa; PangoFontDescription *desc = pango_font_description_new (); GSList *the_attrs, *l; gint range_start, range_end; pango_attr_iterator_range (attr_iter, &range_start, &range_end); if (range_start == range_end) return; desc = pango_font_description_new (); pango_attr_iterator_get_font (state_iter, desc, NULL, NULL); font_scale = pango_font_description_get_size (desc)/ (double)PANGO_SCALE/10.; pango_font_description_free (desc); pa = pango_attr_iterator_get (state_iter, PANGO_ATTR_SCALE); if (pa) scale = ((PangoAttrFloat *)pa)->value; pa = pango_attr_iterator_get (state_iter, PANGO_ATTR_RISE); if (pa) rise = ((PangoAttrInt *)pa)->value; /* We should probably figured out the default font size used */ /* rather than assuming it is 10 pts * scale */ if (font_scale == 0) font_scale = scale; the_attrs = pango_attr_iterator_get_attrs (attr_iter); for (l = the_attrs; l != NULL; l = l->next) { PangoAttribute *attribute = l->data; PangoAttrType type = attribute->klass->type; if (type == go_pango_attr_superscript_get_attr_type ()) { GOPangoAttrSuperscript *attr = (GOPangoAttrSuperscript *)attribute; if (attr->val) { scale *= GO_SUPERSCRIPT_SCALE; rise += GO_SUPERSCRIPT_RISE * font_scale; font_scale *= GO_SUPERSCRIPT_SCALE; } } else { /* go_pango_attr_subscript_type */ GOPangoAttrSubscript *attr = (GOPangoAttrSubscript *)attribute; if (attr->val) { scale *= GO_SUBSCRIPT_SCALE; rise += GO_SUBSCRIPT_RISE * font_scale; font_scale *= GO_SUBSCRIPT_SCALE; } } } if (the_attrs != NULL) { PangoAttribute *attr = pango_attr_scale_new (scale); attr->start_index = range_start; attr->end_index = range_end; pango_attr_list_insert (attrs, attr); attr = pango_attr_rise_new (rise); attr->start_index = range_start; attr->end_index = range_end; pango_attr_list_insert (attrs, attr); } g_slist_free_full (the_attrs, (GDestroyNotify)pango_attribute_destroy); }
static char const * cb_html_attrs_as_string (GsfOutput *output, PangoAttribute *a) { /* PangoColor const *c; */ char const *closure = NULL; switch (a->klass->type) { case PANGO_ATTR_FAMILY : break; /* ignored */ case PANGO_ATTR_SIZE : break; /* ignored */ case PANGO_ATTR_RISE: if (((PangoAttrInt *)a)->value > 5) { gsf_output_puts (output, "<sup>"); closure = "</sup>"; } else if (((PangoAttrInt *)a)->value < -5) { gsf_output_puts (output, "<sub>"); closure = "</sub>"; } break; case PANGO_ATTR_STYLE : if (((PangoAttrInt *)a)->value == PANGO_STYLE_ITALIC) { gsf_output_puts (output, "<i>"); closure = "</i>"; } break; case PANGO_ATTR_WEIGHT : if (((PangoAttrInt *)a)->value > 600){ gsf_output_puts (output, "<b>"); closure = "</b>"; } break; case PANGO_ATTR_STRIKETHROUGH : if (((PangoAttrInt *)a)->value == 1) { gsf_output_puts (output, "<strike>"); closure = "</strike>"; } break; case PANGO_ATTR_UNDERLINE : if (((PangoAttrInt *)a)->value != PANGO_UNDERLINE_NONE) { gsf_output_puts (output, "<u>"); closure = "</u>"; } break; case PANGO_ATTR_FOREGROUND : /* c = &((PangoAttrColor *)a)->color; */ /* g_string_append_printf (accum, "[color=%02xx%02xx%02x", */ /* ((c->red & 0xff00) >> 8), */ /* ((c->green & 0xff00) >> 8), */ /* ((c->blue & 0xff00) >> 8)); */ break;/* ignored */ default : if (a->klass->type == go_pango_attr_subscript_get_attr_type ()) { if (((GOPangoAttrSubscript *)a)->val) { gsf_output_puts (output, "<sub>"); closure = "</sub>"; } } else if (a->klass->type == go_pango_attr_superscript_get_attr_type ()) { if (((GOPangoAttrSuperscript *)a)->val) { gsf_output_puts (output, "<sup>"); closure = "</sup>"; } } break; /* ignored */ } return closure; }