|
From: Ethan M. <merritt@u.washington.edu> - 2009-11-03 21:09:48
|
On Tuesday 03 November 2009 09:39:33 Allin Cottrell wrote: > > On Mon, 2 Nov 2009, Allin Cottrell wrote: > I think I have one piece of the puzzle. I'm not convinced. I suspect that the change you see may be an artifact of shifting the character position by 1 or 2 pixels. See comments below. More importantly... I have begun to wonder if the involvment of cairo may be a red herring. The problem may be more general than that. Have a look at Bug report 1918293 "Copy to Clipboard" on MS-Win32 clip "tails" of p,g,q and y https://sourceforge.net/tracker/?func=detail&aid=1918293&group_id=2055&atid=102055 Could this be the same problem, but involving the windows terminal rather than the cairo terminal? Could it be that the real problem is with the font itself? Or with some very low level Windows font rendering code that is shared by cairo and by the windows terminal? > In src/wxterminal/gp_cairo.c, in the function gp_cairo_draw_text, > at lines 749 to 752, we originally had: > > vert_just = ((double)ink_rect.height/2 +(double)ink_rect.y) / > PANGO_SCALE; > > where "ink_rect" is filled out via pango_layout_get_extents(). > I presume this is code that Timothee wrote (?). > > In March 2009 Ethan disabled this line and substituted > > vert_just = avg_vchar/2; > > with the comment 'Adjusting the vertical position for every > character fragment leads to uneven baselines. Better to adjust to > the "average" character height.' So? vert_just is just an offset in gnuplot's coordinate space. It affects the pixel coordinate pair (x,y) where we request that the text be rendered, but it does not alter anything I can see about how that text is requested. I am wondering whether the bug in the underlying cairo/pango library comes down to a question of whether the x coordinate integer value is even or odd. > [snip script] > I have put the PNG output files (test8a.png, test9a.png from build > A; test8b.png, test9b.png from build B) in > > http://www.wfu.edu/~cottrell/gptest/ > > I find that the differences are seen most easily by opening both > test8a.png and test8b.png (or test9a and test9b) in xv, and > toggling between them. But both of those renderings are different from the output of the same script run under linux. Here are blow-ups of the character rendering in your 9a/9b examples and the output of the same script + font request run on linux. http://skuld.bmsc.washington.edu/~merritt/gnuplot/cairobug/windows_9a.png http://skuld.bmsc.washington.edu/~merritt/gnuplot/cairobug/windows_9b.png http://skuld.bmsc.washington.edu/~merritt/gnuplot/cairobug/linux_9.png One immediately obvious difference is antialiasing -- the windows versions are not using it. A less obvious difference is that in both windows output images the character position (at least that of the "Q") is shifted to the right and down by 1 or 2 pixels relative to the linux output. I am suspicious that this pixel shift may be the real problem. It smells of an off-by-one error in some copy operation. -- Ethan A Merritt |