[goffice] Modified serialization of pango markup to support all weights
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [goffice] Modified serialization of pango markup to support all weights
- Date: Thu, 7 May 2009 20:51:42 -0400 (EDT)
commit a0d62dde48fb295301869f1fc6341da7a0b25ff5
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Thu May 7 18:50:04 2009 -0600
Modified serialization of pango markup to support all weights
2009-05-07 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (cb_attrs_as_string): store the full
pango-weight. We apply a linear adjustment so that earlier
versions that read an int see the correct 0 for normal and
1 for bold and we will read old files correctly.
(go_format_parse_markup): read the full pango-weight
---
ChangeLog | 8 ++++++++
NEWS | 3 +++
goffice/utils/go-format.c | 8 +++++---
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ee45b02..c0a83ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-05-07 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * goffice/utils/go-format.c (cb_attrs_as_string): store the full
+ pango-weight. We apply a linear adjustment so that earlier
+ versions that read an int see the correct 0 for normal and
+ 1 for bold and we will read old files correctly.
+ (go_format_parse_markup): read the full pango-weight
+
2009-05-07 Morten Welinder <terra gnome org>
* goffice/gtk/goffice-gtk.c (go_gtk_url_is_writeable): Avoid a
diff --git a/NEWS b/NEWS
index a0d0ade..21cd029 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.7.7:
+Andreas:
+ * Modified serialization of pango markup to support all weights
+
--------------------------------------------------------------------------
goffice 0.7.6:
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index d7e0256..c918e73 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -4124,8 +4124,10 @@ cb_attrs_as_string (PangoAttribute *a, GString *accum)
(((PangoAttrInt *)a)->value == PANGO_STYLE_ITALIC) ? 1 : 0);
break;
case PANGO_ATTR_WEIGHT :
- g_string_append_printf (accum, "[bold=%d",
- (((PangoAttrInt *)a)->value >= PANGO_WEIGHT_BOLD) ? 1 : 0);
+ /* We are scaling the weight so that earlier versions that used only 0/1 */
+ /* can still read the new formats and we can read the old ones. */
+ g_string_append_printf (accum, "[bold=%.3f",
+ (((PangoAttrInt *)a)->value - 399.)/300.);
break;
case PANGO_ATTR_STRIKETHROUGH :
g_string_append_printf (accum, "[strikethrough=%d",
@@ -4202,7 +4204,7 @@ go_format_parse_markup (char *str)
if (0 == strncmp (str, "size", 4))
a = pango_attr_size_new (atoi (val));
else if (0 == strncmp (str, "bold", 4))
- a = pango_attr_weight_new (atoi (val) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+ a = pango_attr_weight_new ((int)(atof (val) * 300. + 399.));
else if (0 == strncmp (str, "rise", 4))
a = pango_attr_rise_new (atoi (val));
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]