Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 20 Aug 2013 09:51:45 UTC Commit: 1fe7b4848ee47e7cc198082ccb49bb398a6bfb21 https://github.com/geany/geany/commit/1fe7b4848ee47e7cc198082ccb49bb398a6bfb...
Log Message: ----------- Fix printing under Windows
For some reason the Scintilla widget's Pango context don't have a resolution set on Windows, so we get an invalid one. Fix this by correctly peek the resolution from the map if the context doesn't have one by itself.
https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html#pango-ca...
Thanks to Matthew Brush for debugging this!
Closes #961.
Modified Paths: -------------- src/printing.c
Modified: src/printing.c 14 files changed, 12 insertions(+), 2 deletions(-) =================================================================== @@ -334,6 +334,7 @@ static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, DocInfo *dinfo = user_data; PangoContext *pango_ctx, *widget_pango_ctx; PangoFontDescription *desc; + gdouble pango_res, widget_res;
if (dinfo == NULL) return; @@ -358,9 +359,18 @@ static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, * Pango context out of the Cairo target, and the resolution is in the GtkPrintOperation's * Pango context */ pango_ctx = gtk_print_context_create_pango_context(context); - widget_pango_ctx = gtk_widget_get_pango_context(GTK_WIDGET(dinfo->sci)); - dinfo->sci_scale = pango_cairo_context_get_resolution(pango_ctx) / pango_cairo_context_get_resolution(widget_pango_ctx); + pango_res = pango_cairo_context_get_resolution(pango_ctx); g_object_unref(pango_ctx); + widget_pango_ctx = gtk_widget_get_pango_context(GTK_WIDGET(dinfo->sci)); + widget_res = pango_cairo_context_get_resolution(widget_ctx); + /* On Windows, for some reason the widget's resolution is -1, so follow + * Pango docs and peek the font map's one. */ + if (widget_res < 0) + { + widget_res = pango_cairo_font_map_get_resolution( + (PangoCairoFontMap*) pango_context_get_font_map(widget_pango_ctx)); + } + dinfo->sci_scale = pango_res / widget_res;
dinfo->pages = g_array_new(FALSE, FALSE, sizeof(gint));
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).