aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2003-04-02 11:08:29 +0800
committerHans Petter <hansp@src.gnome.org>2003-04-02 11:08:29 +0800
commitc8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc (patch)
treea665be846430589993d9cf01e7d0151d3f121df1
parent9f06cc49809acd03ce9367d6851f9f217bd33d27 (diff)
downloadgsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.tar
gsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.tar.gz
gsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.tar.bz2
gsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.tar.lz
gsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.tar.xz
gsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.tar.zst
gsoc2013-evolution-c8e1c20b8a6b5ba84785ef63fcb4c2f4224dd0bc.zip
Nuke GdkFont and use Pango's font measuring.
2003-04-01 Hans Petter Jansson <hpj@ximian.com> * gui/e-day-view-main-item.c (e_day_view_main_item_draw): Nuke GdkFont and use Pango's font measuring. * gui/e-day-view-time-itme.c (e_day_view_time_item_get_column_width) (e_day_view_time_item_draw): Ditto. * gui/e-day-view-top-item.c (e_day_view_top_item_draw) (e_day_view_top_item_draw_long_event): Ditto. * gui/e-day-view.c (e_day_view_style_set) (e_day_view_recalc_cell_sizes) (e_day_view_reshape_long_event) (e_day_view_update_top_canvas_drag) (e_day_view_update_main_canvas_drag): Ditto. * gui/e-meeting-time-sel.c (e_meeting_time_selector_style_set) (e_meeting_time_selector_recalc_date_form): Ditto. * gui/e-week-view-event-item.c (e_week_view_draw_time): Ditto. * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day): Ditto. * gui/e-week-view-titles-item.c (e_week_view_titles_item_draw): Ditto. * gui/e-week-view.c (e_week_view_style_set) (e_week_view_recalc_cell_sizes) (e_week_view_reshape_event_span): Ditto. * gui/weekday-picker.c (weekday_picker_style_set): Ditto. svn path=/trunk/; revision=20627
-rw-r--r--calendar/ChangeLog34
-rw-r--r--calendar/gui/e-day-view-main-item.c2
-rw-r--r--calendar/gui/e-day-view-time-item.c14
-rw-r--r--calendar/gui/e-day-view-top-item.c8
-rw-r--r--calendar/gui/e-day-view.c179
-rw-r--r--calendar/gui/e-meeting-time-sel.c62
-rw-r--r--calendar/gui/e-week-view-event-item.c2
-rw-r--r--calendar/gui/e-week-view-main-item.c22
-rw-r--r--calendar/gui/e-week-view-titles-item.c2
-rw-r--r--calendar/gui/e-week-view.c88
-rw-r--r--calendar/gui/weekday-picker.c22
11 files changed, 263 insertions, 172 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 89682e69c6..5c913f92a2 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,37 @@
+2003-04-01 Hans Petter Jansson <hpj@ximian.com>
+
+ * gui/e-day-view-main-item.c (e_day_view_main_item_draw):
+ Nuke GdkFont and use Pango's font measuring.
+
+ * gui/e-day-view-time-itme.c (e_day_view_time_item_get_column_width)
+ (e_day_view_time_item_draw): Ditto.
+
+ * gui/e-day-view-top-item.c (e_day_view_top_item_draw)
+ (e_day_view_top_item_draw_long_event): Ditto.
+
+ * gui/e-day-view.c (e_day_view_style_set)
+ (e_day_view_recalc_cell_sizes)
+ (e_day_view_reshape_long_event)
+ (e_day_view_update_top_canvas_drag)
+ (e_day_view_update_main_canvas_drag): Ditto.
+
+ * gui/e-meeting-time-sel.c (e_meeting_time_selector_style_set)
+ (e_meeting_time_selector_recalc_date_form): Ditto.
+
+ * gui/e-week-view-event-item.c (e_week_view_draw_time): Ditto.
+
+ * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day):
+ Ditto.
+
+ * gui/e-week-view-titles-item.c (e_week_view_titles_item_draw):
+ Ditto.
+
+ * gui/e-week-view.c (e_week_view_style_set)
+ (e_week_view_recalc_cell_sizes)
+ (e_week_view_reshape_event_span): Ditto.
+
+ * gui/weekday-picker.c (weekday_picker_style_set): Ditto.
+
2003-04-01 JP Rosevear <jpr@ximian.com>
Fix for #17231 (Evo portion)
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 4d57da1b74..56be20e1be 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -162,7 +162,6 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
EDayView *day_view;
GtkStyle *style;
GdkGC *gc;
- GdkFont *font;
gint row, row_y, grid_x1, grid_x2;
gint day, grid_y1, grid_y2;
gint work_day_start_y, work_day_end_y;
@@ -180,7 +179,6 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
g_return_if_fail (day_view != NULL);
style = gtk_widget_get_style (GTK_WIDGET (day_view));
- font = gtk_style_get_font (style);
/* Paint the background colors. */
gc = day_view->main_gc;
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index ab55bc2b9d..5613a15ec2 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -181,7 +181,6 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
{
EDayView *day_view;
GtkStyle *style;
- GdkFont *small_font;
gint digit, large_digit_width, max_large_digit_width = 0;
gint max_suffix_width, max_minute_or_suffix_width;
gint column_width_default, column_width_60_min_rows;
@@ -192,8 +191,6 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
style = gtk_widget_get_style (GTK_WIDGET (day_view));
g_return_val_if_fail (style != NULL, 0);
- small_font = gtk_style_get_font (style);
- g_return_val_if_fail (small_font != NULL, 0);
context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
@@ -260,7 +257,6 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
EDayView *day_view;
EDayViewTimeItem *dvtmitem;
GtkStyle *style;
- GdkFont *small_font;
GdkGC *fg_gc, *dark_gc;
gchar buffer[64], *suffix;
gint hour, display_hour, minute, row;
@@ -272,18 +268,20 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
PangoLayout *layout;
PangoContext *context;
PangoFontDescription *small_font_desc;
- PangoFontMetrics *large_font_metrics;
+ PangoFontMetrics *large_font_metrics, *small_font_metrics;
dvtmitem = E_DAY_VIEW_TIME_ITEM (canvas_item);
day_view = dvtmitem->day_view;
g_return_if_fail (day_view != NULL);
style = gtk_widget_get_style (GTK_WIDGET (day_view));
- small_font = gtk_style_get_font (style);
small_font_desc = style->font_desc;
context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
- large_font_metrics = pango_context_get_metrics (context, day_view->large_font_desc, NULL);
+ large_font_metrics = pango_context_get_metrics (context, day_view->large_font_desc,
+ pango_context_get_language (context));
+ small_font_metrics = pango_context_get_metrics (context, small_font_desc,
+ pango_context_get_language (context));
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
dark_gc = style->dark_gc[GTK_STATE_NORMAL];
@@ -373,9 +371,9 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
g_snprintf (buffer, sizeof (buffer), "%i %s",
display_hour, suffix);
}
- minute_width = gdk_string_width (small_font, buffer);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ pango_layout_get_pixel_size (layout, &minute_width, NULL);
gdk_draw_layout (drawable, fg_gc,
minute_x2 - minute_width,
row_y + small_font_y_offset,
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index 973d326d8f..82f74c5c4e 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -166,7 +166,6 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
GdkGC *gc, *fg_gc, *bg_gc, *light_gc, *dark_gc;
gchar buffer[128], *format;
GdkRectangle clip_rect;
- GdkFont *font;
gint canvas_width, canvas_height, left_edge, day, date_width, date_x;
gint item_height, event_num;
struct tm day_start = { 0 };
@@ -182,7 +181,6 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
g_return_if_fail (day_view != NULL);
style = gtk_widget_get_style (GTK_WIDGET (day_view));
- font = gtk_style_get_font (style);
gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
bg_gc = style->bg_gc[GTK_STATE_NORMAL];
@@ -279,10 +277,10 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
clip_rect.height = item_height - 2;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rect);
- date_width = gdk_string_width (font, buffer);
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ pango_layout_get_pixel_size (layout, &date_width, NULL);
date_x = day_view->day_offsets[day] + (day_view->day_widths[day] - date_width) / 2;
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
gdk_draw_layout (drawable, fg_gc,
date_x - x,
3 - y,
@@ -341,7 +339,6 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
EDayViewEvent *event;
GtkStyle *style;
GdkGC *gc, *fg_gc, *bg_gc;
- GdkFont *font;
gint start_day, end_day;
gint item_x, item_y, item_w, item_h;
gint text_x, icon_x, icon_y, icon_x_inc;
@@ -373,7 +370,6 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
event_num);
style = gtk_widget_get_style (GTK_WIDGET (day_view));
- font = gtk_style_get_font (style);
gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
bg_gc = style->bg_gc[GTK_STATE_NORMAL];
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index d557b43c5c..f403aeb6ca 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1106,7 +1106,6 @@ e_day_view_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
EDayView *day_view;
- GdkFont *font;
gint top_rows, top_canvas_height;
gint hour, max_large_hour_width;
gint minute, max_minute_width, i;
@@ -1116,28 +1115,44 @@ e_day_view_style_set (GtkWidget *widget,
struct tm date_tm;
gchar buffer[128];
gint times_width;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style);
day_view = E_DAY_VIEW (widget);
- font = gtk_style_get_font (gtk_widget_get_style (widget));
+
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (widget)->font_desc;
+ pango_context = gtk_widget_get_pango_context (widget);
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
/* Create the large font. */
if (day_view->large_font_desc != NULL)
pango_font_description_free (day_view->large_font_desc);
- day_view->large_font_desc =
- pango_font_description_copy (gtk_widget_get_style (widget)->font_desc);
+ day_view->large_font_desc = pango_font_description_copy (font_desc);
pango_font_description_set_size (day_view->large_font_desc,
E_DAY_VIEW_LARGE_FONT_PTSIZE * PANGO_SCALE);
/* Recalculate the height of each row based on the font size. */
- day_view->row_height = font->ascent + font->descent + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD * 2 + 2 /* FIXME */;
+ day_view->row_height =
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) +
+ E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD * 2 + 2 /* FIXME */;
day_view->row_height = MAX (day_view->row_height, E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD + 2);
GTK_LAYOUT (day_view->main_canvas)->vadjustment->step_increment = day_view->row_height;
- day_view->top_row_height = font->ascent + font->descent + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT * 2 + E_DAY_VIEW_LONG_EVENT_Y_PAD * 2 + E_DAY_VIEW_TOP_CANVAS_Y_GAP;
+ day_view->top_row_height =
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) +
+ E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT * 2 + E_DAY_VIEW_LONG_EVENT_Y_PAD * 2 +
+ E_DAY_VIEW_TOP_CANVAS_Y_GAP;
day_view->top_row_height = MAX (day_view->top_row_height, E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD + 2 + E_DAY_VIEW_TOP_CANVAS_Y_GAP);
/* Set the height of the top canvas based on the row height and the
@@ -1158,14 +1173,18 @@ e_day_view_style_set (GtkWidget *widget,
date_tm.tm_mon = month;
strftime (buffer, sizeof (buffer), "%B", &date_tm);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
if (width > longest_month_width) {
longest_month_width = width;
day_view->longest_month_name = month;
}
strftime (buffer, sizeof (buffer), "%b", &date_tm);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
if (width > longest_abbreviated_month_width) {
longest_abbreviated_month_width = width;
day_view->longest_abbreviated_month_name = month;
@@ -1185,14 +1204,18 @@ e_day_view_style_set (GtkWidget *widget,
date_tm.tm_wday = day;
strftime (buffer, sizeof (buffer), "%A", &date_tm);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
if (width > longest_weekday_width) {
longest_weekday_width = width;
day_view->longest_weekday_name = day;
}
strftime (buffer, sizeof (buffer), "%a", &date_tm);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
if (width > longest_abbreviated_weekday_width) {
longest_abbreviated_weekday_width = width;
day_view->longest_abbreviated_weekday_name = day;
@@ -1205,7 +1228,9 @@ e_day_view_style_set (GtkWidget *widget,
max_large_hour_width = 0;
for (hour = 0; hour < 24; hour++) {
g_snprintf (buffer, sizeof (buffer), "%02i", hour);
- day_view->small_hour_widths[hour] = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &day_view->small_hour_widths [hour], NULL);
+
day_view->max_small_hour_width = MAX (day_view->max_small_hour_width, day_view->small_hour_widths[hour]);
}
@@ -1214,65 +1239,28 @@ e_day_view_style_set (GtkWidget *widget,
gint minute_width;
g_snprintf (buffer, sizeof (buffer), "%02i", minute);
- minute_width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &minute_width, NULL);
+
max_minute_width = MAX (max_minute_width, minute_width);
}
day_view->max_minute_width = max_minute_width;
- day_view->colon_width = gdk_string_width (font, ":");
- day_view->digit_width = gdk_string_width (font, "0");
- day_view->am_string_width = gdk_string_width (font,
- day_view->am_string);
- day_view->pm_string_width = gdk_string_width (font,
- day_view->pm_string);
+ pango_layout_set_text (layout, ":", 1);
+ pango_layout_get_pixel_size (layout, &day_view->colon_width, NULL);
+ pango_layout_set_text (layout, "0", 1);
+ pango_layout_get_pixel_size (layout, &day_view->digit_width, NULL);
+
+ pango_layout_set_text (layout, day_view->am_string, -1);
+ pango_layout_get_pixel_size (layout, &day_view->am_string_width, NULL);
+ pango_layout_set_text (layout, day_view->pm_string, -1);
+ pango_layout_get_pixel_size (layout, &day_view->pm_string_width, NULL);
/* Calculate the width of the time column. */
times_width = e_day_view_time_item_get_column_width (E_DAY_VIEW_TIME_ITEM (day_view->time_canvas_item));
gtk_widget_set_usize (day_view->time_canvas, times_width, -1);
- /* Set the font of all the EText items. */
- e_day_view_foreach_event (day_view, e_day_view_set_event_font_cb,
- font);
-
-#if 0
- /* FIXME: Port. */
-
- /* Set the fonts for the text items used when dragging. */
- gnome_canvas_item_set (day_view->drag_long_event_item,
- "font_gdk", font, NULL);
-
- gnome_canvas_item_set (day_view->drag_item,
- "font_gdk", font, NULL);
-#endif
-}
-
-
-static gboolean
-e_day_view_set_event_font_cb (EDayView *day_view,
- gint day,
- gint event_num,
- gpointer data)
-{
- EDayViewEvent *event;
-#if 0
- GdkFont *font = data;
-#endif
-
- if (day == E_DAY_VIEW_LONG_EVENT)
- event = &g_array_index (day_view->long_events,
- EDayViewEvent, event_num);
- else
- event = &g_array_index (day_view->events[day],
- EDayViewEvent, event_num);
-
-#if 0
- if (event->canvas_item)
- gnome_canvas_item_set (event->canvas_item,
- "font_gdk", font,
- NULL);
-#endif
-
- return TRUE;
+ g_object_unref (layout);
}
@@ -1336,11 +1324,21 @@ e_day_view_recalc_cell_sizes (EDayView *day_view)
gfloat width, offset;
gint day, max_width;
struct tm date_tm;
- GdkFont *font;
char buffer[128];
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
+ gint pango_width;
g_return_if_fail (((GtkWidget*)day_view)->style != NULL);
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (day_view)));
+
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc;
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
/* Calculate the column sizes, using floating point so that pixels
get divided evenly. Note that we use one more element than the
@@ -1376,7 +1374,10 @@ e_day_view_recalc_cell_sizes (EDayView *day_view)
/* strftime format %A = full weekday name, %d = day of month,
%B = full month name. Don't use any other specifiers. */
strftime (buffer, sizeof (buffer), _("%A %d %B"), &date_tm);
- if (gdk_string_width (font, buffer) < max_width) {
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &pango_width, NULL);
+
+ if (pango_width < max_width) {
day_view->date_format = E_DAY_VIEW_DATE_FULL;
return;
}
@@ -1390,7 +1391,10 @@ e_day_view_recalc_cell_sizes (EDayView *day_view)
/* strftime format %a = abbreviated weekday name, %d = day of month,
%b = abbreviated month name. Don't use any other specifiers. */
strftime (buffer, sizeof (buffer), _("%a %d %b"), &date_tm);
- if (gdk_string_width (font, buffer) < max_width) {
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &pango_width, NULL);
+
+ if (pango_width < max_width) {
day_view->date_format = E_DAY_VIEW_DATE_ABBREVIATED;
return;
}
@@ -1403,10 +1407,15 @@ e_day_view_recalc_cell_sizes (EDayView *day_view)
/* strftime format %d = day of month, %b = abbreviated month name.
Don't use any other specifiers. */
strftime (buffer, sizeof (buffer), _("%d %b"), &date_tm);
- if (gdk_string_width (font, buffer) < max_width)
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &pango_width, NULL);
+
+ if (pango_width < max_width)
day_view->date_format = E_DAY_VIEW_DATE_NO_WEEKDAY;
else
day_view->date_format = E_DAY_VIEW_DATE_SHORT;
+
+ g_object_unref (layout);
}
@@ -5175,13 +5184,16 @@ e_day_view_reshape_long_event (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- GdkFont *font;
gint start_day, end_day, item_x, item_y, item_w, item_h;
gint text_x, text_w, num_icons, icons_width, width, time_width;
CalComponent *comp;
gint min_text_x, max_text_w, text_width, line_len;
gchar *text, *end_of_line;
gboolean show_icons = TRUE, use_max_width = FALSE;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
@@ -5207,7 +5219,13 @@ e_day_view_reshape_long_event (EDayView *day_view,
draw them on top of the resize rect. Nor when editing. */
num_icons = 0;
comp = event->comp;
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (day_view)));
+
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc;
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE
&& day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT
@@ -5249,9 +5267,6 @@ e_day_view_reshape_long_event (EDayView *day_view,
event->canvas_item =
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->top_canvas)->root),
e_text_get_type (),
-#if 0
- "font_gdk", font,
-#endif
"anchor", GTK_ANCHOR_NW,
"clip", TRUE,
"max_lines", 1,
@@ -5286,7 +5301,8 @@ e_day_view_reshape_long_event (EDayView *day_view,
line_len = end_of_line - text;
else
line_len = strlen (text);
- text_width = gdk_text_width (font, text, line_len);
+ pango_layout_set_text (layout, text, line_len);
+ pango_layout_get_pixel_size (layout, &text_width, NULL);
g_free (text);
}
@@ -5317,6 +5333,8 @@ e_day_view_reshape_long_event (EDayView *day_view,
NULL);
e_canvas_item_move_absolute(event->canvas_item,
text_x, item_y);
+
+ g_object_unref (layout);
}
@@ -5403,15 +5421,9 @@ e_day_view_reshape_day_event (EDayView *day_view,
}
if (!event->canvas_item) {
- GdkFont *font;
-
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (day_view)));
event->canvas_item =
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root),
e_text_get_type (),
-#if 0
- "font_gdk", font,
-#endif
"anchor", GTK_ANCHOR_NW,
"line_wrap", TRUE,
"editable", TRUE,
@@ -6820,10 +6832,8 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
EDayViewEvent *event = NULL;
gint row, num_days, start_day, end_day;
gdouble item_x, item_y, item_w, item_h;
- GdkFont *font;
gchar *text;
-
/* Calculate the event's position. If the event is in the same
position we started in, we use the same columns. */
row = day_view->rows_in_top_display + 1;
@@ -6875,11 +6885,7 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
"y2", item_y + item_h - 1,
NULL);
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (day_view)));
gnome_canvas_item_set (day_view->drag_long_event_item,
-#if 0
- "font_gdk", font,
-#endif
"clip_width", item_w - (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) * 2,
"clip_height", item_h - (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD) * 2,
NULL);
@@ -6975,7 +6981,6 @@ e_day_view_update_main_canvas_drag (EDayView *day_view,
EDayViewEvent *event = NULL;
gint cols_in_row, start_col, num_columns, num_rows, start_row, end_row;
gdouble item_x, item_y, item_w, item_h;
- GdkFont *font;
gchar *text;
/* If the position hasn't changed, just return. */
@@ -7038,11 +7043,7 @@ e_day_view_update_main_canvas_drag (EDayView *day_view,
"y2", item_y + item_h - 1,
NULL);
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (day_view)));
gnome_canvas_item_set (day_view->drag_item,
-#if 0
- "font_gdk", font,
-#endif
"clip_width", item_w - E_DAY_VIEW_BAR_WIDTH - E_DAY_VIEW_EVENT_X_PAD * 2,
"clip_height", item_h - (E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD) * 2,
NULL);
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index fec13635f5..c3e6d3a051 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -889,35 +889,44 @@ e_meeting_time_selector_style_set (GtkWidget *widget,
EMeetingTime saved_time;
ETable *real_table;
ETableHeader *eth;
- GdkFont *font;
- EFont *efont;
int hour, max_hour_width;
int numcols, col;
int maxheight;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style);
mts = E_MEETING_TIME_SELECTOR (widget);
- font = gtk_style_get_font (gtk_widget_get_style (widget));
- efont = e_font_from_gdk_font (font);
+
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (widget)->font_desc;
+ pango_context = gtk_widget_get_pango_context (widget);
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
/* Calculate the widths of the hour strings in the style's font. */
max_hour_width = 0;
for (hour = 0; hour < 24; hour++) {
if (calendar_config_get_24_hour_format ())
- mts->hour_widths[hour] = gdk_string_width (font, EMeetingTimeSelectorHours[hour]);
+ pango_layout_set_text (layout, EMeetingTimeSelectorHours [hour], -1);
else
- mts->hour_widths[hour] = gdk_string_width (font, EMeetingTimeSelectorHours12[hour]);
+ pango_layout_set_text (layout, EMeetingTimeSelectorHours12 [hour], -1);
+
+ pango_layout_get_pixel_size (layout, &mts->hour_widths [hour], NULL);
max_hour_width = MAX (max_hour_width, mts->hour_widths[hour]);
}
/* FIXME the 5 is for the padding etable adds on */
- mts->row_height = e_font_height (efont) + 5;
+ mts->row_height =
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) + 5;
mts->col_width = max_hour_width + 6;
- e_font_unref (efont);
-
e_meeting_time_selector_save_position (mts, &saved_time);
e_meeting_time_selector_recalc_grid (mts);
e_meeting_time_selector_restore_position (mts, &saved_time);
@@ -943,6 +952,8 @@ e_meeting_time_selector_style_set (GtkWidget *widget,
GTK_LAYOUT (mts->display_main)->hadjustment->step_increment = mts->col_width;
GTK_LAYOUT (mts->display_main)->vadjustment->step_increment = mts->row_height;
+
+ g_object_unref (layout);
}
/* This draws a shadow around the top display and main display. */
@@ -2012,9 +2023,17 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
gint max_date_width, longest_weekday_width, longest_month_width, width;
gint day, longest_weekday, month, longest_month;
gchar buffer[128];
- GdkFont *font;
-
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (mts)));
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
+
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (GTK_WIDGET (mts))->font_desc;
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (mts));
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
/* Calculate the maximum date width we can fit into the display. */
max_date_width = mts->day_width - 2;
@@ -2027,7 +2046,8 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
longest_weekday = G_DATE_MONDAY;
for (day = G_DATE_MONDAY; day <= G_DATE_SUNDAY; day++) {
g_date_strftime (buffer, sizeof (buffer), "%A", &date);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_weekday_width) {
longest_weekday = day;
longest_weekday_width = width;
@@ -2041,7 +2061,8 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
for (month = G_DATE_JANUARY; month <= G_DATE_DECEMBER; month++) {
g_date_set_month (&date, month);
g_date_strftime (buffer, sizeof (buffer), "%B", &date);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_month_width) {
longest_month = month;
longest_month_width = width;
@@ -2063,7 +2084,9 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
longest_month, longest_weekday, buffer);
#endif
- if (gdk_string_width (font, buffer) < max_date_width) {
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+ if (width < max_date_width) {
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_FULL;
return;
}
@@ -2074,7 +2097,8 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
g_date_set_dmy (&date, 3, 1, 2000); /* Monday 3rd Jan 2000. */
for (day = G_DATE_MONDAY; day <= G_DATE_SUNDAY; day++) {
g_date_strftime (buffer, sizeof (buffer), "%a", &date);
- width = gdk_string_width (font, buffer);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_weekday_width) {
longest_weekday = day;
longest_weekday_width = width;
@@ -2093,10 +2117,14 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
longest_month, longest_weekday, buffer);
#endif
- if (gdk_string_width (font, buffer) < max_date_width)
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+ if (width < max_date_width)
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY;
else
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_SHORT;
+
+ g_object_unref (layout);
}
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 10932d76cc..749bcbad65 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -462,7 +462,6 @@ e_week_view_draw_time (EWeekView *week_view,
{
GtkStyle *style;
GdkGC *gc;
- GdkFont *font;
gint hour_to_display, suffix_width;
gint time_y_normal_font, time_y_small_font;
gchar buffer[128], *suffix;
@@ -470,7 +469,6 @@ e_week_view_draw_time (EWeekView *week_view,
PangoFontDescription *small_font_desc;
style = gtk_widget_get_style (GTK_WIDGET (week_view));
- font = gtk_style_get_font (style);
small_font_desc = week_view->small_font_desc;
gc = week_view->main_gc;
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index e5fc58721d..87682a354a 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -205,12 +205,14 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
EWeekView *week_view;
GtkStyle *style;
GdkGC *gc;
- GdkFont *font;
gint right_edge, bottom_edge, date_width, date_x, line_y;
gboolean show_day_name, show_month_name, selected;
gchar buffer[128], *format_string;
gint month, day_of_month, max_width;
GdkColor *bg_color;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
PangoLayout *layout;
#if 0
@@ -218,15 +220,22 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
#endif
week_view = wvmitem->week_view;
style = gtk_widget_get_style (GTK_WIDGET (week_view));
- font = gtk_style_get_font (style);
gc = week_view->main_gc;
+ /* Set up Pango prerequisites */
+ font_desc = style->font_desc;
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view));
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+
g_return_if_fail (gc != NULL);
month = g_date_month (date);
day_of_month = g_date_day (date);
- line_y = y + E_WEEK_VIEW_DATE_T_PAD + font->ascent
- + font->descent + E_WEEK_VIEW_DATE_LINE_T_PAD;
+ line_y = y + E_WEEK_VIEW_DATE_T_PAD +
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) +
+ E_WEEK_VIEW_DATE_LINE_T_PAD;
/* Draw the background of the day. In the month view odd months are
one color and even months another, so you can easily see when each
@@ -266,8 +275,9 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
gdk_draw_rectangle (drawable, gc, TRUE,
x + 2, y + 1,
width - 5,
- E_WEEK_VIEW_DATE_T_PAD - 1
- + font->ascent + font->descent);
+ E_WEEK_VIEW_DATE_T_PAD - 1 +
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)));
} else {
gdk_draw_rectangle (drawable, gc, TRUE,
x + 2, y + 1,
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index d22938c8b8..733bec9a81 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -147,7 +147,6 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
EWeekView *week_view;
GtkStyle *style;
GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc;
- GdkFont *font;
gint canvas_width, canvas_height, col_width, col, date_width, date_x;
gchar buffer[128], *date_format;
GDate date;
@@ -166,7 +165,6 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
g_return_if_fail (week_view != NULL);
style = gtk_widget_get_style (GTK_WIDGET (week_view));
- font = gtk_style_get_font (style);
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
bg_gc = style->bg_gc[GTK_STATE_NORMAL];
light_gc = style->light_gc[GTK_STATE_NORMAL];
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 06d3dfb906..b1c3290798 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -653,12 +653,14 @@ e_week_view_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
EWeekView *week_view;
- GdkFont *font;
GtkStyle *style;
gint day, day_width, max_day_width, max_abbr_day_width;
gint month, month_width, max_month_width, max_abbr_month_width;
GDate date;
gchar buffer[128];
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
PangoLayout *layout;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
@@ -666,23 +668,33 @@ e_week_view_style_set (GtkWidget *widget,
week_view = E_WEEK_VIEW (widget);
style = gtk_widget_get_style (widget);
- font = gtk_style_get_font (style);
- layout = gtk_widget_create_pango_layout (widget, NULL);
+
+ /* Set up Pango prerequisites */
+ font_desc = style->font_desc;
+ pango_context = gtk_widget_get_pango_context (widget);
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
/* Recalculate the height of each row based on the font size. */
- week_view->row_height = font->ascent + font->descent + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2 + E_WEEK_VIEW_EVENT_TEXT_Y_PAD * 2;
+ week_view->row_height = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) +
+ E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2 + E_WEEK_VIEW_EVENT_TEXT_Y_PAD * 2;
week_view->row_height = MAX (week_view->row_height, E_WEEK_VIEW_ICON_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2);
/* Check that the small font is smaller than the default font.
If it isn't, we won't use it. */
if (week_view->small_font_desc) {
- if (font->ascent + font->descent <= E_WEEK_VIEW_SMALL_FONT_PTSIZE)
+ if (PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
+ <= E_WEEK_VIEW_SMALL_FONT_PTSIZE)
week_view->use_small_font = FALSE;
}
/* Set the height of the top canvas. */
gtk_widget_set_usize (week_view->titles_canvas, -1,
- font->ascent + font->descent + 5);
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) + 5);
/* Save the sizes of various strings in the font, so we can quickly
decide which date formats to use. */
@@ -740,21 +752,6 @@ e_week_view_style_set (GtkWidget *widget,
week_view->pm_string_width = get_string_width (layout,
week_view->pm_string);
-#if 0
- /* Set the font of all the EText items. */
- if (week_view->spans) {
- for (span_num = 0; span_num < week_view->spans->len;
- span_num++) {
- span = &g_array_index (week_view->spans,
- EWeekViewEventSpan, span_num);
- if (span->text_item)
- gnome_canvas_item_set (span->text_item,
- "font_gdk", font,
- NULL);
- }
- }
-#endif
-
g_object_unref (layout);
}
@@ -807,8 +804,10 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
gint row, col;
GtkWidget *widget;
GtkStyle *style;
- GdkFont *font;
gint width, height, time_width;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
if (week_view->multi_week_view) {
week_view->rows = week_view->weeks_shown * 2;
@@ -858,19 +857,26 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
style = gtk_widget_get_style (widget);
if (!style)
return;
- font = gtk_style_get_font (style);
- if (!font)
+ font_desc = style->font_desc;
+ if (!font_desc)
return;
+ pango_context = gtk_widget_get_pango_context (widget);
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+
+
/* Calculate the number of rows of events in each cell, for the large
cells and the compressed weekend cells. */
if (week_view->multi_week_view) {
- week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD
- + font->ascent + font->descent
+ week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD +
+ + PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics))
+ + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
+ E_WEEK_VIEW_DATE_B_PAD;
} else {
week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD
- + font->ascent + font->descent
+ + PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics))
+ + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
+ E_WEEK_VIEW_DATE_LINE_T_PAD + 1
+ E_WEEK_VIEW_DATE_LINE_B_PAD;
}
@@ -2635,7 +2641,6 @@ e_week_view_reshape_event_span (EWeekView *week_view,
{
EWeekViewEvent *event;
EWeekViewEventSpan *span;
- GdkFont *font;
gint span_x, span_y, span_w, num_icons, icons_width, time_width;
gint min_text_x, max_text_w, width;
gboolean show_icons = TRUE, use_max_width = FALSE;
@@ -2644,15 +2649,25 @@ e_week_view_reshape_event_span (EWeekView *week_view,
gdouble text_x, text_y, text_w, text_h;
gchar *text, *end_of_line;
gint line_len, text_width;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
comp = event->comp;
- font = gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (week_view)));
one_day_event = e_week_view_is_one_day_event (week_view, event_num);
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc;
+ pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view));
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
+
/* If the span will not be visible destroy the canvas items and
return. */
if (!e_week_view_get_span_position (week_view, event_num, span_num,
@@ -2721,9 +2736,6 @@ e_week_view_reshape_event_span (EWeekView *week_view,
span->text_item =
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root),
e_text_get_type (),
-#if 0
- "font_gdk", font,
-#endif
"anchor", GTK_ANCHOR_NW,
"clip", TRUE,
"max_lines", 1,
@@ -2756,7 +2768,10 @@ e_week_view_reshape_event_span (EWeekView *week_view,
/* The y position and height are the same for both event types. */
text_y = span_y + E_WEEK_VIEW_EVENT_BORDER_HEIGHT
+ E_WEEK_VIEW_EVENT_TEXT_Y_PAD;
- text_h = font->ascent + font->descent;
+
+ text_h =
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
if (one_day_event) {
/* Note that 1-day events don't have a border. Although we
@@ -2815,8 +2830,9 @@ e_week_view_reshape_event_span (EWeekView *week_view,
line_len = end_of_line - text;
else
line_len = strlen (text);
- text_width = gdk_text_width (font, text,
- line_len);
+
+ pango_layout_set_text (layout, text, line_len);
+ pango_layout_get_pixel_size (layout, &text_width, NULL);
g_free (text);
}
@@ -2867,6 +2883,8 @@ e_week_view_reshape_event_span (EWeekView *week_view,
"clip_height", (gdouble) text_h,
NULL);
e_canvas_item_move_absolute (span->text_item, text_x, text_y);
+
+ g_object_unref (layout);
}
diff --git a/calendar/gui/weekday-picker.c b/calendar/gui/weekday-picker.c
index 67e4a12ea2..fb77a2236f 100644
--- a/calendar/gui/weekday-picker.c
+++ b/calendar/gui/weekday-picker.c
@@ -362,17 +362,26 @@ weekday_picker_style_set (GtkWidget *widget, GtkStyle *previous_style)
{
WeekdayPicker *wp;
WeekdayPickerPrivate *priv;
- GdkFont *font;
int max_width;
const char *str;
int i, len;
+ PangoFontDescription *font_desc;
+ PangoContext *pango_context;
+ PangoFontMetrics *font_metrics;
+ PangoLayout *layout;
wp = WEEKDAY_PICKER (widget);
priv = wp->priv;
- font = gtk_style_get_font (gtk_widget_get_style (widget));
- priv->font_ascent = font->ascent;
- priv->font_descent = font->descent;
+ /* Set up Pango prerequisites */
+ font_desc = gtk_widget_get_style (widget)->font_desc;
+ pango_context = gtk_widget_get_pango_context (widget);
+ font_metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
+ layout = pango_layout_new (pango_context);
+
+ priv->font_ascent = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics));
+ priv->font_descent = PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
max_width = 0;
@@ -382,7 +391,9 @@ weekday_picker_style_set (GtkWidget *widget, GtkStyle *previous_style)
for (i = 0; i < len; i++) {
int w;
- w = gdk_char_measure (font, str[i]);
+ pango_layout_set_text (layout, str + i, 1);
+ pango_layout_get_pixel_size (layout, &w, NULL);
+
if (w > max_width)
max_width = w;
}
@@ -390,6 +401,7 @@ weekday_picker_style_set (GtkWidget *widget, GtkStyle *previous_style)
priv->max_letter_width = max_width;
configure_items (wp);
+ g_object_unref (layout);
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous_style);