diff options
author | Hans Petter Jansson <hpj@ximian.com> | 2003-06-24 04:30:22 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2003-06-24 04:30:22 +0800 |
commit | 4f9a9a637954354029caa5781b17150d8f7c1b1d (patch) | |
tree | 7e865d07bd18f1558a4a18d5ba59d3ec2a4060a9 | |
parent | bd71a378e45c2cd83592bc29453947234e40cd2b (diff) | |
download | gsoc2013-evolution-4f9a9a637954354029caa5781b17150d8f7c1b1d.tar.gz gsoc2013-evolution-4f9a9a637954354029caa5781b17150d8f7c1b1d.tar.zst gsoc2013-evolution-4f9a9a637954354029caa5781b17150d8f7c1b1d.zip |
Implement. (ect_print): Use same font heuristics as evo calendar, pick a
2003-06-22 Hans Petter Jansson <hpj@ximian.com>
* e-cell-text.c (get_font_for_size): Implement.
(ect_print): Use same font heuristics as evo calendar, pick a font
that fits. Correct baseline calculation.
svn path=/trunk/; revision=21519
-rw-r--r-- | widgets/table/e-cell-text.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 05cf99e653..9151fcc26e 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -1113,12 +1113,33 @@ ect_free_state (ECellView *ecell_view, int model_col, int view_col, int row, voi g_free (save_state); } +#define FONT_NAME "Sans Regular" + +static GnomeFont * +get_font_for_size (double h) +{ + GnomeFontFace *face; + GnomeFont *font; + double asc, desc, size; + + 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); + + font = gnome_font_find_closest (FONT_NAME, size); + + g_object_unref (face); + return font; +} + static void ect_print (ECellView *ecell_view, GnomePrintContext *context, int model_col, int view_col, int row, double width, double height) { - GnomeFont *font = gnome_font_find ("Helvetica", 12); + GnomeFont *font = get_font_for_size (16); char *string; ECellText *ect = E_CELL_TEXT(ecell_view->ecell); string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row); @@ -1135,11 +1156,13 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, /* FIXME */; if (gnome_print_clip(context) == -1) /* FIXME */; - gnome_print_moveto(context, 2, (height - gnome_font_get_ascender(font) + gnome_font_get_descender(font)) / 2); + gnome_print_moveto(context, 2, (height - gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2); + gnome_print_setfont(context, font); gnome_print_show(context, string); gnome_print_grestore(context); e_cell_text_free_text(ect, string); + g_object_unref (font); } static gdouble |