void gnm_init (void) { static gboolean inited = FALSE; if (inited) return; inited = TRUE; libgoffice_init (); _gnm_register_resource (); if (gdk_screen_get_default ()) { /* Only when we have a gui. */ gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (), "/org/gnumeric/gnumeric/icons"); } gnm_register_ui_files (); go_plugin_service_define ("function_group", &gnm_plugin_service_function_group_get_type); go_plugin_service_define ("ui", &gnm_plugin_service_ui_get_type); go_plugin_service_define ("solver", &gnm_plugin_service_solver_get_type); go_plugin_loader_module_register_version ("gnumeric", GNM_VERSION_FULL); g_object_new (GNM_APP_TYPE, NULL); mathfunc_init (); gnm_style_init (); gnm_conf_init (); gnm_color_init (); gnm_font_init (); /* requires config */ value_init (); parse_util_init (); _gnm_expr_init (); gnm_sheet_cell_init (); clipboard_init (); dependent_types_init (); gnm_rendered_value_init (); functions_init (); print_init (); gnm_autofill_init (); sheet_objects_init (); _gnm_hlink_init (); /* The statically linked in file formats */ gnm_xml_sax_read_init (); gnm_xml_sax_write_init (); stf_init (); /* Make sure that images will be displayed with the correct resolution, see #628472 */ go_image_set_default_dpi (gnm_app_display_dpi_get (TRUE), gnm_app_display_dpi_get (FALSE)); }
static void gnm_so_path_draw_cairo (SheetObject const *so, cairo_t *cr, double width, double height) { GnmSOPath *sop = GNM_SO_PATH (so); GOStyle const *style = sop->style; cairo_new_path (cr); cairo_save (cr); cairo_move_to (cr, -sop->x_offset, -sop->y_offset); cairo_scale (cr, width / sop->width, height / sop->height); go_path_to_cairo (sop->path, GO_PATH_DIRECTION_FORWARD, cr); cairo_restore (cr); /* Fill the shape */ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); /* might be an option */ go_style_fill (style, cr, TRUE); /* Draw the line */ if (go_style_set_cairo_line (style, cr)) cairo_stroke (cr); else cairo_new_path (cr); /* Draw the text. */ if (sop->text != NULL && *(sop->text) != '\0') { PangoLayout *pl = pango_cairo_create_layout (cr); double const scale_h = 72. / gnm_app_display_dpi_get (TRUE); double const scale_v = 72. / gnm_app_display_dpi_get (FALSE); double pl_height = (height - sop->margin_pts.top - sop->margin_pts.bottom) * PANGO_SCALE / scale_v; double pl_width = (width - sop->margin_pts.left - sop->margin_pts.right) * PANGO_SCALE / scale_h; /* set a font, a very bad solution, but will do until we move to GOString */ PangoFontDescription *desc = pango_font_description_from_string ("Sans 10"); PangoRectangle r; pango_layout_set_font_description (pl, desc); pango_layout_set_text (pl, sop->text, -1); pango_layout_set_attributes (pl, sop->markup); pango_layout_set_width (pl, pl_width); pango_layout_set_height (pl, pl_height); cairo_save (cr); pango_layout_get_extents (pl, NULL, &r); cairo_move_to (cr, (width - r.width / PANGO_SCALE * scale_h) / 2., (height - r.height / PANGO_SCALE * scale_v) / 2.); cairo_scale (cr, scale_h, scale_v); cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->font.color)); pango_cairo_show_layout (cr, pl); cairo_new_path (cr); cairo_restore (cr); g_object_unref (pl); } }
static void cb_dialog_so_size_value_changed_update_points (GtkSpinButton *spinbutton, GtkLabel *points) { gint value = gtk_spin_button_get_value_as_int (spinbutton); double size_points = value * 72./gnm_app_display_dpi_get (FALSE); gchar *pts = g_strdup_printf ("%.2f",size_points); gtk_label_set_text (points, pts); g_free (pts); }
static void dialog_row_height_update_points (RowHeightState *state) { gint value = gtk_spin_button_get_value_as_int (state->spin); double size_points = value * 72./gnm_app_display_dpi_get (TRUE); gchar *pts; pts = g_strdup_printf ("%.2f",size_points); gtk_label_set_text (GTK_LABEL (state->points), pts); g_free (pts); }
void gnm_font_init (void) { PangoContext *context; GnmFont *gnumeric_default_font = NULL; double pts_scale = 72. / gnm_app_display_dpi_get (TRUE); style_font_hash = g_hash_table_new ( gnm_font_hash, gnm_font_equal); style_font_negative_hash = g_hash_table_new ( gnm_font_hash, gnm_font_equal); gnumeric_default_font_name = g_strdup (gnm_conf_get_core_defaultfont_name ()); gnumeric_default_font_size = gnm_conf_get_core_defaultfont_size (); context = gnm_pango_context_get (); if (gnumeric_default_font_name && gnumeric_default_font_size >= 1) gnumeric_default_font = style_font_new_simple (context, gnumeric_default_font_name, gnumeric_default_font_size, FALSE, FALSE); if (gnumeric_default_font == NULL) { g_warning ("Configured default font '%s %f' not available, trying fallback...", gnumeric_default_font_name, gnumeric_default_font_size); gnumeric_default_font = style_font_new_simple (context, DEFAULT_FONT, DEFAULT_SIZE, FALSE, FALSE); if (gnumeric_default_font != NULL) { g_free (gnumeric_default_font_name); gnumeric_default_font_name = g_strdup (DEFAULT_FONT); gnumeric_default_font_size = DEFAULT_SIZE; } else { g_warning ("Fallback font '%s %f' not available, trying 'fixed'...", DEFAULT_FONT, DEFAULT_SIZE); gnumeric_default_font = style_font_new_simple (context, "fixed", 10, FALSE, FALSE); if (gnumeric_default_font != NULL) { g_free (gnumeric_default_font_name); gnumeric_default_font_name = g_strdup ("fixed"); gnumeric_default_font_size = 10; } else { g_warning ("Even 'fixed 10' failed ?? We're going to exit now," "there is something wrong with your font configuration"); exit (1); } } } gnm_font_default_width = pts_scale * PANGO_PIXELS (gnumeric_default_font->go.metrics->avg_digit_width); gnm_font_unref (gnumeric_default_font); g_object_unref (context); }
static void cb_dialog_row_height_apply_clicked (G_GNUC_UNUSED GtkWidget *button, RowHeightState *state) { gint value = gtk_spin_button_get_value_as_int (state->spin); int size_pixels = (int)(value * state->sheet->last_zoom_factor_used + 0.5); gboolean use_default = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (state->default_check)); if (state->set_default_value) { double points = value * 72./gnm_app_display_dpi_get (TRUE); cmd_colrow_std_size (GNM_WBC (state->wbcg), state->sheet, FALSE, points); dialog_row_height_load_value (state); } else { if (use_default) size_pixels = 0; workbook_cmd_resize_selected_colrow (GNM_WBC (state->wbcg), state->sheet, FALSE, size_pixels); dialog_row_height_load_value (state); } }
double gnm_app_dpi_to_pixels (void) { return MIN (gnm_app_display_dpi_get (TRUE), gnm_app_display_dpi_get (FALSE)) / 72.; }
double colrow_compute_pixel_scale (Sheet const *sheet, gboolean horizontal) { return sheet->last_zoom_factor_used * gnm_app_display_dpi_get (horizontal) / 72.; }