summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/print.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-07-10 23:05:17 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-07-10 23:05:17 +0200
commitc120c7bcbcf115ecc2a6668f4c7f45b3d4a5bc86 (patch)
tree5550610553d1b1d7236d052b6e956b22e0bb4883 /app/wlib/gtklib/print.c
parent67d0ce65dc6a1d240e271a7cd479b60aa1dc2967 (diff)
parent26d299964db18cb71c2c6a5be4864479ba82d54f (diff)
Merge branch 'release/debian/5.1.1-1'debian/5.1.1-1
Diffstat (limited to 'app/wlib/gtklib/print.c')
-rw-r--r--app/wlib/gtklib/print.c47
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.