Ejemplo n.º 1
0
static gint
_calc_footer_height(GtkHTML * html, GtkPrintOperation * operation,
		    GtkPrintContext * context)
{
	PangoContext *pango_context;
	PangoFontDescription *desc;
	PangoFontMetrics *metrics;
	gint footer_height;

	pango_context = gtk_print_context_create_pango_context(context);
	desc = pango_font_description_from_string("Sans Regular 10");

	metrics =
	    pango_context_get_metrics(pango_context, desc,
				      pango_language_get_default());
	footer_height =
	    pango_font_metrics_get_ascent(metrics) +
	    pango_font_metrics_get_descent(metrics);
	pango_font_metrics_unref(metrics);

	pango_font_description_free(desc);
	g_object_unref(pango_context);

	return footer_height;
}
Ejemplo n.º 2
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkPrintContext_gtk_1print_1context_1create_1pango_1context
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	PangoContext* result;
	jlong _result;
	GtkPrintContext* self;

	// convert parameter self
	self = (GtkPrintContext*) _self;

	// call function
	result = gtk_print_context_create_pango_context(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, FALSE);
	}

	// and finally
	return _result;
}
Ejemplo n.º 3
0
/* We don't support variable width fonts (yet) */
static gint get_font_width(GtkPrintContext *context, PangoFontDescription *desc)
{
	PangoContext *pc;
	PangoFontMetrics *metrics;
	gint width;

	pc = gtk_print_context_create_pango_context(context);

	if (!utils_font_desc_check_monospace(pc, desc))
		dialogs_show_msgbox_with_secondary(GTK_MESSAGE_WARNING,
			_("The editor font is not a monospaced font!"),
			_("Text will be wrongly spaced."));

	metrics = pango_context_get_metrics(pc, desc, pango_context_get_language(pc));
	/** TODO is this the best result we can get? */
	/* digit and char width are mostly equal for monospace fonts, char width might be
	 * for dual width characters(e.g. Japanese) so use digit width to get sure we get the width
	 * for one character */
	width = pango_font_metrics_get_approximate_digit_width(metrics) / PANGO_SCALE;

	pango_font_metrics_unref(metrics);
	g_object_unref(pc);

	return width;
}
Ejemplo n.º 4
0
/*! Drawing callback for use with GtkPrintOperation. */
static void
draw_page__print_operation (GtkPrintOperation *print,
                            GtkPrintContext *context,
                            gint page_nr,
                            gpointer user_data)
{
  GschemToplevel *w_current = (GschemToplevel *) user_data;
  PAGE *page;
  cairo_t *cr;
  PangoContext *pc;
  double width, height;
  EdaConfig *cfg;
  gboolean is_color;

  /* Find the page data */
  g_return_if_fail (page_nr != 1);
  page = w_current->toplevel->page_current;
  g_return_if_fail (page != NULL);

  /* Get cairo & pango contexts */
  cr = gtk_print_context_get_cairo_context (context);
  pc = gtk_print_context_create_pango_context (context);

  width = gtk_print_context_get_width (context);
  height = gtk_print_context_get_height (context);

  /* Find out if colour printing is enabled */
  cfg = eda_config_get_context_for_path (s_page_get_filename (page));
  is_color = !eda_config_get_boolean (cfg, CFG_GROUP_PRINTING,
                                      CFG_KEY_PRINTING_MONOCHROME, NULL);

  x_print_draw_page (w_current->toplevel, page, cr, pc,
                     width, height, is_color, FALSE);

  /* Clean up */
  g_object_unref (pc);
}
Ejemplo n.º 5
0
static VALUE
rg_create_pango_context(VALUE self)
{
    return GOBJ2RVALU(gtk_print_context_create_pango_context(_SELF(self)));
}