diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-05-05 18:22:19 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-05-05 18:22:19 +0200 |
commit | 498011c44291d7d619143ce5ff3e38369d759c22 (patch) | |
tree | 5b4d1fdd686089c0c1778a462e27fa694b8f49be /app/wlib/gtklib/print.c | |
parent | 67d0ce65dc6a1d240e271a7cd479b60aa1dc2967 (diff) | |
parent | 9a1d6eded2750572e9f5f79e53ec507dd7a06ba5 (diff) |
Update upstream source from tag 'upstream/5.1.1'
Update to upstream version '5.1.1'
with Debian dir 878f8cb06af8c1037570ac8774f9261ff9b12fa4
Diffstat (limited to 'app/wlib/gtklib/print.c')
-rw-r--r-- | app/wlib/gtklib/print.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/app/wlib/gtklib/print.c b/app/wlib/gtklib/print.c index cad7e57..8e96e3b 100644 --- a/app/wlib/gtklib/print.c +++ b/app/wlib/gtklib/print.c @@ -25,12 +25,15 @@ #include <malloc.h> #endif #include <math.h> +#include <string.h> #define GTK_DISABLE_SINGLE_INCLUDES #define GDK_DISABLE_DEPRECATED #define GTK_DISABLE_DEPRECATED #define GSEAL_ENABLE +#define PRODUCT "XTRKCAD" + #include <gtk/gtk.h> #include <gdk/gdk.h> @@ -87,6 +90,7 @@ static double lBorder; /**< left margin */ static double bBorder; /**< bottom margin */ static double scale_adjust = 1.0; +static double scale_text = 1.0; static long printFormat = PRINT_LANDSCAPE; @@ -605,7 +609,8 @@ void psPrintString( /** \todo use a getter function instead of double conversion */ desc = pango_font_description_from_string(wlibFontTranslate(fp)); - pango_font_description_set_size(desc, fs * PANGO_SCALE ); + + pango_font_description_set_size(desc, fs * PANGO_SCALE * scale_text); // render the string to a Pango layout pango_layout_set_font_description(layout, desc); @@ -619,7 +624,7 @@ void psPrintString( metrics = pango_context_get_metrics(pcontext, desc, pango_context_get_language(pcontext)); - ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE * scale_adjust ; + ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE *scale_adjust; cairo_identity_matrix(cr); @@ -852,19 +857,35 @@ wBool_t wPrintDocStart(const char * title, int fTotalPageCount, int * copiesP) //update the paper dimensions WlibGetPaperSize(); - /* for the file based surfaces the resolution is 72 dpi (see documentation) */ + /* for all surfaces including files the resolution is always 72 ppi (as all GTK uses PDF) */ surface_type = cairo_surface_get_type(psPrint_d.curPrintSurface); - if (surface_type == CAIRO_SURFACE_TYPE_PDF || - surface_type == CAIRO_SURFACE_TYPE_PS || - surface_type == CAIRO_SURFACE_TYPE_SVG) { - double p_def=600; - cairo_surface_set_fallback_resolution (psPrint_d.curPrintSurface, p_def, p_def); - psPrint_d.dpi = p_def; - scale_adjust = 72/p_def; - } else { - psPrint_d.dpi = (double)gtk_print_settings_get_resolution(settings); - } + const char * printer_name = gtk_print_settings_get_printer(settings); + /* + * Override up-scaling for some printer drivers/Linux systems that don't support the latest CUPS + * - the user sets the environment variable XTRKCADPRINTSCALE to a value + * and we just let the dpi default to 72ppi and set scaling to that value. + * And for PangoText we allow an override via variable XTRKCADPRINTTEXTSCALE + * Note - doing this will introduce differing artifacts. + * + */ + char * sEnvScale = PRODUCT "PRINTSCALE"; + + if ((strcmp(printer_name,"Print to File") == 0) || getenv(sEnvScale) == NULL) { + double p_def = 600; + cairo_surface_set_fallback_resolution(psPrint_d.curPrintSurface, p_def, p_def); + psPrint_d.dpi = p_def; + scale_adjust = 72/p_def; + } else { + char * sEnvTextScale = PRODUCT "PRINTTEXTSCALE"; + if (getenv(sEnvTextScale) && (atof(getenv(sEnvTextScale)) != 0.0)) { + scale_text = atof(getenv(sEnvTextScale)); + } else scale_text = 1.0; + if (getenv(sEnvScale) && (atof(getenv(sEnvScale)) != 0.0)) { + scale_adjust = atof(getenv(sEnvScale)); + } else scale_adjust = 1.0; + psPrint_d.dpi = 72; + } // in XTrackCAD 0,0 is top left, in cairo bottom left. This is // corrected via the following transformations. |