[evolution-patches] Printing fixes: Addressbook (269430), Calendar (272668), ETable (272815)
- From: David Malcolm <dmalcolm redhat com>
- To: Evolution Patches <evolution-patches ximian com>
- Cc:
- Subject: [evolution-patches] Printing fixes: Addressbook (269430), Calendar (272668), ETable (272815)
- Date: Mon, 22 Aug 2005 16:33:22 -0400
I've got various fixes for printing that port Evolution from using
gnome_font to Pango's font selection and from using gnome_print_show to
gnome_print_pango_layout. These have been in Fedora's downstream
packages for a while and really ought to go into upstream evolution.
They would require bumping the dependency/configure check on
libgnomeprint in evolution from 2.2.0 to 2.7.0 (to ensure that Pango
integration is available).
I'm attaching the patches I apply in Fedora. There's a rather
disturbing magic scale factor of 0.86 needed when handling font sizes
that probably should be tracked down before committing these.
They fix the following bugs in GNOME bugzilla:
269430: "Print preview of russian names is not working"
(evo-addressbook-print-with-pango-2.patch)
272668: "Calendar Printing should use gnome_print_pango_layout"
(evo-calendar-print-with-pango-5.patch)
272815: "ETable printing code doesn't support indic/japanese scripts"
(evolution-2.3.5.1-fix-150459.patch)
Thoughts? Is this kind of change acceptable at this stage of the
release cycle?
David
Index: addressbook/printing/e-contact-print-types.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/printing/e-contact-print-types.h,v
retrieving revision 1.6
diff -u -p -r1.6 e-contact-print-types.h
--- addressbook/printing/e-contact-print-types.h 27 Oct 2001 16:41:29 -0000 1.6
+++ addressbook/printing/e-contact-print-types.h 22 Feb 2005 02:05:41 -0000
@@ -24,6 +24,7 @@
#include <glib.h>
#include <libgnomeprint/gnome-font.h>
+#include <libgnomeprint/gnome-print-pango.h>
typedef struct _EContactPrintStyle EContactPrintStyle;
typedef enum _EContactPrintType EContactPrintType;
@@ -43,8 +44,8 @@ struct _EContactPrintStyle
guint blank_forms;
gboolean letter_tabs;
gboolean letter_headings;
- GnomeFont *headings_font;
- GnomeFont *body_font;
+ PangoFontDescription *headings_font;
+ PangoFontDescription *body_font;
gboolean print_using_grey;
gint paper_type;
gdouble paper_width;
@@ -58,11 +59,11 @@ struct _EContactPrintStyle
gdouble page_width;
gdouble page_height;
gboolean orientation_portrait;
- GnomeFont *header_font;
+ PangoFontDescription *header_font;
gchar *left_header;
gchar *center_header;
gchar *right_header;
- GnomeFont *footer_font;
+ PangoFontDescription *footer_font;
gchar *left_footer;
gchar *center_footer;
gchar *right_footer;
Index: addressbook/printing/e-contact-print.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/printing/e-contact-print.c,v
retrieving revision 1.49
diff -u -p -r1.49 e-contact-print.c
--- addressbook/printing/e-contact-print.c 21 Jan 2005 21:05:13 -0000 1.49
+++ addressbook/printing/e-contact-print.c 22 Feb 2005 02:05:41 -0000
@@ -53,6 +53,7 @@ struct _EContactPrintContext
{
GnomePrintContext *pc;
GnomePrintJob *master;
+ PangoLayout *pl;
gdouble x;
gdouble y;
gint column;
@@ -60,8 +61,9 @@ struct _EContactPrintContext
gboolean first_section;
gchar first_char_on_page;
gchar last_char_on_page;
- GnomeFont *letter_heading_font;
- GnomeFont *letter_tab_font;
+
+ PangoFontDescription *letter_heading_font;
+ PangoFontDescription *letter_tab_font;
char *character;
gboolean first_contact;
@@ -73,222 +75,111 @@ struct _EContactPrintContext
GList *contacts;
};
-static gint
-e_contact_divide_text(GnomePrintContext *pc, GnomeFont *font, double width, const gchar *text, GList **return_val /* Of type char[] */)
+static double
+get_font_height (PangoFontDescription *font)
{
- if ( width == -1 || gnome_font_get_width_utf8(font, text) <= width ) {
- if ( return_val ) {
- *return_val = g_list_append(*return_val, g_strdup(text));
- }
- return 1;
- } else {
-#if 1
- int i, l;
- double x = 0;
- int lastend = 0;
- int linestart = 0;
- int firstword = 1;
- int linecount = 0;
- l = strlen(text);
- for ( i = 0; i < l; i++ ) {
- if ( text[i] == ' ' ) {
- if ( (!firstword) && x + gnome_font_get_width_utf8_sized(font, text + lastend, i - lastend) > width ) {
- if (return_val) {
- *return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart));
- }
- x = gnome_font_get_width_utf8(font, " ");
- linestart = lastend + 1;
- x += gnome_font_get_width_utf8_sized(font, text + linestart, i - linestart);
- lastend = i;
- linecount ++;
- } else {
- x += gnome_font_get_width_utf8_sized(font, text + lastend, i - lastend);
- lastend = i;
- }
- firstword = 0;
- } else if ( text[i] == '\n' ) {
- if ( (!firstword) && x + gnome_font_get_width_utf8_sized(font, text + lastend, i - lastend) > width ) {
- if (return_val) {
- *return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart));
- }
- linestart = lastend + 1;
- lastend = i;
- linecount ++;
- }
- if (return_val) {
- *return_val = g_list_append(*return_val, g_strndup(text + linestart, i - linestart));
- }
- linestart = i + 1;
- lastend = i + 1;
- linecount ++;
- x = gnome_font_get_width_utf8(font, " ");
+ return (double)pango_font_description_get_size (font)/(double)PANGO_SCALE;
+}
- firstword = 1;
- }
- }
- if ( (!firstword) && x + gnome_font_get_width_utf8_sized(font, text + lastend, i - lastend) > width ) {
- if (return_val) {
- *return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart));
- }
- linestart = lastend + 1;
- lastend = i;
- linecount ++;
- }
- if (return_val) {
- *return_val = g_list_append(*return_val, g_strndup(text + linestart, i - linestart));
- }
- linecount ++;
- return(linecount);
-#else
- HnjBreak *breaks;
- gint *result;
- gint *is;
- gint n_breaks = 0, n_actual_breaks = 0;
- gint i;
- gint l;
- gchar *hyphenation;
- double x = - gnome_font_get_width_utf8(font, " ") * SCALE;
- HnjParams hnjparams;
-
- hnjparams.set_width = width * SCALE + x;
- hnjparams.max_neg_space = 0;
- hnjparams.tab_width = 0;
+static double
+get_font_width (EContactPrintContext *context, PangoFontDescription *font, const char *text)
+{
+ int width;
+ int height;
- l = strlen(text);
-
- /* find possible line breaks. */
- for (i = 0; i < l; i++) {
- if (text[i] == '-')
- n_breaks++;
- else if (text[i] == ' ')
- n_breaks++;
-#if 0
- else if (hyphenation[i] & 1)
- n_breaks++;
-#endif
- }
+ g_return_val_if_fail (font, 0.0);
+ g_return_val_if_fail (text, 0.0);
- breaks = g_new( HnjBreak, n_breaks + 1 );
- result = g_new( gint, n_breaks + 1 );
- is = g_new( gint, n_breaks + 1 );
- n_breaks = 0;
- /* find possible line breaks. */
-
- for (i = 0; i < l; i++) {
- if ( text[i] == '-' ) {
- x += gnome_font_get_width(font, text[i]) * SCALE;
- breaks[n_breaks].x0 = x;
- breaks[n_breaks].x1 = x;
- breaks[n_breaks].penalty = HYPHEN_PENALTY;
- breaks[n_breaks].flags = HNJ_JUST_FLAG_ISHYPHEN;
- is[n_breaks] = i + 1;
- n_breaks++;
- } else if ( text[i] == ' ' ) {
- breaks[ n_breaks ].x0 = x;
- x += gnome_font_get_width(font, text[i]) * SCALE;
- breaks[ n_breaks ].x1 = x;
- breaks[ n_breaks ].penalty = 0;
- breaks[ n_breaks ].flags = HNJ_JUST_FLAG_ISSPACE;
- is[ n_breaks ] = i + 1;
- n_breaks++;
-#if 0
- } else if (word->hyphenation[i] & 1) {
- breaks[n_breaks].x0 = x + gnome_font_get_width(font, '-') * SCALE;
- breaks[n_breaks].x1 = x;
- breaks[n_breaks].penalty = HYPHEN_PENALTY;
- breaks[n_breaks].flags = HNJ_JUST_FLAG_ISHYPHEN;
- is[n_breaks] = i + 1;
- n_breaks++;
-#endif
- } else
- x += gnome_font_get_width(font, text[i]) * SCALE;
+ g_assert (context->pl);
+ pango_layout_set_font_description (context->pl, font);
+ pango_layout_set_text (context->pl, text, -1);
+ pango_layout_set_width (context->pl, -1);
+ pango_layout_set_indent (context->pl, 0);
- }
- is[n_breaks] = i;
- breaks[n_breaks].flags = 0;
- n_breaks++;
-
- /* Calculate optimal line breaks. */
- n_actual_breaks = hnj_hs_just (breaks, n_breaks,
- &hnjparams, result);
-
- if ( return_val ) {
- gchar *next_val;
- if ( breaks[result[0]].flags == HNJ_JUST_FLAG_ISHYPHEN && text[is[result[0]]] != '-' ) {
- next_val = g_new(gchar, is[result[0]] + 2);
- strncpy(next_val, text, is[result[0]]);
- next_val[is[result[0]]] = 0;
- strcat(next_val, "-");
- } else {
- next_val = g_new(gchar, is[result[0]] + 1);
- strncpy(next_val, text, is[result[0]]);
- next_val[is[result[0]]] = 0;
- }
- *return_val = g_list_append(*return_val, next_val);
-
- for ( i = 1; i < n_actual_breaks; i++ ) {
- if ( (breaks[result[i]].flags & HNJ_JUST_FLAG_ISHYPHEN) && (text[is[result[i]]] != '-') ) {
- next_val = g_new(gchar, is[result[i]] - is[result[i - 1]] + 2);
- strncpy(next_val, text + is[result[i - 1]], is[result[i]] - is[result[i - 1]]);
- next_val[is[result[i]] - is[result[i - 1]]] = 0;
- strcat(next_val, "-");
- } else {
- next_val = g_new(gchar, is[result[i]] - is[result[i - 1]] + 1);
- strncpy(next_val, text + is[result[i - 1]], is[result[i]] - is[result[i - 1]]);
- next_val[is[result[i]] - is[result[i - 1]]] = 0;
- }
- *return_val = g_list_append(*return_val, next_val);
- }
- }
-
- g_free (breaks);
- g_free (result);
- g_free (is);
- return n_actual_breaks;
-#endif
+ pango_layout_get_size (context->pl,
+ &width,
+ &height);
+
+ return (double)width/(double)PANGO_SCALE;
+}
+
+static PangoFontDescription*
+find_font (const char *name, double height)
+{
+ PangoFontDescription *desc = pango_font_description_new ();
+ pango_font_description_set_family (desc, name);
+ pango_font_description_set_size (desc, height * PANGO_SCALE);
+
+ return desc;
+}
+
+static PangoFontDescription*
+find_closest_font_from_weight_slant (const guchar *family, GnomeFontWeight weight, gboolean italic, gdouble size)
+{
+ PangoFontDescription *desc = pango_font_description_new ();
+ pango_font_description_set_family (desc, family);
+
+ /* GnomePrintWeight and PangoWeight values should be interchangeable: */
+ pango_font_description_set_weight (desc, (PangoWeight)weight);
+
+ if (italic) {
+ pango_font_description_set_style (desc, PANGO_STYLE_ITALIC);
}
+ pango_font_description_set_size (desc, size * PANGO_SCALE);
+
+ return desc;
}
static void
-e_contact_output(GnomePrintContext *pc, GnomeFont *font, double x, double y, double width, const gchar *text)
+e_contact_output(EContactPrintContext *ctxt, PangoFontDescription *font, double x, double y, double width, const gchar *text)
{
- GList *list = NULL, *list_start;
- int first_line = 1;
- gnome_print_gsave(pc);
- gnome_print_setfont(pc, font);
- e_contact_divide_text(pc, font, width, text, &list);
- for ( list_start = list; list; list = g_list_next(list)) {
- y -= gnome_font_get_ascender(font);
- gnome_print_moveto(pc, x, y);
- gnome_print_show(pc, (char *)list->data);
- y -= gnome_font_get_descender(font);
- y -= .2 * gnome_font_get_size (font);
- if ( first_line ) {
- x += gnome_font_get_width_utf8(font, " ");
- first_line = 0;
- }
- }
- g_list_foreach( list_start, (GFunc) g_free, NULL );
- g_list_free( list_start );
- gnome_print_grestore(pc);
+ gnome_print_gsave(ctxt->pc);
+
+ /* Preserve the indentation behaviour of the old e_contact_divide_text function: */
+ double indent;
+ if ( width == -1 || get_font_width(ctxt, font, text) <= width ) {
+ indent = 0.0;
+ } else {
+ indent = get_font_width (ctxt, font, " ");
+ }
+
+ g_assert (ctxt->pl);
+ pango_layout_set_font_description (ctxt->pl, font);
+ pango_layout_set_text (ctxt->pl, text, -1);
+ pango_layout_set_width (ctxt->pl, width*PANGO_SCALE);
+ pango_layout_set_indent (ctxt->pl, indent*PANGO_SCALE);
+
+ gnome_print_moveto(ctxt->pc, x, y);
+ gnome_print_pango_layout (ctxt->pc, ctxt->pl);
+ gnome_print_grestore(ctxt->pc);
}
static gdouble
-e_contact_text_height(GnomePrintContext *pc, GnomeFont *font, double width, const gchar *text)
+e_contact_text_height(EContactPrintContext *ctxt, PangoFontDescription *font, double width, const gchar *text)
{
- int line_count = e_contact_divide_text(pc, font, width, text, NULL);
- return line_count * (gnome_font_get_ascender(font) + gnome_font_get_descender(font)) +
- (line_count - 1) * .2 * gnome_font_get_size (font);
+ gint w, h;
+
+ g_assert (ctxt->pl);
+ pango_layout_set_font_description (ctxt->pl, font);
+ pango_layout_set_text (ctxt->pl, text, -1);
+ pango_layout_set_width (ctxt->pl, width*PANGO_SCALE);
+ pango_layout_set_indent (ctxt->pl, 0);
+
+ pango_layout_get_size (ctxt->pl,
+ &w,
+ &h);
+
+ return (double)h/(double)PANGO_SCALE;
}
#if 0
static void
-e_contact_output_and_advance(EContactPrintContext *ctxt, GnomeFont *font, double x, double width, gchar *text)
+e_contact_output_and_advance(EContactPrintContext *ctxt, PangoFontDescription *font, double x, double width, gchar *text)
{
- ctxt->y -= .1 * gnome_font_get_size (font);
+ ctxt->y -= .1 * get_font_height (font);
e_contact_output(ctxt->pc, font, x, ctxt->y, width, text);
ctxt->y -= e_contact_text_height(ctxt->pc, font, width, text);
- ctxt->y -= .1 * gnome_font_get_size (font);
+ ctxt->y -= .1 * get_font_height (font);
}
#endif
@@ -316,7 +207,7 @@ e_contact_rectangle(GnomePrintContext *p
static double
e_contact_get_letter_tab_width (EContactPrintContext *ctxt)
{
- return gnome_font_get_width_utf8(ctxt->letter_tab_font, "123") + 4 + 18;
+ return get_font_width(ctxt, ctxt->letter_tab_font, "123") + 4 + 18;
}
static double
@@ -346,41 +237,37 @@ e_contact_print_letter_tab (EContactPrin
if ( character >= ctxt->first_char_on_page && character <= ctxt->last_char_on_page ) {
e_contact_rectangle( ctxt->pc, x + 1, y - 1, x + tab_width - 1, y - (tab_height - 1), 0, 0, 0 );
gnome_print_setrgbcolor( ctxt->pc, 1, 1, 1 );
- e_contact_output( ctxt->pc, ctxt->letter_tab_font, x + tab_width / 2 - gnome_font_get_width_utf8(ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
+ e_contact_output( ctxt, ctxt->letter_tab_font, x + tab_width / 2 - get_font_width(ctxt, ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
} else {
gnome_print_setrgbcolor( ctxt->pc, 0, 0, 0 );
- e_contact_output( ctxt->pc, ctxt->letter_tab_font, x + tab_width / 2 - gnome_font_get_width_utf8(ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
+ e_contact_output( ctxt, ctxt->letter_tab_font, x + tab_width / 2 - get_font_width(ctxt, ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
}
y -= tab_height;
}
gnome_print_grestore( ctxt->pc );
- return gnome_font_get_width_utf8(ctxt->style->body_font, "123") + gnome_font_get_size (ctxt->style->body_font) / 5;
+ return get_font_width(ctxt, ctxt->style->body_font, "123") + get_font_height (ctxt->style->body_font) / 5;
}
static double
e_contact_get_letter_heading_height (EContactPrintContext *ctxt)
{
- gdouble ascender, descender;
- ascender = gnome_font_get_ascender(ctxt->letter_heading_font);
- descender = gnome_font_get_descender(ctxt->letter_heading_font);
- return ascender + descender + 9;
+ return get_font_height (ctxt->letter_heading_font);
}
static void
e_contact_print_letter_heading (EContactPrintContext *ctxt, gchar *character)
{
- gdouble ascender, descender;
+ gdouble height;
gdouble width;
- width = gnome_font_get_width_utf8(ctxt->letter_heading_font, "m") * 1.7;
- ascender = gnome_font_get_ascender(ctxt->letter_heading_font);
- descender = gnome_font_get_descender(ctxt->letter_heading_font);
+ width = get_font_width(ctxt, ctxt->letter_heading_font, "m") * 1.7;
+ height = get_font_height (ctxt->letter_heading_font);
gnome_print_gsave( ctxt->pc );
- e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, ctxt->x + width, ctxt->y - (ascender + descender + 6), 0, 0, 0);
+ e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, ctxt->x + width, ctxt->y - (height + 6), 0, 0, 0);
gnome_print_setrgbcolor(ctxt->pc, 1, 1, 1);
ctxt->y -= 4;
- e_contact_output(ctxt->pc, ctxt->letter_heading_font, ctxt->x + (width - gnome_font_get_width_utf8(ctxt->letter_heading_font, character))/ 2, ctxt->y, -1, character);
- ctxt->y -= ascender + descender;
+ e_contact_output(ctxt, ctxt->letter_heading_font, ctxt->x + (width - get_font_width(ctxt, ctxt->letter_heading_font, character))/ 2, ctxt->y, -1, character);
+ ctxt->y -= height;
ctxt->y -= 2;
ctxt->y -= 3;
gnome_print_grestore( ctxt->pc );
@@ -413,31 +300,31 @@ e_contact_get_contact_size(EContact *con
page_width -= e_contact_get_letter_tab_width(ctxt);
column_width = (page_width + 18) / ctxt->style->num_columns - 18;
- height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+ height += get_font_height (ctxt->style->headings_font) * .2;
- height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+ height += get_font_height (ctxt->style->headings_font) * .2;
file_as = e_contact_get_const (contact, E_CONTACT_FILE_AS);
- height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as);
+ height += e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as);
- height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+ height += get_font_height (ctxt->style->headings_font) * .2;
- height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+ height += get_font_height (ctxt->style->headings_font) * .2;
for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) {
char *string;
string = e_contact_get(contact, field);
if (string && *string) {
double xoff = 0;
- xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_contact_pretty_name (field));
- xoff += gnome_font_get_width_utf8(ctxt->style->body_font, ": ");
- height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string);
- height += .2 * gnome_font_get_size (ctxt->style->body_font);
+ xoff += get_font_width(ctxt, ctxt->style->body_font, e_contact_pretty_name (field));
+ xoff += get_font_width(ctxt, ctxt->style->body_font, ": ");
+ height += e_contact_text_height(ctxt, ctxt->style->body_font, column_width - xoff, string);
+ height += .2 * get_font_height (ctxt->style->body_font);
}
g_free(string);
}
- height += gnome_font_get_size (ctxt->style->headings_font) * .4;
+ height += get_font_height (ctxt->style->headings_font) * .4;
/* g_message ("%s %g", e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_FILE_AS), height); */
return height;
@@ -458,18 +345,18 @@ e_contact_print_contact (EContact *conta
gnome_print_gsave(ctxt->pc);
- ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
- ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
+ ctxt->y -= get_font_height (ctxt->style->headings_font) * .2;
+ ctxt->y -= get_font_height (ctxt->style->headings_font) * .2;
file_as = e_contact_get (contact, E_CONTACT_FILE_AS);
if (ctxt->style->print_using_grey)
- e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + gnome_font_get_size (ctxt->style->headings_font) * .3, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as) - gnome_font_get_size (ctxt->style->headings_font) * .3, .85, .85, .85);
- e_contact_output(ctxt->pc, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as);
- ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as);
+ e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + get_font_height (ctxt->style->headings_font) * .3, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as) - get_font_height (ctxt->style->headings_font) * .3, .85, .85, .85);
+ e_contact_output(ctxt, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as);
+ ctxt->y -= e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as);
g_free (file_as);
- ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
- ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
+ ctxt->y -= get_font_height (ctxt->style->headings_font) * .2;
+ ctxt->y -= get_font_height (ctxt->style->headings_font) * .2;
for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) {
char *string;
@@ -477,18 +364,18 @@ e_contact_print_contact (EContact *conta
if (string && *string) {
double xoff = 0;
- e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_contact_pretty_name (field));
- xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_contact_pretty_name (field));
- e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": ");
- xoff += gnome_font_get_width_utf8(ctxt->style->body_font, ": ");
- e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string);
- ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string);
- ctxt->y -= .2 * gnome_font_get_size (ctxt->style->body_font);
+ e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_contact_pretty_name (field));
+ xoff += get_font_width(ctxt, ctxt->style->body_font, e_contact_pretty_name (field));
+ e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": ");
+ xoff += get_font_width(ctxt, ctxt->style->body_font, ": ");
+ e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string);
+ ctxt->y -= e_contact_text_height(ctxt, ctxt->style->body_font, column_width - xoff, string);
+ ctxt->y -= .2 * get_font_height (ctxt->style->body_font);
}
g_free(string);
}
- ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .4;
+ ctxt->y -= get_font_height (ctxt->style->headings_font) * .4;
gnome_print_grestore(ctxt->pc);
}
@@ -585,12 +472,12 @@ complete_sequence(EBookView *book_view,
e_book_query_unref (ctxt->query);
g_list_foreach(ctxt->contacts, (GFunc) g_object_unref, NULL);
g_list_free(ctxt->contacts);
- g_object_unref(ctxt->style->headings_font);
- g_object_unref(ctxt->style->body_font);
- g_object_unref(ctxt->style->header_font);
- g_object_unref(ctxt->style->footer_font);
- g_object_unref(ctxt->letter_heading_font);
- g_object_unref(ctxt->letter_tab_font);
+ pango_font_description_free(ctxt->style->headings_font);
+ pango_font_description_free(ctxt->style->body_font);
+ pango_font_description_free(ctxt->style->header_font);
+ pango_font_description_free(ctxt->style->footer_font);
+ pango_font_description_free(ctxt->letter_heading_font);
+ pango_font_description_free(ctxt->letter_tab_font);
g_free(ctxt->style);
g_free(ctxt);
}
@@ -701,12 +588,12 @@ static double get_float( char *data )
return 0;
}
-static void get_font( char *data, GnomeFont **variable )
+static void get_font( char *data, PangoFontDescription **variable )
{
if ( data ) {
- GnomeFont *font = gnome_font_find_from_full_name( data );
+ PangoFontDescription *font = pango_font_description_from_string ( data );
if ( font ) {
- g_object_unref(*variable);
+ pango_font_description_free(*variable);
*variable = font;
}
}
@@ -727,8 +614,8 @@ e_contact_build_style(EContactPrintStyle
style->letter_tabs = TRUE;
style->letter_headings = FALSE;
- style->headings_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOLD, FALSE, 8);
- style->body_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
+ style->headings_font = find_closest_font_from_weight_slant ("Sans", GNOME_FONT_BOLD, FALSE, 8);
+ style->body_font = find_closest_font_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
style->print_using_grey = TRUE;
style->paper_type = 0;
@@ -752,13 +639,13 @@ e_contact_build_style(EContactPrintStyle
#endif
style->orientation_portrait = FALSE;
- style->header_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
+ style->header_font = find_closest_font_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
style->left_header = g_strdup("");
style->center_header = g_strdup("");
style->right_header = g_strdup("");
- style->footer_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
+ style->footer_font = find_closest_font_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
style->left_footer = g_strdup("");
style->center_footer = g_strdup("");
@@ -897,10 +784,11 @@ e_contact_print_response(GtkWidget *dial
ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PRINT;
font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
- ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5);
- ctxt->letter_tab_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), font_size);
+ ctxt->letter_heading_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), get_font_height(ctxt->style->headings_font)*1.5);
+ ctxt->letter_tab_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), font_size);
ctxt->pc = pc;
+ ctxt->pl = gnome_print_pango_create_layout (pc);
#warning FIXME gnome_print_multipage_new_from_sizes
#if 0
ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc,
@@ -943,8 +831,8 @@ e_contact_print_response(GtkWidget *dial
ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PREVIEW;
font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
- ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5);
- ctxt->letter_tab_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), font_size);
+ ctxt->letter_heading_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), get_font_height (ctxt->style->headings_font) * 1.5);
+ ctxt->letter_tab_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), font_size);
ctxt->pc = pc;
#warning FIXME gnome_print_multipage_new_from_sizes
@@ -986,6 +874,8 @@ e_contact_print_response(GtkWidget *dial
e_book_query_unref (query);
gtk_widget_destroy (dialog);
+ g_assert (ctxt->pl);
+ g_object_unref (G_OBJECT(ctxt->pl));
g_free(style);
g_free(ctxt);
break;
@@ -1039,10 +929,11 @@ e_contact_print_preview(EBook *book, cha
ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PREVIEW;
font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
- ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5);
- ctxt->letter_tab_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), font_size);
+ ctxt->letter_heading_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), get_font_height (ctxt->style->headings_font) * 1.5);
+ ctxt->letter_tab_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), font_size);
- ctxt->pc = pc;
+ ctxt->pc = pc;
+ ctxt->pl = gnome_print_pango_create_layout (pc);
#warning FIXME gnome_print_multipage_new_from_sizes
#if 0
ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc,
--- evolution-2.3.5.1/calendar/gui/print.c.calendar-print-with-pango 2005-06-23 02:12:18.000000000 -0400
+++ evolution-2.3.5.1/calendar/gui/print.c 2005-07-25 15:50:01.000000000 -0400
@@ -59,6 +59,83 @@
#include "gnome-cal.h"
#include "print.h"
+#include <libgnomeprint/gnome-print-pango.h>
+
+typedef struct EvoCalendarPrintRenderer EvoCalendarPrintRenderer;
+
+struct EvoCalendarPrintRenderer
+{
+ GnomePrintContext *pc;
+
+ /* keep one of these around: */
+ PangoLayout *pl;
+};
+
+static EvoCalendarPrintRenderer *
+evo_calendar_print_data_new (GnomePrintContext *pc);
+
+static void
+evo_calendar_print_data_free (EvoCalendarPrintRenderer *pr);
+
+static double
+evo_calendar_print_renderer_get_width (EvoCalendarPrintRenderer *pr,
+ PangoFontDescription *font,
+ const char *text);
+
+
+static EvoCalendarPrintRenderer *
+evo_calendar_print_data_new (GnomePrintContext *pc)
+{
+ EvoCalendarPrintRenderer *pr;
+
+ g_return_val_if_fail (pc, NULL);
+
+ pr = g_new0 (EvoCalendarPrintRenderer, 1);
+
+ pr->pc = pc; /* ref/unref this? the old code doesn't */
+
+ pr->pl = gnome_print_pango_create_layout (pc);
+
+ return pr;
+}
+
+static void
+evo_calendar_print_data_free (EvoCalendarPrintRenderer *pr)
+{
+ g_return_if_fail (pr);
+
+ g_assert (pr->pl);
+ g_object_unref (G_OBJECT (pr->pl));
+
+ g_free (pr);
+}
+
+
+static double
+evo_calendar_print_renderer_get_width (EvoCalendarPrintRenderer *pr,
+ PangoFontDescription *font,
+ const char *text)
+{
+ int w, h;
+
+ pango_layout_set_font_description (pr->pl, font);
+ pango_layout_set_text (pr->pl, text, -1);
+ pango_layout_set_indent (pr->pl, 0);
+
+ pango_layout_get_size (pr->pl, &w, &h);
+
+ return w/(double)PANGO_SCALE;
+}
+
+
+static double
+get_font_size (PangoFontDescription *font)
+{
+ g_return_val_if_fail (font, 0.0);
+
+ return ((double)pango_font_description_get_size (font)/(double)PANGO_SCALE);
+}
+
/*
@@ -251,12 +328,10 @@
*end = d_week + d_month - 1;
}
-static GnomeFont *
-get_font_for_size (double h, GnomeFontWeight weight, gboolean italic)
+static PangoFontDescription *
+get_font_for_size (EvoCalendarPrintRenderer *pr, double h, GnomeFontWeight weight, gboolean italic)
{
- GnomeFontFace *face;
- GnomeFont *font;
- double asc, desc, size;
+ PangoFontDescription *font_desc;
gchar *font_name;
if (weight <= GNOME_FONT_BOOK)
@@ -267,22 +342,16 @@
if (italic)
font_name = g_strconcat (font_name, " Italic", NULL);
- /* This function is broken in gnome-print (it doesn't find a suitable face).
- * face = gnome_font_face_find_closest_from_weight_slant (DEFAULT_FONT, weight, italic); */
- face = gnome_font_face_find (font_name);
-
- asc = gnome_font_face_get_ascender (face);
- desc = abs (gnome_font_face_get_descender (face));
- size = h * 1000 / (asc + desc);
-
- /* This function is broken in gnome-print (it doesn't find a suitable font).
- * font = gnome_font_find_closest_from_weight_slant (DEFAULT_FONT, weight, italic, size); */
- font = gnome_font_find_closest (font_name, size);
+ font_desc = pango_font_description_from_string (font_name);
+
+ #define MAGIC_SCALE_FACTOR (0.86)
+ pango_font_description_set_size (font_desc,
+ h * MAGIC_SCALE_FACTOR * PANGO_SCALE );
- g_object_unref (face);
if (italic)
g_free (font_name);
- return font;
+
+ return font_desc;
}
enum align_box {
@@ -384,18 +453,25 @@
gnome_print_grestore (pc);
}
+
+
/* Prints 1 line of aligned text in a box. It is centered vertically, and
the horizontal alignment can be either ALIGN_LEFT, ALIGN_RIGHT, or
ALIGN_CENTER. */
-static void
-print_text(GnomePrintContext *pc, GnomeFont *font, const char *text,
+static double
+print_text (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char *text,
enum align_box align, double l, double r, double t, double b)
{
- double w, x, y;
-
- gnome_print_gsave (pc);
-
- w = gnome_font_get_width_utf8 (font, text);
+ double w, x;
+ int pw, ph;
+ gnome_print_gsave (pr->pc);
+
+ pango_layout_set_font_description (pr->pl, font);
+ pango_layout_set_text (pr->pl, text, -1);
+ pango_layout_set_width (pr->pl, -1); /* ensure no line-wrapping occurs */
+ pango_layout_set_indent (pr->pl, 0);
+ pango_layout_get_size (pr->pl, &pw, &ph);
+ w = pw/(double)PANGO_SCALE;
switch (align & 3) {
case ALIGN_LEFT:
@@ -413,63 +489,68 @@
/* Make sure we don't go off the left edge. */
x = MAX (l, x);
- /* Now calculate the baseline. */
- y = t - gnome_font_get_ascender (font);
-
/* Set a clipping rectangle. */
- gnome_print_moveto (pc, l, t);
- gnome_print_lineto (pc, r, t);
- gnome_print_lineto (pc, r, b);
- gnome_print_lineto (pc, l, b);
- gnome_print_closepath (pc);
- gnome_print_clip (pc);
+ gnome_print_moveto (pr->pc, l, t);
+ gnome_print_lineto (pr->pc, r, t);
+ gnome_print_lineto (pr->pc, r, b);
+ gnome_print_lineto (pr->pc, l, b);
+ gnome_print_closepath (pr->pc);
+ gnome_print_clip (pr->pc);
+
+ gnome_print_newpath (pr->pc);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
- gnome_print_newpath (pc);
- gnome_print_moveto (pc, x, y);
- gnome_print_setfont (pc, font);
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- gnome_print_show (pc, text);
+ gnome_print_moveto (pr->pc, x, t);
+ gnome_print_pango_layout (pr->pc, pr->pl);
- gnome_print_grestore (pc);
+ gnome_print_grestore (pr->pc);
+
+ return w;
}
/* gets/frees the font for you, as a book font */
-static void
-print_text_size(GnomePrintContext *pc, const char *text,
+static double
+print_text_size(EvoCalendarPrintRenderer *pr, const char *text,
enum align_box align, double l, double r, double t, double b)
{
- GnomeFont *font;
+ PangoFontDescription *font;
+ double w;
- font = get_font_for_size (t - b, GNOME_FONT_BOOK, FALSE);
- print_text(pc, font, text, align, l, r, t, b);
- g_object_unref (font);
+ font = get_font_for_size (pr, t - b, GNOME_FONT_BOOK, FALSE);
+ w = print_text(pr, font, text, align, l, r, t, b);
+ pango_font_description_free (font);
+
+ return w;
}
/* gets/frees the font for you, as a bold font */
-static void
-print_text_size_bold(GnomePrintContext *pc, const char *text,
+static double
+print_text_size_bold(EvoCalendarPrintRenderer *pr, const char *text,
enum align_box align, double l, double r, double t, double b)
{
- GnomeFont *font;
+ PangoFontDescription *font;
+ double w;
- font = get_font_for_size (t - b, GNOME_FONT_BOLD, FALSE);
- print_text(pc, font, text, align, l, r, t, b);
- g_object_unref (font);
+ font = get_font_for_size (pr, t - b, GNOME_FONT_BOLD, FALSE);
+ w = print_text(pr, font, text, align, l, r, t, b);
+ pango_font_description_free (font);
+
+ return w;
}
static void
-titled_box (GnomePrintContext *pc, const char *text, GnomeFont *font,
+titled_box (EvoCalendarPrintRenderer *pr, const char *text, PangoFontDescription *font,
enum align_box align, double *l, double *r, double *t, double *b,
double linewidth)
{
double size;
- size = gnome_font_get_size (font);
+ size = get_font_size (font);
if (align & ALIGN_BORDER) {
- print_border (pc, *l, *r, *t, *t - size * 1.4,
+ print_border (pr->pc, *l, *r, *t, *t - size * 1.4,
linewidth, 0.9);
- print_border (pc, *l, *r, *t - size * 1.4, *b,
+ print_border (pr->pc, *l, *r, *t - size * 1.4, *b,
linewidth, -1.0);
*l += 2;
@@ -477,7 +558,7 @@
*b += 2;
}
- print_text (pc, font, text, align, *l, *r, *t, *t - size * 1.4);
+ print_text (pr, font, text, align, *l, *r, *t, *t - size * 1.4);
*t -= size * 1.4;
}
@@ -553,14 +634,14 @@
print out the month small, embolden any days with events.
*/
static void
-print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, time_t month,
+print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t month,
double left, double right, double top, double bottom,
int titleflags, time_t greystart, time_t greyend,
int bordertitle)
{
icaltimezone *zone = calendar_config_get_icaltimezone ();
ECal *client;
- GnomeFont *font, *font_bold, *font_normal;
+ PangoFontDescription *font, *font_bold, *font_normal;
time_t now, next;
int x, y;
int days[42];
@@ -576,14 +657,14 @@
/* Print the title, e.g. 'June 2001', in the top 16% of the area. */
format_date (month, titleflags, buf, 100);
header_size = (top - bottom) * 0.16;
- font = get_font_for_size (header_size, GNOME_FONT_BOLD, FALSE);
+ font = get_font_for_size (pr, header_size, GNOME_FONT_BOLD, FALSE);
if (bordertitle) {
- print_border (pc, left, right, top, top - header_size,
+ print_border (pr->pc, left, right, top, top - header_size,
1.0, 0.9);
}
- print_text (pc, font, buf, ALIGN_CENTER, left, right,
+ print_text (pr, font, buf, ALIGN_CENTER, left, right,
top, top - header_size);
- g_object_unref (font);
+ pango_font_description_free (font);
top -= header_size;
@@ -610,22 +691,22 @@
tm = *convert_timet_to_struct_tm (month, zone);
build_month (tm.tm_mon, tm.tm_year + 1900, days, 0, 0);
- font_normal = get_font_for_size (font_size, GNOME_FONT_BOOK, FALSE);
- font_bold = get_font_for_size (font_size, GNOME_FONT_BOLD, FALSE);
+ font_normal = get_font_for_size (pr, font_size, GNOME_FONT_BOOK, FALSE);
+ font_bold = get_font_for_size (pr, font_size, GNOME_FONT_BOLD, FALSE);
/* Get a reasonable estimate of the largest number we will need,
and use it to calculate the offset from the right edge of the
cell that we should put the numbers. */
- w = gnome_font_get_width_utf8 (font_bold, "23");
+ w = evo_calendar_print_renderer_get_width (pr, font_bold, "23");
text_xpad = (col_width - w) / 2;
- gnome_print_setrgbcolor (pc, 0, 0, 0);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
/* Print the abbreviated day names across the top in bold. */
week_start_day = calendar_config_get_week_start_day ();
weekday = week_start_day;
for (x = 0; x < 7; x++) {
- print_text (pc, font_bold, _(daynames[weekday]), ALIGN_CENTER,
+ print_text (pr, font_bold, _(daynames[weekday]), ALIGN_CENTER,
left + x * col_width, left + (x + 1) * col_width,
top, top - row_height * 1.4);
weekday = (weekday + 1) % 7;
@@ -665,12 +746,12 @@
next = time_add_day_with_zone (now, 1, zone);
if ((now >= greystart && now < greyend)
|| (greystart >= now && greystart < next)) {
- print_border (pc,
+ print_border (pr->pc,
cell_left, cell_right,
cell_top, cell_bottom,
-1.0, 0.75);
}
- print_text (pc, font, buf, ALIGN_RIGHT,
+ print_text (pr, font, buf, ALIGN_RIGHT,
cell_left, text_right,
cell_top, cell_bottom);
@@ -678,119 +759,53 @@
}
}
}
- g_object_unref (font_normal);
- g_object_unref (font_bold);
+ pango_font_description_free (font_normal);
+ pango_font_description_free (font_bold);
}
-
/* wraps text into the print context, not taking up more than its allowed space */
static double
-bound_text(GnomePrintContext *pc, GnomeFont *font, const char *text,
+bound_text(EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char *text,
double left, double right, double top, double bottom, double indent)
{
- double maxwidth = right-left;
- double width;
- const char *p;
- char *wordstart;
- int c;
- char *outbuffer, *o, *outbuffendmarker;
- int outbufflen;
- int dump=0;
- int first=1;
-
- g_return_val_if_fail(text!=NULL, top);
-
- if (top<bottom) {
- /* too much to fit in appointment printout */
- return top;
- }
-
- outbufflen = 1024;
- outbuffer = g_malloc(outbufflen);
- outbuffendmarker = outbuffer+outbufflen-2;
-
- top -= gnome_font_get_size (font);
- gnome_print_setfont (pc, font);
-
- width=0;
- p = text;
- wordstart = outbuffer;
- o = outbuffer;
- while ((c=*p)) {
- if (c=='\n') {
- wordstart=o;
- dump=1;
- } else {
- /* grow output buffer if required */
- if (o>=outbuffendmarker) {
- char *newbuf;
- outbufflen*=2;
- newbuf = g_realloc(outbuffer, outbufflen);
- o = newbuf+(o-outbuffer);
- wordstart = newbuf+(o-outbuffer);
- outbuffer = newbuf;
- outbuffendmarker = outbuffer+outbufflen-2;
- }
- *o++=c;
- if (c==' ')
- wordstart = o;
-
- dump=0;
- if (g_utf8_validate (p, strlen(p), NULL)) {
- width+=gnome_font_get_glyph_width(font, gnome_font_lookup_default (font, c));
- if (width>maxwidth) {
- o--;
- p--;
- dump=1;
- }
- }
- }
- if (dump) {
- if (wordstart==outbuffer)
- wordstart=o;
- c=*wordstart;
- *wordstart=0;
- gnome_print_moveto(pc, left, top);
- gnome_print_show(pc, outbuffer);
- *wordstart=c;
- memcpy(outbuffer, wordstart, o-wordstart);
- width = gnome_font_get_width_utf8_sized(font, outbuffer, o-wordstart);
- o=outbuffer+(o-wordstart);
- wordstart = outbuffer;
- top -= gnome_font_get_size (font);
- if (top<bottom) {
- /* too much to fit, drop the rest */
- g_free(outbuffer);
- return top;
- }
- if (first) {
- left += indent;
- maxwidth -= indent;
- first=0;
- }
- }
- p++;
- }
- if (dump==0) {
- *o=0;
- gnome_print_moveto(pc, left, top);
- gnome_print_show(pc, outbuffer);
- top -= gnome_font_get_size (font);
- }
- g_free(outbuffer);
+ /* Let Pango do all the work: */
+ int w, h;
+
+ gnome_print_gsave (pr->pc);
+
+ /* Set a clipping rectangle. */
+ gnome_print_moveto (pr->pc, left, top);
+ gnome_print_lineto (pr->pc, right, top);
+ gnome_print_lineto (pr->pc, right, bottom);
+ gnome_print_lineto (pr->pc, left, bottom);
+ gnome_print_closepath (pr->pc);
+ gnome_print_clip (pr->pc);
+
+ gnome_print_newpath (pr->pc);
+
+ pango_layout_set_font_description (pr->pl, font);
+ pango_layout_set_text (pr->pl, text, -1);
+ pango_layout_set_indent (pr->pl, indent * PANGO_SCALE);
+ pango_layout_set_width (pr->pl, (right-left)*PANGO_SCALE);
+ gnome_print_moveto (pr->pc, left, top);
+ gnome_print_pango_layout (pr->pc, pr->pl);
+
+ gnome_print_grestore (pr->pc);
+
+ pango_layout_get_size (pr->pl, &w, &h);
- return top;
+ return top - (double)h/(double)PANGO_SCALE;
}
/* Draw the borders, lines, and times down the left of the day view. */
static void
-print_day_background (GnomePrintContext *pc, GnomeCalendar *gcal,
+print_day_background (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal,
time_t whence, struct pdinfo *pdi,
double left, double right, double top, double bottom)
{
- GnomeFont *font_hour, *font_minute;
+ PangoFontDescription *font_hour, *font_minute;
double yinc, y;
double width = DAY_VIEW_TIME_COLUMN_WIDTH;
double font_size, max_font_size, hour_font_size, minute_font_size;
@@ -798,19 +813,20 @@
const char *minute;
gboolean use_24_hour;
int i, hour, row;
+ double hour_minute_x;
/* Fill the time column in light-gray. */
- print_border (pc, left, left + width, top, bottom, -1.0, 0.9);
+ print_border (pr->pc, left, left + width, top, bottom, -1.0, 0.9);
/* Draw the border around the entire view. */
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- print_border (pc, left, right, top, bottom, 1.0, -1.0);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
+ print_border (pr->pc, left, right, top, bottom, 1.0, -1.0);
/* Draw the vertical line on the right of the time column. */
- gnome_print_setlinewidth (pc, 0.0);
- gnome_print_moveto (pc, left + width, bottom);
- gnome_print_lineto (pc, left + width, top);
- gnome_print_stroke (pc);
+ gnome_print_setlinewidth (pr->pc, 0.0);
+ gnome_print_moveto (pr->pc, left + width, bottom);
+ gnome_print_lineto (pr->pc, left + width, top);
+ gnome_print_stroke (pr->pc);
/* Calculate the row height. */
yinc = (top - bottom) / (pdi->end_hour - pdi->start_hour);
@@ -819,19 +835,20 @@
font_size = yinc * 0.6;
max_font_size = width * 0.5;
hour_font_size = MIN (font_size, max_font_size);
- font_hour = get_font_for_size (hour_font_size, GNOME_FONT_BOLD, FALSE);
+ font_hour = get_font_for_size (pr, hour_font_size, GNOME_FONT_BOLD, FALSE);
font_size = yinc * 0.33;
max_font_size = width * 0.25;
minute_font_size = MIN (font_size, max_font_size);
- font_minute = get_font_for_size (minute_font_size, GNOME_FONT_BOLD, FALSE);
+ font_minute = get_font_for_size (pr, minute_font_size, GNOME_FONT_BOLD, FALSE);
use_24_hour = calendar_config_get_24_hour_format ();
row = 0;
+ hour_minute_x = left + width * 0.58;
for (i = pdi->start_hour; i < pdi->end_hour; i++) {
y = top - yinc * (row + 1);
- gnome_print_setrgbcolor (pc, 0, 0, 0);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
if (use_24_hour) {
hour = i;
@@ -849,30 +866,30 @@
/* the hour label/minute */
sprintf (buf, "%d", hour);
- print_text (pc, font_hour, buf, ALIGN_RIGHT,
- left, left + width * 0.58,
+ print_text (pr, font_hour, buf, ALIGN_RIGHT,
+ left, hour_minute_x,
y + yinc - 4, y + yinc - 4 - hour_font_size);
- print_text (pc, font_minute, minute, ALIGN_RIGHT,
- left, left + width - 3,
+ print_text (pr, font_minute, minute, ALIGN_LEFT,
+ hour_minute_x, left + width - 3,
y + yinc - 3, y + yinc - 3 - minute_font_size);
/* Draw the horizontal line between hours, across the entire
width of the day view. */
- gnome_print_moveto (pc, left, y);
- gnome_print_lineto (pc, right, y);
- gnome_print_stroke (pc);
+ gnome_print_moveto (pr->pc, left, y);
+ gnome_print_lineto (pr->pc, right, y);
+ gnome_print_stroke (pr->pc);
/* Draw the horizontal line for the 1/2-hours, across the
entire width except for part of the time column. */
- gnome_print_moveto (pc, left + width * 0.6, y + yinc / 2);
- gnome_print_lineto (pc, right, y + yinc / 2);
- gnome_print_stroke (pc);
+ gnome_print_moveto (pr->pc, left + width * 0.6, y + yinc / 2);
+ gnome_print_lineto (pr->pc, right, y + yinc / 2);
+ gnome_print_stroke (pr->pc);
row++;
}
- g_object_unref (font_hour);
- g_object_unref (font_minute);
+ pango_font_description_free (font_hour);
+ pango_font_description_free (font_minute);
}
@@ -984,7 +1001,7 @@
static void
-print_day_long_event (GnomePrintContext *pc, GnomeFont *font,
+print_day_long_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font,
double left, double right, double top, double bottom,
double row_height, EDayViewEvent *event,
struct pdinfo *pdi, ECalModel *model)
@@ -1014,7 +1031,7 @@
y2 = y1 - row_height + 4;
red = green = blue = 0.95;
e_cal_model_get_rgb_color_for_component (model, event->comp_data, &red, &green, &blue);
- print_border_with_triangles (pc, x1, x2, y1, y2, 0.5, red, green, blue,
+ print_border_with_triangles (pr->pc, x1, x2, y1, y2, 0.5, red, green, blue,
left_triangle_width,
right_triangle_width);
@@ -1033,8 +1050,7 @@
buffer, sizeof (buffer));
x1 += 4;
- print_text (pc, font, buffer, ALIGN_LEFT, x1, x2, y1, y2);
- x1 += gnome_font_get_width_utf8 (font, buffer);
+ x1 += print_text (pr, font, buffer, ALIGN_LEFT, x1, x2, y1, y2);
}
/* If the event ends before the end of the last day being printed,
@@ -1052,8 +1068,7 @@
buffer, sizeof (buffer));
x2 -= 4;
- print_text (pc, font, buffer, ALIGN_RIGHT, x1, x2, y1, y2);
- x2 -= gnome_font_get_width_utf8 (font, buffer);
+ x2 -= print_text (pr, font, buffer, ALIGN_RIGHT, x1, x2, y1, y2);
}
/* Print the text. */
@@ -1062,12 +1077,12 @@
x1 += 4;
x2 -= 4;
- print_text (pc, font, text, ALIGN_CENTER, x1, x2, y1, y2);
+ print_text (pr, font, text, ALIGN_CENTER, x1, x2, y1, y2);
}
static void
-print_day_event (GnomePrintContext *pc, GnomeFont *font,
+print_day_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font,
double left, double right, double top, double bottom,
EDayViewEvent *event, struct pdinfo *pdi, ECalModel *model)
{
@@ -1110,7 +1125,7 @@
red = green = blue = 0.95;
e_cal_model_get_rgb_color_for_component (model, event->comp_data, &red, &green, &blue);
- print_border_rgb (pc, x1, x2, y1, y2, 1.0, red, green, blue);
+ print_border_rgb (pr->pc, x1, x2, y1, y2, 1.0, red, green, blue);
summary = icalcomponent_get_summary (event->comp_data->icalcomp);
text = summary ? (char*) summary : "";
@@ -1140,7 +1155,7 @@
free_text = TRUE;
}
- bound_text (pc, font, text, x1 + 2, x2 - 2, y1, y2, 0);
+ bound_text (pr, font, text, x1 + 2, x2 - 2, y1, y2, 0);
if (free_text)
g_free (text);
@@ -1148,12 +1163,12 @@
static void
-print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
+print_day_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t whence,
double left, double right, double top, double bottom)
{
icaltimezone *zone = calendar_config_get_icaltimezone ();
EDayViewEvent *event;
- GnomeFont *font;
+ PangoFontDescription *font;
time_t start, end;
struct pdinfo pdi;
gint rows_in_top_display, i;
@@ -1213,13 +1228,13 @@
pdi.day_starts, &rows_in_top_display);
/* Print the long events. */
- font = get_font_for_size (12, GNOME_FONT_BOOK, FALSE);
+ font = get_font_for_size (pr, 12, GNOME_FONT_BOOK, FALSE);
for (i = 0; i < pdi.long_events->len; i++) {
event = &g_array_index (pdi.long_events, EDayViewEvent, i);
- print_day_long_event (pc, font, left, right, top, bottom,
+ print_day_long_event (pr, font, left, right, top, bottom,
DAY_VIEW_ROW_HEIGHT, event, &pdi, model);
}
- g_object_unref (font);
+ pango_font_description_free (font);
/* We always leave space for DAY_VIEW_MIN_ROWS_IN_TOP_DISPLAY in the
top display, but we may have more rows than that, in which case
@@ -1228,8 +1243,8 @@
DAY_VIEW_MIN_ROWS_IN_TOP_DISPLAY);
/* Draw the border around the long events. */
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- print_border (pc, left, right,
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
+ print_border (pr->pc, left, right,
top, top - rows_in_top_display * DAY_VIEW_ROW_HEIGHT - 4,
1.0, -1.0);
@@ -1237,7 +1252,7 @@
top -= rows_in_top_display * DAY_VIEW_ROW_HEIGHT + 4;
/* Draw the borders, lines, and times down the left. */
- print_day_background (pc, gcal, whence, &pdi,
+ print_day_background (pr, gcal, whence, &pdi,
left, right, top, bottom);
/* Now adjust to get rid of the time column. */
@@ -1250,13 +1265,13 @@
/* Print the short events. */
max_font_size = ((top - bottom) / pdi.rows) - 4;
font_size = MIN (DAY_NORMAL_FONT_SIZE, max_font_size);
- font = get_font_for_size (font_size, GNOME_FONT_BOOK, FALSE);
+ font = get_font_for_size (pr, font_size, GNOME_FONT_BOOK, FALSE);
for (i = 0; i < pdi.events[0]->len; i++) {
event = &g_array_index (pdi.events[0], EDayViewEvent, i);
- print_day_event (pc, font, left, right, top, bottom,
+ print_day_event (pr, font, left, right, top, bottom,
event, &pdi, model);
}
- g_object_unref (font);
+ pango_font_description_free (font);
/* Free everything. */
free_event_array (pdi.long_events);
@@ -1285,7 +1300,7 @@
static void
-print_week_long_event (GnomePrintContext *pc, GnomeFont *font,
+print_week_long_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font,
struct psinfo *psi,
double x1, double x2, double y1, double y2,
EWeekViewEvent *event, EWeekViewEventSpan *span,
@@ -1305,7 +1320,7 @@
if (event->end > psi->day_starts[span->start_day + span->num_days])
right_triangle_width = 4;
- print_border_with_triangles (pc, x1, x2, y1, y2, 0.5, red, green, blue,
+ print_border_with_triangles (pr->pc, x1, x2, y1, y2, 0.5, red, green, blue,
left_triangle_width,
right_triangle_width);
@@ -1324,8 +1339,7 @@
buffer, sizeof (buffer));
x1 += 4;
- print_text_size (pc, buffer, ALIGN_LEFT, x1, x2, y1, y2);
- x1 += gnome_font_get_width_utf8 (font, buffer);
+ x1 += print_text_size (pr, buffer, ALIGN_LEFT, x1, x2, y1, y2);
}
/* If the event ends before the end of the last day being printed,
@@ -1343,18 +1357,17 @@
buffer, sizeof (buffer));
x2 -= 4;
- print_text_size (pc, buffer, ALIGN_RIGHT, x1, x2, y1, y2);
- x2 -= gnome_font_get_width_utf8 (font, buffer);
+ x2 -= print_text_size (pr, buffer, ALIGN_RIGHT, x1, x2, y1, y2);
}
x1 += 4;
x2 -= 4;
- print_text_size (pc, text, ALIGN_CENTER, x1, x2, y1, y2);
+ print_text_size (pr, text, ALIGN_CENTER, x1, x2, y1, y2);
}
static void
-print_week_day_event (GnomePrintContext *pc, GnomeFont *font,
+print_week_day_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font,
struct psinfo *psi,
double x1, double x2, double y1, double y2,
EWeekViewEvent *event, EWeekViewEventSpan *span,
@@ -1374,15 +1387,14 @@
e_time_format_time (&date_tm, psi->use_24_hour_format, FALSE,
buffer, sizeof (buffer));
- print_rectangle (pc, x1, x2, y1, y2, red, green, blue);
- print_text_size (pc, buffer, ALIGN_LEFT, x1, x2, y1, y2);
- x1 += gnome_font_get_width_utf8 (font, buffer) + 4;
- print_text_size (pc, text, ALIGN_LEFT, x1, x2, y1, y2);
+ print_rectangle (pr->pc, x1, x2, y1, y2, red, green, blue);
+ x1 += print_text_size (pr, buffer, ALIGN_LEFT, x1, x2, y1, y2) + 4;
+ print_text_size (pr, text, ALIGN_LEFT, x1, x2, y1, y2);
}
static void
-print_week_event (GnomePrintContext *pc, GnomeFont *font,
+print_week_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font,
struct psinfo *psi,
double left, double top,
double cell_width, double cell_height,
@@ -1448,11 +1460,11 @@
e_cal_model_get_rgb_color_for_component (model, event->comp_data, &red, &green, &blue);
if (print_is_one_day_week_event (event, span,
psi->day_starts)) {
- print_week_day_event (pc, font, psi,
+ print_week_day_event (pr, font, psi,
x1, x2, y1, y2,
event, span, text, red, green, blue);
} else {
- print_week_long_event (pc, font, psi,
+ print_week_long_event (pr, font, psi,
x1, x2, y1, y2,
event, span, text, red, green, blue);
}
@@ -1462,7 +1474,7 @@
static void
-print_week_view_background (GnomePrintContext *pc, GnomeFont *font,
+print_week_view_background (EvoCalendarPrintRenderer *pr, PangoFontDescription *font,
struct psinfo *psi,
double left, double top,
double cell_width, double cell_height)
@@ -1473,7 +1485,7 @@
struct tm tm;
char *format_string, buffer[128];
- font_size = gnome_font_get_size (font);
+ font_size = get_font_size (font);
for (day = 0; day < psi->days_shown; day++) {
e_week_view_layout_get_day_position
@@ -1494,7 +1506,7 @@
if (psi->multi_week_view && (tm.tm_mon != psi->month))
fillcolor = 0.9;
- print_border (pc, x1, x2, y1, y2, 1.0, fillcolor);
+ print_border (pr->pc, x1, x2, y1, y2, 1.0, fillcolor);
if (psi->multi_week_view) {
if (tm.tm_mday == 1)
@@ -1502,13 +1514,13 @@
else
format_string = "%d";
} else {
- gnome_print_moveto (pc, x1 + 0.1 * cell_width,
+ gnome_print_moveto (pr->pc, x1 + 0.1 * cell_width,
y1 - psi->header_row_height + 3);
- gnome_print_lineto (pc, x2,
+ gnome_print_lineto (pr->pc, x2,
y1 - psi->header_row_height + 3);
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- gnome_print_setlinewidth (pc, 0.5);
- gnome_print_stroke (pc);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
+ gnome_print_setlinewidth (pr->pc, 0.5);
+ gnome_print_stroke (pr->pc);
/* strftime format %A = full weekday name, %d = day of
month, %B = full month name. You can change the
@@ -1519,7 +1531,7 @@
}
e_utf8_strftime (buffer, sizeof (buffer), format_string, &tm);
- print_text_size (pc, buffer, ALIGN_RIGHT,
+ print_text_size (pr, buffer, ALIGN_RIGHT,
x1, x2 - 4, y1 - 2, y1 - 2 - font_size);
}
}
@@ -1571,7 +1583,7 @@
}
static void
-print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal,
+print_week_summary (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal,
time_t whence, gboolean multi_week_view, int weeks_shown,
int month, double font_size,
double left, double right, double top, double bottom)
@@ -1582,7 +1594,7 @@
time_t day_start;
gint rows_per_day[E_WEEK_VIEW_MAX_WEEKS * 7], day, event_num;
GArray *spans;
- GnomeFont *font;
+ PangoFontDescription *font;
double cell_width, cell_height;
ECalModel *model = gnome_calendar_get_calendar_model (gcal);
@@ -1648,20 +1660,20 @@
psi.rows_per_compressed_cell = (cell_height - psi.header_row_height)
/ psi.row_height;
- font = get_font_for_size (font_size, GNOME_FONT_BOOK, FALSE);
+ font = get_font_for_size (pr, font_size, GNOME_FONT_BOOK, FALSE);
/* Draw the grid and the day names/numbers. */
- print_week_view_background (pc, font, &psi, left, top,
+ print_week_view_background (pr, font, &psi, left, top,
cell_width, cell_height);
/* Print the events. */
for (event_num = 0; event_num < psi.events->len; event_num++) {
event = &g_array_index (psi.events, EWeekViewEvent, event_num);
- print_week_event (pc, font, &psi, left, top,
+ print_week_event (pr, font, &psi, left, top,
cell_width, cell_height, model, event, spans);
}
- g_object_unref (font);
+ pango_font_description_free (font);
/* Free everything. */
for (event_num = 0; event_num < psi.events->len; event_num++) {
@@ -1673,7 +1685,7 @@
static void
-print_year_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
+print_year_summary (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t whence,
double left, double right, double top, double bottom,
int morerows)
{
@@ -1707,7 +1719,7 @@
for (col = 0; col < cols; col++) {
l = left + col_width * col;
r = l + col_width;
- print_month_small (pc, gcal, now,
+ print_month_small (pr, gcal, now,
l + 8, r - 8, t - 8, b + 8,
DATE_MONTH, 0, 0, TRUE);
now = time_add_month_with_zone (now, 1, zone);
@@ -1716,7 +1728,7 @@
}
static void
-print_month_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
+print_month_summary (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t whence,
double left, double right, double top, double bottom)
{
icaltimezone *zone = calendar_config_get_icaltimezone ();
@@ -1724,7 +1736,7 @@
struct tm tm;
struct icaltimetype tt;
char buffer[100];
- GnomeFont *font;
+ PangoFontDescription *font;
gboolean compress_weekend;
int columns, col, weekday, len, month;
double font_size, cell_width, x1, x2, y1, y2;
@@ -1754,9 +1766,8 @@
tm = *convert_timet_to_struct_tm (date, zone);
tm.tm_mday = (tm.tm_mday % 7) + 7;
- font = get_font_for_size (MONTH_NORMAL_FONT_SIZE, GNOME_FONT_BOLD, FALSE);
- font_size = gnome_font_get_size (font);
- gnome_print_setfont (pc, font);
+ font = get_font_for_size (pr, MONTH_NORMAL_FONT_SIZE, GNOME_FONT_BOLD, FALSE);
+ font_size = get_font_size (font);
columns = compress_weekend ? 6 : 7;
cell_width = (right - left) / columns;
@@ -1778,28 +1789,28 @@
x1 = left + cell_width * col;
x2 = x1 + cell_width;
- print_border (pc, x1, x2, y1, y2, 1.0, -1.0);
- print_text_size (pc, buffer, ALIGN_CENTER, x1, x2, y1, y2);
+ print_border (pr->pc, x1, x2, y1, y2, 1.0, -1.0);
+ print_text_size (pr, buffer, ALIGN_CENTER, x1, x2, y1, y2);
tm.tm_mday++;
tm.tm_wday = (tm.tm_wday + 1) % 7;
}
- g_object_unref (font);
+ pango_font_description_free (font);
top = y2;
- print_week_summary (pc, gcal, date, TRUE, 6, month,
+ print_week_summary (pr, gcal, date, TRUE, 6, month,
MONTH_NORMAL_FONT_SIZE,
left, right, top, bottom);
}
static void
-print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
+print_todo_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal,
time_t start, time_t end,
double left, double right, double top, double bottom)
{
ECal *client;
- GnomeFont *font_summary;
+ PangoFontDescription *font_summary;
double y, yend, x, xend;
struct icaltimetype *tt;
ECalendarTable *task_pad;
@@ -1814,12 +1825,12 @@
model = e_calendar_table_get_model (task_pad);
client = e_cal_model_get_default_client (model);
- font_summary = get_font_for_size (10, GNOME_FONT_BOOK, FALSE);
+ font_summary = get_font_for_size (pr, 10, GNOME_FONT_BOOK, FALSE);
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- gnome_print_setlinewidth (pc, 0.0);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
+ gnome_print_setlinewidth (pr->pc, 0.0);
- titled_box (pc, _("Tasks"), font_summary, ALIGN_CENTER | ALIGN_BORDER,
+ titled_box (pr, _("Tasks"), font_summary, ALIGN_CENTER | ALIGN_BORDER,
&left, &right, &top, &bottom, 1.0);
y = top - 3;
@@ -1853,33 +1864,34 @@
break;
/* Print the box to put the tick in. */
- print_border (pc, x + 2, x + 8, y - 3, y - 11, 0.1, -1.0);
+ print_border (pr->pc, x + 2, x + 8, y - 3, y - 11, 0.1, -1.0);
/* If the task is complete, print a tick in the box. */
e_cal_component_get_completed (comp, &tt);
if (tt) {
e_cal_component_free_icaltimetype (tt);
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- gnome_print_setlinewidth (pc, 1.0);
- gnome_print_moveto (pc, x + 3, y - 8);
- gnome_print_lineto (pc, x + 5, y - 10);
- gnome_print_lineto (pc, x + 7, y - 3.5);
- gnome_print_stroke (pc);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
+ gnome_print_setlinewidth (pr->pc, 1.0);
+ gnome_print_moveto (pr->pc, x + 3, y - 8);
+ gnome_print_lineto (pr->pc, x + 5, y - 10);
+ gnome_print_lineto (pr->pc, x + 7, y - 3.5);
+ gnome_print_stroke (pr->pc);
}
- y = bound_text (pc, font_summary, summary.value,
+ y = bound_text (pr, font_summary, summary.value,
x + 10, xend, y, yend, 0);
- y += gnome_font_get_size (font_summary) - 6;
- gnome_print_moveto (pc, x, y);
- gnome_print_lineto (pc, xend, y);
- gnome_print_stroke (pc);
+
+ y += get_font_size (font_summary) - 12;
+ gnome_print_moveto (pr->pc, x, y);
+ gnome_print_lineto (pr->pc, xend, y);
+ gnome_print_stroke (pr->pc);
y -= 3;
g_object_unref (comp);
}
- g_object_unref (font_summary);
+ pango_font_description_free (font_summary);
}
@@ -1981,7 +1993,7 @@
static void
-print_day_view (GnomePrintContext *pc, GnomeCalendar *gcal, time_t date,
+print_day_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date,
double left, double right, double top, double bottom)
{
icaltimezone *zone = calendar_config_get_icaltimezone ();
@@ -1993,29 +2005,29 @@
todo = (right - left) * 0.75 + left;
header = top - HEADER_HEIGHT;
- gnome_print_beginpage (pc, NULL);
+ gnome_print_beginpage (pr->pc, NULL);
/* Print the main view with all the events in. */
- print_day_details (pc, gcal, date,
+ print_day_details (pr, gcal, date,
left, todo - 2.0, header, bottom);
/* Print the TaskPad down the right. */
- print_todo_details (pc, gcal, 0, INT_MAX,
+ print_todo_details (pr, gcal, 0, INT_MAX,
todo, right, header, bottom);
/* Print the filled border around the header. */
- print_border (pc, left, right, top, header + 2.0, 1.0, 0.9);
+ print_border (pr->pc, left, right, top, header + 2.0, 1.0, 0.9);
/* Print the 2 mini calendar-months. */
l = right - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2
- SMALL_MONTH_SPACING;
- print_month_small (pc, gcal, date,
+ print_month_small (pr, gcal, date,
l, l + SMALL_MONTH_WIDTH,
top - 4, header + 4,
DATE_MONTH | DATE_YEAR, date, date, FALSE);
l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH;
- print_month_small (pc, gcal,
+ print_month_small (pr, gcal,
time_add_month_with_zone (date, 1, zone),
l, l + SMALL_MONTH_WIDTH,
top - 4, header + 4,
@@ -2024,22 +2036,22 @@
/* Print the date, e.g. '8th May, 2001'. */
format_date (date, DATE_DAY | DATE_MONTH | DATE_YEAR,
buf, 100);
- print_text_size_bold (pc, buf, ALIGN_LEFT,
+ print_text_size_bold (pr, buf, ALIGN_LEFT,
left + 4, todo, top - 4, top - 4 - 24);
/* Print the day, e.g. 'Tuesday'. */
format_date (date, DATE_DAYNAME, buf, 100);
- print_text_size_bold (pc, buf, ALIGN_LEFT,
+ print_text_size_bold (pr, buf, ALIGN_LEFT,
left + 4, todo, top - 32, top - 32 - 18);
- gnome_print_showpage (pc);
+ gnome_print_showpage (pr->pc);
date = time_add_day_with_zone (date, 1, zone);
}
}
static void
-print_week_view (GnomePrintContext *pc, GnomeCalendar *gcal, time_t date,
+print_week_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date,
double left, double right, double top, double bottom)
{
icaltimezone *zone = calendar_config_get_icaltimezone ();
@@ -2051,7 +2063,7 @@
header = top - HEADER_HEIGHT;
- gnome_print_beginpage (pc, NULL);
+ gnome_print_beginpage (pr->pc, NULL);
tm = *convert_timet_to_struct_tm (date, zone);
week_start_day = calendar_config_get_week_start_day ();
@@ -2066,27 +2078,27 @@
}
/* Print the main week view. */
- print_week_summary (pc, gcal, when, FALSE, 1, 0,
+ print_week_summary (pr, gcal, when, FALSE, 1, 0,
WEEK_NORMAL_FONT_SIZE,
left, right, header, bottom);
/* Print the border around the main view. */
- print_border (pc, left, right, header, bottom, 1.0, -1.0);
+ print_border (pr->pc, left, right, header, bottom, 1.0, -1.0);
/* Print the border around the header area. */
- print_border (pc, left, right, top, header + 2.0, 1.0, 0.9);
+ print_border (pr->pc, left, right, top, header + 2.0, 1.0, 0.9);
/* Print the 2 mini calendar-months. */
l = right - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2
- SMALL_MONTH_SPACING;
- print_month_small (pc, gcal, when,
+ print_month_small (pr, gcal, when,
l, l + SMALL_MONTH_WIDTH,
top - 4, header + 4,
DATE_MONTH | DATE_YEAR, when,
time_add_week_with_zone (when, 1, zone), FALSE);
l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH;
- print_month_small (pc, gcal,
+ print_month_small (pr, gcal,
time_add_month_with_zone (when, 1, zone),
l, l + SMALL_MONTH_WIDTH,
top - 4, header + 4,
@@ -2095,21 +2107,21 @@
/* Print the start day of the week, e.g. '7th May 2001'. */
format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100);
- print_text_size_bold (pc, buf, ALIGN_LEFT,
+ print_text_size_bold (pr, buf, ALIGN_LEFT,
left + 3, right, top - 4, top - 4 - 24);
/* Print the end day of the week, e.g. '13th May 2001'. */
when = time_add_day_with_zone (when, 6, zone);
format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100);
- print_text_size_bold (pc, buf, ALIGN_LEFT,
+ print_text_size_bold (pr, buf, ALIGN_LEFT,
left + 3, right, top - 24 - 3, top - 24 - 3 - 24);
- gnome_print_showpage (pc);
+ gnome_print_showpage (pr->pc);
}
static void
-print_month_view (GnomePrintContext *pc, GnomeCalendar *gcal, time_t date,
+print_month_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date,
double left, double right, double top, double bottom)
{
icaltimezone *zone = calendar_config_get_icaltimezone ();
@@ -2118,21 +2130,21 @@
header = top - HEADER_HEIGHT;
- gnome_print_beginpage (pc, NULL);
+ gnome_print_beginpage (pr->pc, NULL);
/* Print the main month view. */
- print_month_summary (pc, gcal, date, left, right, header, bottom);
+ print_month_summary (pr, gcal, date, left, right, header, bottom);
/* Print the border around the header. */
- print_border (pc, left, right, top, header, 1.0, 0.9);
+ print_border (pr->pc, left, right, top, header, 1.0, 0.9);
/* Print the 2 mini calendar-months. */
- print_month_small (pc, gcal,
+ print_month_small (pr, gcal,
time_add_month_with_zone (date, 1, zone),
right - (right - left) / 7 + 2, right - 8,
top - 4, header,
DATE_MONTH | DATE_YEAR, 0, 0, FALSE);
- print_month_small (pc, gcal,
+ print_month_small (pr, gcal,
time_add_month_with_zone (date, -1, zone),
left + 8, left + (right - left) / 7 - 2,
top - 4, header,
@@ -2140,30 +2152,30 @@
/* Print the month, e.g. 'May 2001'. */
format_date (date, DATE_MONTH | DATE_YEAR, buf, 100);
- print_text_size_bold (pc, buf, ALIGN_CENTER,
+ print_text_size_bold (pr, buf, ALIGN_CENTER,
left + 3, right - 3, top - 3, top - 3 - 24);
- gnome_print_showpage (pc);
+ gnome_print_showpage (pr->pc);
}
static void
-print_year_view (GnomePrintContext *pc, GnomeCalendar *gcal, time_t date,
+print_year_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date,
double left, double right, double top, double bottom)
{
char buf[100];
- gnome_print_beginpage (pc, NULL);
+ gnome_print_beginpage (pr->pc, NULL);
- print_year_summary (pc, gcal, date, left, right, top - 50, bottom,
+ print_year_summary (pr, gcal, date, left, right, top - 50, bottom,
TRUE);
/* centered title */
format_date (date, DATE_YEAR, buf, 100);
- print_text_size_bold (pc, buf, ALIGN_CENTER,
+ print_text_size_bold (pr, buf, ALIGN_CENTER,
left+3, right, top-3, top - 27);
- gnome_print_showpage (pc);
+ gnome_print_showpage (pr->pc);
}
static void
@@ -2206,7 +2218,7 @@
}
static void
-print_date_label (GnomePrintContext *pc, ECalComponent *comp, ECal *client,
+print_date_label (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client,
double left, double right, double top, double bottom)
{
icaltimezone *start_zone, *end_zone, *due_zone, *completed_zone;
@@ -2274,15 +2286,15 @@
write_label_piece (due, buffer, 1024, _("Due "), NULL);
}
- print_text_size_bold (pc, buffer, ALIGN_LEFT,
+ print_text_size_bold (pr, buffer, ALIGN_LEFT,
left, right, top, top - 15);
}
static void
-print_comp_item (GnomePrintContext *pc, ECalComponent *comp, ECal *client,
+print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client,
double left, double right, double top, double bottom)
{
- GnomeFont *font;
+ PangoFontDescription *font;
ECalComponentVType vtype;
ECalComponentText text;
GSList *desc, *l;
@@ -2301,24 +2313,24 @@
else
return;
- gnome_print_beginpage (pc, NULL);
+ gnome_print_beginpage (pr->pc, NULL);
/* Print the title in a box at the top of the page. */
- font = get_font_for_size (18, GNOME_FONT_BOLD, FALSE);
+ font = get_font_for_size (pr, 18, GNOME_FONT_BOLD, FALSE);
header_size = 50;
- print_border (pc, left, right, top, top - header_size,
+ print_border (pr->pc, left, right, top, top - header_size,
1.0, 0.9);
- print_text (pc, font, title, ALIGN_CENTER, left, right,
+ print_text (pr, font, title, ALIGN_CENTER, left, right,
top - header_size * 0.1, top - header_size);
- g_object_unref (font);
+ pango_font_description_free (font);
top -= header_size + 10;
/* Summary */
- font = get_font_for_size (18, GNOME_FONT_BOLD, FALSE);
+ font = get_font_for_size (pr, 18, GNOME_FONT_BOLD, FALSE);
e_cal_component_get_summary (comp, &text);
summary_string = g_strdup_printf (_("Summary: %s"), text.value);
- top = bound_text (pc, font, summary_string, left, right,
+ top = bound_text (pr, font, summary_string, left, right,
top - 3, bottom, 0);
g_free (summary_string);
@@ -2327,17 +2339,17 @@
if (location && location[0]) {
location_string = g_strdup_printf (_("Location: %s"),
location);
- top = bound_text (pc, font, location_string, left, right,
+ top = bound_text (pr, font, location_string, left, right,
top - 3, bottom, 0);
g_free (location_string);
}
- g_object_unref (font);
+ pango_font_description_free (font);
/* Date information */
- print_date_label (pc, comp, client, left, right, top-3, top - 15);
+ print_date_label (pr, comp, client, left, right, top-3, top - 15);
top -= 20;
- font = get_font_for_size (12, GNOME_FONT_BOOK, FALSE);
+ font = get_font_for_size (pr, 12, GNOME_FONT_BOOK, FALSE);
/* For a VTODO we print the Status, Priority, % Complete and URL. */
if (vtype == E_CAL_COMPONENT_TODO) {
@@ -2370,9 +2382,9 @@
if (status_string) {
char *text = g_strdup_printf (_("Status: %s"),
status_string);
- top = bound_text (pc, font, text,
+ top = bound_text (pr, font, text,
left, right, top, bottom, 0);
- top += gnome_font_get_size (font) - 6;
+ top += get_font_size (font) - 6;
g_free (text);
}
}
@@ -2386,9 +2398,9 @@
e_cal_component_free_priority (priority);
text = g_strdup_printf (_("Priority: %s"), priority_string);
- top = bound_text (pc, font, text,
+ top = bound_text (pr, font, text,
left, right, top, bottom, 0);
- top += gnome_font_get_size (font) - 6;
+ top += get_font_size (font) - 6;
g_free (text);
}
@@ -2400,9 +2412,9 @@
percent_string = g_strdup_printf (_("Percent Complete: %i"), *percent);
e_cal_component_free_percent (percent);
- top = bound_text (pc, font, percent_string,
+ top = bound_text (pr, font, percent_string,
left, right, top, bottom, 0);
- top += gnome_font_get_size (font) - 6;
+ top += get_font_size (font) - 6;
}
@@ -2412,9 +2424,9 @@
char *url_string = g_strdup_printf (_("URL: %s"),
url);
- top = bound_text (pc, font, url_string,
+ top = bound_text (pr, font, url_string,
left, right, top, bottom, 0);
- top += gnome_font_get_size (font) - 6;
+ top += get_font_size (font) - 6;
g_free (url_string);
}
@@ -2425,9 +2437,9 @@
if (categories && categories[0]) {
categories_string = g_strdup_printf (_("Categories: %s"),
categories);
- top = bound_text (pc, font, categories_string,
+ top = bound_text (pr, font, categories_string,
left, right, top, bottom, 0);
- top += gnome_font_get_size (font) - 6;
+ top += get_font_size (font) - 6;
g_free (categories_string);
}
@@ -2444,9 +2456,9 @@
}
e_cal_component_free_text_list (contact_list);
- top = bound_text (pc, font, contacts->str,
+ top = bound_text (pr, font, contacts->str,
left, right, top, bottom, 0);
- top += gnome_font_get_size (font) - 6;
+ top += get_font_size (font) - 6;
g_string_free (contacts, TRUE);
}
@@ -2459,12 +2471,12 @@
ECalComponentText *text = l->data;
if (text->value != NULL)
- top = bound_text (pc, font, text->value, left, right, top-3, bottom, 0);
+ top = bound_text (pr, font, text->value, left, right, top-3, bottom, 0);
}
e_cal_component_free_text_list (desc);
- g_object_unref (font);
+ pango_font_description_free (font);
- gnome_print_showpage (pc);
+ gnome_print_showpage (pr->pc);
}
void
@@ -2473,7 +2485,7 @@
{
GnomePrintConfig *print_config;
GnomePrintJob *gpm;
- GnomePrintContext *pc;
+ EvoCalendarPrintRenderer *pr;
double l, r, t, b;
char *old_orientation;
@@ -2533,7 +2545,8 @@
gpm = gnome_print_job_new (print_config);
- pc = gnome_print_job_get_context (gpm);
+ pr = evo_calendar_print_data_new (gnome_print_job_get_context (gpm));
+
gnome_print_config_get_page_size (print_config, &r, &t);
/* See top of source for an explanation of this */
@@ -2554,21 +2567,23 @@
/* depending on the view, do a different output */
switch (default_view) {
case PRINT_VIEW_DAY:
- print_day_view (pc, gcal, date, l, r, t, b);
+ print_day_view (pr, gcal, date, l, r, t, b);
break;
case PRINT_VIEW_WEEK:
- print_week_view (pc, gcal, date, l, r, t, b);
+ print_week_view (pr, gcal, date, l, r, t, b);
break;
case PRINT_VIEW_MONTH:
- print_month_view (pc, gcal, date, l, r, t, b);
+ print_month_view (pr, gcal, date, l, r, t, b);
break;
case PRINT_VIEW_YEAR:
- print_year_view (pc, gcal, date, l, r, t, b);
+ print_year_view (pr, gcal, date, l, r, t, b);
break;
default:
g_assert_not_reached ();
}
+ evo_calendar_print_data_free (pr);
+
gnome_print_job_close (gpm);
if (preview) {
@@ -2598,7 +2613,7 @@
{
GnomePrintConfig *print_config;
GnomePrintJob *gpm;
- GnomePrintContext *pc;
+ EvoCalendarPrintRenderer *pr;
double l, r, t, b;
g_return_if_fail (comp != NULL);
@@ -2638,7 +2653,7 @@
gpm = gnome_print_job_new (print_config);
- pc = gnome_print_job_get_context (gpm);
+ pr = evo_calendar_print_data_new (gnome_print_job_get_context (gpm));
gnome_print_config_get_page_size (print_config, &r, &t);
/* See top of source for an explanation of this */
@@ -2656,9 +2671,11 @@
t *= (1.0 - TEMP_MARGIN);
r *= (1.0 - TEMP_MARGIN);
- print_comp_item (pc, comp, client, l, r, t, b);
+ print_comp_item (pr, comp, client, l, r, t, b);
gnome_print_job_close (gpm);
+ evo_calendar_print_data_free (pr);
+
if (preview) {
GtkWidget *gpmp;
@@ -2673,25 +2690,26 @@
}
static void
-print_title (GnomePrintContext *pc, const char *title,
+print_title (EvoCalendarPrintRenderer *pr, const char *title,
double page_width, double page_height)
{
- GnomeFont *font;
+ PangoFontDescription *font;
double w, x, y;
- font = gnome_font_find_closest ("Sans Bold", 18);
-
- w = gnome_font_get_width_utf8 (font, title);
+ font = pango_font_description_from_string("Sans Bold 18");
+ pango_layout_set_font_description (pr->pl, font);
+ pango_layout_set_text (pr->pl, title, -1);
+ w = pango_layout_get_width (pr->pl)/(double)PANGO_SCALE;
+ y = page_height;
x = (page_width - w) / 2;
- y = page_height - gnome_font_get_ascender (font);
- gnome_print_moveto (pc, x, y);
- gnome_print_setfont (pc, font);
- gnome_print_setrgbcolor (pc, 0, 0, 0);
- gnome_print_show (pc, title);
+ gnome_print_moveto (pr->pc, x, y);
+ gnome_print_setrgbcolor (pr->pc, 0, 0, 0);
+
+ gnome_print_pango_layout (pr->pc, pr->pl);
- g_object_unref (font);
+ pango_font_description_free (font);
}
void
@@ -2699,7 +2717,7 @@
{
EPrintable *printable;
GnomePrintConfig *print_config;
- GnomePrintContext *pc;
+ EvoCalendarPrintRenderer *pr;
GnomePrintJob *gpm;
double l, r, t, b, page_width, page_height, left_margin, bottom_margin;
@@ -2743,7 +2761,7 @@
gpm = gnome_print_job_new (print_config);
- pc = gnome_print_job_get_context (gpm);
+ pr = evo_calendar_print_data_new (gnome_print_job_get_context (gpm));
gnome_print_config_get_page_size (print_config, &r, &t);
@@ -2769,21 +2787,23 @@
bottom_margin = b;
do {
- gnome_print_beginpage (pc, "Tasks");
- gnome_print_gsave (pc);
+ gnome_print_beginpage (pr->pc, "Tasks");
+ gnome_print_gsave (pr->pc);
- gnome_print_translate (pc, left_margin, bottom_margin);
+ gnome_print_translate (pr->pc, left_margin, bottom_margin);
- print_title (pc, print_header, page_width, page_height);
+ print_title (pr, print_header, page_width, page_height);
if (e_printable_data_left (printable))
- e_printable_print_page (printable, pc,
+ e_printable_print_page (printable, pr->pc,
page_width, page_height - 24, TRUE);
- gnome_print_grestore (pc);
- gnome_print_showpage (pc);
+ gnome_print_grestore (pr->pc);
+ gnome_print_showpage (pr->pc);
} while (e_printable_data_left (printable));
+ evo_calendar_print_data_free (pr);
+
gnome_print_job_close (gpm);
if (preview) {
--- evolution-2.3.5.1/widgets/table/e-cell-text.c.fix-150458 2005-06-25 06:24:31.000000000 -0400
+++ evolution-2.3.5.1/widgets/table/e-cell-text.c 2005-08-01 20:25:03.000000000 -0400
@@ -45,6 +45,7 @@
#include <gtk/gtk.h>
#include <libgnomecanvas/gnome-canvas.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
+#include <libgnomeprint/gnome-print-pango.h>
#include "a11y/e-table/gal-a11y-e-cell-registry.h"
#include "a11y/e-table/gal-a11y-e-cell-text.h"
@@ -1286,23 +1287,18 @@
#define FONT_NAME "Sans Regular"
-static GnomeFont *
+static PangoFontDescription *
get_font_for_size (double h)
{
- GnomeFontFace *face;
- GnomeFont *font;
- double asc, desc, size;
+ PangoFontDescription *font_desc;
- face = gnome_font_face_find (FONT_NAME);
+ font_desc = pango_font_description_from_string (FONT_NAME);
- asc = gnome_font_face_get_ascender (face);
- desc = abs (gnome_font_face_get_descender (face));
- size = h * 1000 / (asc + desc);
-
- font = gnome_font_find_closest (FONT_NAME, size);
-
- g_object_unref (face);
- return font;
+ #define MAGIC_SCALE_FACTOR (0.86)
+ pango_font_description_set_size (font_desc,
+ h * (MAGIC_SCALE_FACTOR * PANGO_SCALE) );
+
+ return font_desc;
}
static void
@@ -1310,13 +1306,54 @@
int model_col, int view_col, int row,
double width, double height)
{
- GnomeFont *font = get_font_for_size (16);
+ PangoFontDescription *font_desc = get_font_for_size (16);
+ PangoLayout *pl;
char *string;
ECellText *ect = E_CELL_TEXT(ecell_view->ecell);
- double ty, ly, text_width;
+ double ty;
gboolean strikeout, underline;
+
string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row);
+
+ strikeout = ect->strikeout_column >= 0 && row >= 0 &&
+ e_table_model_value_at (ecell_view->e_table_model, ect->strikeout_column, row);
+ underline = ect->underline_column >= 0 && row >= 0 &&
+ e_table_model_value_at(ecell_view->e_table_model, ect->underline_column, row);
+
+
+ /* Set up PangoLayout: */
+ pl = gnome_print_pango_create_layout (context);
+ pango_layout_set_font_description (pl, font_desc);
+ pango_layout_set_text (pl, string, -1);
+ pango_layout_set_width (pl, -1); /* ensure no line-wrapping occurs */
+ pango_layout_set_indent (pl, 0);
+
+ if (strikeout || underline) {
+ PangoAttrList *attr_list;
+
+ attr_list = pango_attr_list_new ();
+
+ if (underline) {
+ PangoAttribute* attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
+ attr->start_index = 0;
+ attr->end_index = strlen (string);
+ pango_attr_list_insert (attr_list,
+ attr);
+ }
+
+ if (strikeout) {
+ PangoAttribute* attr = pango_attr_strikethrough_new (TRUE);
+ attr->start_index = 0;
+ attr->end_index = strlen (string);
+ pango_attr_list_insert (attr_list,
+ attr);
+ }
+ pango_layout_set_attributes (pl,
+ attr_list);
+ pango_attr_list_unref (attr_list);
+ }
+
gnome_print_gsave(context);
if (gnome_print_moveto(context, 2, 2) == -1)
/* FIXME */;
@@ -1331,38 +1368,14 @@
if (gnome_print_clip(context) == -1)
/* FIXME */;
- ty = (height - gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2;
- text_width = gnome_font_get_width_utf8 (font, string);
-
- strikeout = ect->strikeout_column >= 0 && row >= 0 &&
- e_table_model_value_at (ecell_view->e_table_model, ect->strikeout_column, row);
- underline = ect->underline_column >= 0 && row >= 0 &&
- e_table_model_value_at(ecell_view->e_table_model, ect->underline_column, row);
-
- if (underline) {
- ly = ty + gnome_font_get_underline_position (font);
- gnome_print_newpath (context);
- gnome_print_moveto (context, 2, ly);
- gnome_print_lineto (context, MIN (2 + text_width, width - 2), ly);
- gnome_print_setlinewidth (context, gnome_font_get_underline_thickness (font));
- gnome_print_stroke (context);
- }
-
- if (strikeout) {
- ly = ty + (gnome_font_get_ascender (font) - gnome_font_get_underline_thickness (font))/ 2.0;
- gnome_print_newpath (context);
- gnome_print_moveto (context, 2, ly);
- gnome_print_lineto (context, MIN (2 + text_width, width - 2), ly);
- gnome_print_setlinewidth (context, gnome_font_get_underline_thickness (font));
- gnome_print_stroke (context);
- }
+ ty = height;
gnome_print_moveto(context, 2, ty);
- gnome_print_setfont(context, font);
- gnome_print_show(context, string);
+ gnome_print_pango_layout (context, pl);
gnome_print_grestore(context);
e_cell_text_free_text(ect, string);
- g_object_unref (font);
+ pango_font_description_free (font_desc);
+ g_object_unref (G_OBJECT (pl));
}
static gdouble
--- evolution-2.3.5.1/widgets/table/e-table-group-container.c.fix-150458 2005-06-25 06:24:31.000000000 -0400
+++ evolution-2.3.5.1/widgets/table/e-table-group-container.c 2005-07-28 15:00:03.000000000 -0400
@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include <libgnome/libgnome.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
+#include <libgnomeprint/gnome-print-pango.h>
#include "text/e-text.h"
#include "e-util/e-i18n.h"
@@ -1159,7 +1160,18 @@
GList *child;
EPrintable *child_printable;
gchar *string;
- GnomeFont *font = gnome_font_find ("Helvetica", TEXT_HEIGHT);
+
+ PangoLayout *pl;
+
+ PangoFontDescription *font_desc = pango_font_description_from_string ("Helvetica");
+ #define MAGIC_SCALE_FACTOR (0.86)
+ pango_font_description_set_size (font_desc,
+ TEXT_HEIGHT * MAGIC_SCALE_FACTOR * PANGO_SCALE );
+
+ pl = gnome_print_pango_create_layout (context);
+ pango_layout_set_font_description (pl, font_desc);
+ pango_layout_set_width (pl, -1); /* ensure no line-wrapping occurs */
+ pango_layout_set_indent (pl, 0);
child_printable = groupcontext->child_printable;
child = groupcontext->child;
@@ -1223,9 +1235,8 @@
if (gnome_print_clip(context) == -1)
/* FIXME */;
- if (gnome_print_moveto(context, 2, yd - (TEXT_AREA_HEIGHT + gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2) == -1)
- /* FIXME */;
- if (gnome_print_setfont(context, font))
+ /* FIXME: get correct Y coordinate: */
+ if (gnome_print_moveto(context, 2, yd) == -1)
/* FIXME */;
if (groupcontext->etgc->ecol->text)
string = g_strdup_printf ("%s : %s (%d item%s)",
@@ -1238,9 +1249,13 @@
child_node->string,
(gint) child_node->count,
child_node->count == 1 ? "" : "s");
- if (gnome_print_show(context, string))
- /* FIXME */;
+
+ pango_layout_set_text (pl, string, -1);
+
g_free(string);
+
+ gnome_print_pango_layout (context, pl);
+
if (gnome_print_grestore(context) == -1)
/* FIXME */;
@@ -1294,7 +1309,9 @@
g_object_unref (groupcontext->child_printable);
groupcontext->child_printable = child_printable;
groupcontext->child = child;
-
+
+ pango_font_description_free (font_desc);
+ g_object_unref (G_OBJECT (pl));
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]