[goffice] Render superscripts in scientific formats with regard to font size and scale. [#425685]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Render superscripts in scientific formats with regard to font size and scale. [#425685]
- Date: Sun, 23 Oct 2011 19:57:21 +0000 (UTC)
commit a6d0bc0b01b1a7649721e8e543fcae2c6eb0b00c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Oct 23 00:08:13 2011 -0600
Render superscripts in scientific formats with regard to font size and scale. [#425685]
2011-10-22 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (go_format_execute): consider the
existing attributes
ChangeLog | 5 +++++
NEWS | 2 ++
goffice/utils/go-format.c | 37 +++++++++++++++++++++++++++++++++++--
3 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 04cab8a..817714a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2011-10-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * goffice/utils/go-format.c (go_format_execute): consider the
+ existing attributes
+
+2011-10-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* goffice/utils/go-format.h: add format defines
* goffice/utils/go-format.c (go_format_execute): use these defines
diff --git a/NEWS b/NEWS
index 7da84a1..d5fd653 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ Andreas:
* Improve fraction format selector. [#117215]
* Support SI prefixes and units in scientific format selector. [#588516]
* Show in-use custom formats in the custom format selector. [#658472]
+ * Render superscripts in scientific formats with regard to font size
+ and scale. [#425685]
Jean:
* Port to gtk+-3.0.
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index f2e3e9c..1938188 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -3470,17 +3470,50 @@ SUFFIX(go_format_execute) (PangoLayout *layout, GString *dst,
guint start = 0,
end = (guint)numpos_end;
PangoAttribute *attr;
+ double font_scale = 1.;
+ double scale = 1.;
+ int rise = 0;
+
if (markup_stack) {
start = (guint)GPOINTER_TO_SIZE (markup_stack->data);
markup_stack = g_slist_delete_link (markup_stack, markup_stack);
}
+
+ if (attrs != NULL) {
+ PangoAttrIterator *iter = pango_attr_list_get_iterator (attrs);
+ gint range_start, range_end;
+ gboolean at_end = FALSE;
+ pango_attr_iterator_range (iter, &range_start, &range_end);
+ while (range_end <= (int) start &&
+ (at_end = pango_attr_iterator_next (iter)))
+ pango_attr_iterator_range (iter, &range_start, &range_end);
+ if (!at_end && range_start <= (int) start) {
+ PangoAttribute *pa;
+ PangoFontDescription *desc = pango_font_description_new ();
+
+ pango_attr_iterator_get_font (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
+ (iter, PANGO_ATTR_SCALE);
+ if (pa)
+ scale = ((PangoAttrFloat *)pa)->value;
+ pa = pango_attr_iterator_get
+ (iter, PANGO_ATTR_RISE);
+ if (pa)
+ rise = ((PangoAttrInt *)pa)->value;
+ }
+ pango_attr_iterator_destroy (iter);
+ }
attr = pango_attr_rise_new
- (GO_SUPERSCRIPT_RISE);
+ (GO_SUPERSCRIPT_RISE * font_scale + rise);
attr->start_index = start;
attr->end_index = end;
pango_attr_list_insert (attrs, attr);
attr = pango_attr_scale_new
- (GO_SUPERSCRIPT_SCALE);
+ (GO_SUPERSCRIPT_SCALE * scale);
attr->start_index = start;
attr->end_index = end;
pango_attr_list_insert (attrs, attr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]