The Pango contexts are not properly updated for the surface they are actually used to draw on, which results in improper transformations if the target surface isn't the widget's one (e.g. when printing on a scaled surface).
Attached is a patch that fixes it by making sure the used Pango contexts are properly set up for the surface they are actually used with.
Properly update the Pango contexts for the target surface
I couldn't see any problems using Print or Print Preview from SciTE with a scale factor.
Committed.
What do you mean, that before you didn't see a problem, or that the patch didn't break anything? The problem the patch fixes is improper measurements if the target surface has a Cairo scale (and probably other transforms) factor different than the ScintillaGTK widget.
Actually, when printing using the GTK backend, the default scale may be incorrect for the target because Scintilla creates its own Pango layout, but the GtkPrintOperation's one may have a scale factor applied (to adjust for printing deice DPIs). So since Scintilla won't it (since actually it never sees this scale factor nor the DPI), to print at the appropriate size for the device I needed to scale the target surface depending on the source (widget, so screen) and destination (printing device) DPI. But some[1] measurements were done with a non-scaled Pango context, thus leading to unaligned stuff and worse.
Anyway, thanks for committing :)
[1] not sure why not all were wrong, but e.g. tab stops were incorrect.
I meant that I couldn't see any problems before the patch was applied. It would have been useful to include an image showing an example problem.
Here is an image showing both incorrect (before the patch) and correct (after) output when printing on a scaled target surface, with font DejaVu Sans Mono 8.
Here, some lines are aligned with tabulations (longer ones) and some with the appropriate amount of spaces (shorter ones). You can also see that the line height is taller on the improper output.
For reference, I attach the file that was used to discover the issue.
In Geany, the problem doesn't happen with font monospace at size 10, but does at size 12.
See http://lists.geany.org/pipermail/devel/2012-November/007185.html