From 9a1d6eded2750572e9f5f79e53ec507dd7a06ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 5 May 2018 18:22:00 +0200 Subject: New upstream version 5.1.1 --- app/wlib/gtklib/print.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'app/wlib/gtklib/print.c') 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 #endif #include +#include #define GTK_DISABLE_SINGLE_INCLUDES #define GDK_DISABLE_DEPRECATED #define GTK_DISABLE_DEPRECATED #define GSEAL_ENABLE +#define PRODUCT "XTRKCAD" + #include #include @@ -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. -- cgit v1.2.3