diff options
author | Rajeev ramanathan <rajeevramanathan_2004@yahoo.co.in> | 2006-07-10 22:02:36 +0800 |
---|---|---|
committer | Harish Krishnaswamy <kharish@src.gnome.org> | 2006-07-10 22:02:36 +0800 |
commit | 891d8bfc6acc170db4bc3f067a99e60e1459726b (patch) | |
tree | 236538f61eab14ed38c2de5a18d37426d62ae070 /widgets | |
parent | b551414de076b32b638742aa26c0aa175f0e3e7a (diff) | |
download | gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.tar gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.tar.gz gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.tar.bz2 gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.tar.lz gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.tar.xz gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.tar.zst gsoc2013-evolution-891d8bfc6acc170db4bc3f067a99e60e1459726b.zip |
Added code for Resize Transparency with Cairo drawing. Added code to
2006-07-10 Rajeev ramanathan <rajeevramanathan_2004@yahoo.co.in>
Added code for Resize Transparency with Cairo drawing.
Added code to render ECell and EText text items with
antialiasing, hinting and sub-pixel ordering with cairo.
svn path=/trunk/; revision=32270
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/ChangeLog | 5 | ||||
-rw-r--r-- | widgets/table/e-cell-text.c | 60 | ||||
-rw-r--r-- | widgets/text/e-text.c | 69 |
3 files changed, 130 insertions, 4 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog index 1d10540ccd..1ca442d8e6 100644 --- a/widgets/ChangeLog +++ b/widgets/ChangeLog @@ -1,3 +1,8 @@ +2006-07-05 Rajeev ramanathan <rajeevramanathan_2004@yahoo.co.in> + * text/e-text.c, table/e-cell-text.c: + Added code to render ECell and EText text items with + antialiasing, hinting and sub-pixel ordering with cairo. + 2006-07-06 Hiroyuki Ikezoe <poincare@ikezoe.net> ** Fixes bug #341354. diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 7ea8a54c98..a1b56a674c 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -142,7 +142,6 @@ typedef struct { int xofs, yofs; /* This gets added to the x and y for the cell text. */ double ellipsis_width[2]; /* The width of the ellipsis. */ - } ECellTextView; struct _CellEdit { @@ -439,6 +438,7 @@ ect_unrealize (ECellView *ecv) if (parent_class->unrealize) (* parent_class->unrealize) (ecv); + } static void @@ -504,6 +504,53 @@ build_attr_list (ECellTextView *text_view, int row, int text_length) return attrs; } +static cairo_font_options_t * +get_font_options () +{ + char *antialiasing, *hinting, *subpixel_order; + cairo_font_options_t *font_options = cairo_font_options_create (); + + /* Antialiasing */ + antialiasing = gconf_client_get_string (gconf_client_get_default (), + "/desktop/gnome/font_rendering/antialiasing", NULL); + if (strcmp (antialiasing, "grayscale") == 0) + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY); + else if (strcmp (antialiasing, "rgba") == 0) + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); + else if (strcmp (antialiasing, "none") == 0) + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_NONE); + else + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT); + + hinting = gconf_client_get_string (gconf_client_get_default (), + "/desktop/gnome/font_rendering/hinting", NULL); + if (strcmp (hinting, "full") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_FULL); + else if (strcmp (hinting, "medium") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_MEDIUM); + else if (strcmp (hinting, "slight") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT); + else if (strcmp (hinting, "none") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE); + else + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT); + + subpixel_order = gconf_client_get_string (gconf_client_get_default (), + "/desktop/gnome/font_rendering/rgba_order", NULL); + if (strcmp (subpixel_order, "rgb") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB); + else if (strcmp (subpixel_order, "bgr") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_BGR); + else if (strcmp (subpixel_order, "vrgb") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VRGB); + else if (strcmp (subpixel_order, "vbgr") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VBGR); + else + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT); + + return font_options; +} + static PangoLayout * layout_with_preedit (ECellTextView *text_view, int row, const char *text, gint width) { @@ -570,6 +617,8 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width) ECellText *ect = E_CELL_TEXT (ecell_view->ecell); PangoAttrList *attrs ; PangoLayout *layout; + PangoContext *context; + cairo_font_options_t *font_options; layout = gtk_widget_create_pango_layout (GTK_WIDGET (((GnomeCanvasItem *)ecell_view->e_table_item_view)->canvas), text); @@ -581,6 +630,13 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width) if (text_view->edit || width <= 0) return layout; + context = pango_layout_get_context (layout); + + font_options = get_font_options(); + pango_cairo_context_set_font_options (context, font_options); + cairo_font_options_destroy (font_options); + pango_layout_context_changed (layout); + if (ect->font_name) { PangoFontDescription *desc = NULL, *fixed_desc = NULL; @@ -632,7 +688,7 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width) default: break; } - + return layout; } diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 75332cdd8a..50e75dd8f4 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -388,6 +388,53 @@ reset_layout_attrs (EText *text) calc_height (text); } +static cairo_font_options_t * +get_font_options () +{ + char *antialiasing, *hinting, *subpixel_order; + cairo_font_options_t *font_options = cairo_font_options_create (); + + /* Antialiasing */ + antialiasing = gconf_client_get_string (gconf_client_get_default (), + "/desktop/gnome/font_rendering/antialiasing", NULL); + if (strcmp (antialiasing, "grayscale") == 0) + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY); + else if (strcmp (antialiasing, "rgba") == 0) + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); + else if (strcmp (antialiasing, "none") == 0) + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_NONE); + else + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT); + + hinting = gconf_client_get_string (gconf_client_get_default (), + "/desktop/gnome/font_rendering/hinting", NULL); + if (strcmp (hinting, "full") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_FULL); + else if (strcmp (hinting, "medium") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_MEDIUM); + else if (strcmp (hinting, "slight") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT); + else if (strcmp (hinting, "none") == 0) + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE); + else + cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT); + + subpixel_order = gconf_client_get_string (gconf_client_get_default (), + "/desktop/gnome/font_rendering/rgba_order", NULL); + if (strcmp (subpixel_order, "rgb") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB); + else if (strcmp (subpixel_order, "bgr") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_BGR); + else if (strcmp (subpixel_order, "vrgb") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VRGB); + else if (strcmp (subpixel_order, "vbgr") == 0) + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VBGR); + else + cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT); + + return font_options; +} + static void create_layout (EText *text) { @@ -405,12 +452,30 @@ create_layout (EText *text) static void reset_layout (EText *text) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (text); + cairo_font_options_t *font_options; + PangoContext *context; + if (text->layout == NULL) { create_layout (text); } else { - pango_layout_set_text (text->layout, text->text, -1); - reset_layout_attrs (text); + context = pango_layout_get_context (text->layout); + + font_options = get_font_options(); + pango_cairo_context_set_font_options (context, font_options); + cairo_font_options_destroy (font_options); + pango_layout_context_changed (text->layout); + + text->font_desc = pango_font_description_new (); + pango_font_description_set_size (text->font_desc, + pango_font_description_get_size ((GTK_WIDGET (item->canvas))->style->font_desc)); + pango_font_description_set_family (text->font_desc, + pango_font_description_get_family ((GTK_WIDGET (item->canvas))->style->font_desc)); + pango_layout_set_font_description (text->layout, text->font_desc); + + pango_layout_set_text (text->layout, text->text, -1); + reset_layout_attrs (text); } if (!text->button_down) { |