From 4f613a2a667061bf96aad43bc5df12180a111182 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 23 Dec 2011 19:01:45 +0000 Subject: [PATCH] * Source/cairo/CairoContext.m (-beginPrologueBBox:...): Use paper size from print info to set the cairo page size, instead of using the bounding box (which is usually smaller than the paper size, and was causing cairo print output to be wrong compared to GNUstep's built-in PostScript writer.) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@34351 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Source/cairo/CairoContext.m | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c0f45d..ffc444a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-12-23 Eric Wasylishen + + * Source/cairo/CairoContext.m (-beginPrologueBBox:...): Use + paper size from print info to set the cairo page size, instead + of using the bounding box (which is usually smaller than the + paper size, and was causing cairo print output to be wrong + compared to GNUstep's built-in PostScript writer.) + 2011-11-28 Fred Kiefer * Source/x11/XGServerEvent.m (initialize_keyboard): Don't use diff --git a/Source/cairo/CairoContext.m b/Source/cairo/CairoContext.m index 5235365..756382a 100644 --- a/Source/cairo/CairoContext.m +++ b/Source/cairo/CairoContext.m @@ -27,6 +27,8 @@ #include #include +#include +#include #include "cairo/CairoContext.h" #include "cairo/CairoGState.h" @@ -225,6 +227,21 @@ NSSize size; NSString *contextType; + NSPrintOperation *printOp = [NSPrintOperation currentOperation]; + NSPrintInfo *printInfo = [printOp printInfo]; + + if (printInfo != nil) + { + size = [printInfo paperSize]; + } + else + { + [NSException raise: NSInternalInconsistencyException + format: @"current print operation printInfo is nil in %@", + NSStringFromSelector(_cmd)]; + return; + } + contextType = [context_info objectForKey: NSGraphicsContextRepresentationFormatAttributeName]; @@ -232,7 +249,6 @@ { if ([contextType isEqual: NSGraphicsContextPSFormat]) { - size = boundingBox.size; surface = [[CairoPSSurface alloc] initWithDevice: context_info]; [surface setSize: size]; // This strange setting is needed because of the way GUI handles offset. @@ -241,7 +257,6 @@ } else if ([contextType isEqual: NSGraphicsContextPDFFormat]) { - size = boundingBox.size; surface = [[CairoPDFSurface alloc] initWithDevice: context_info]; [surface setSize: size]; // This strange setting is needed because of the way GUI handles offset.