[Geany-Devel] Printing

Colomban Wendling lists.ban at herbesfolles.org
Wed Oct 31 18:56:17 UTC 2012

Le 31/10/2012 15:03, Colomban Wendling a écrit :
>> On 31 October 2012 16:36, Roger Booth <rbooth at kabooth.com> wrote:
>>> Geany – the current git - problems
>>>  * Print Preview displays a different number of lines than hard-copy -
>>> #3580269.
>>>  * The line separating line numbers from text when printing is positioned
>>> incorrectly - #3580268.
> I'm not sure, but I suspect this might be because of the "magnification"
> setting from scintilla.  You noted I added a quite clear comment next to
> that call, showing I have roughly no idea why -2 gives good results.  To
> get this right, either the fixes has to go in Scintilla, or we need to
> understand exactly what that magnification is, so what to reproduce.

OK, I think I found it.  The Pango layout from GtkPrintOperation may
have the resolution set to a non-default value, and that resolution
probably depends on the output device.  However, this resolution is set
in the PangoContext one can get from the GtkPrintOperation, context that
Scintilla never get -- and can't (at least easily), it creates its Pango
contexts directly from the Cairo ones.

This results in an inappropriate resolution on the Scintilla draws,
hence the bigger text and the sizing issues (since we get out own
context from the GtkPrintOperation, context that has the proper resolution).

So, three solution are possible:

1) Set the magnification so it compensates the resolution difference.
However, this is not really a solution because the magnification value
is a integer, which isn't precise enough (e.g. it can't represent the
compensation needed if the device output resolution is 72, which would
give a magnification of -2.5).

2) Scale down Scintilla's drawings.  This requires a little more
attention since then the surface size given to Scintilla needs to be
adjusted to compensate the scaling, but it works.

3) make the same mistake in our own code an ignore the resolution.  This
doesn't seem sensible since that resolution isn't here for nothing, and
it doesn't fix the overall sizing problem.

So, I implemented solution 2 in the attached patch, please test and tell
me if it's ok, better, or what problem remains, etc.

>>>  * Printed lines are right-shifted compared to previous Geany versions,
>>> causing wrapping which did not occur in previous Geany versions.
> As you noted, it's Scintilla that adds whitespace to separate line
> numbers from code, but we prefer a vertical line.

BTW, with the appropriate sizing, the 3 spaces aren't that big, and even
though we may prefer to only have say, 0.5 on both side of the vertical
line, it's not that much of an issue I think.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: print-resolution-fix.diff
Type: text/x-patch
Size: 3909 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20121031/264d777c/attachment.bin>

More information about the Devel mailing list