# HG changeset patch # User Rik # Date 1362596172 28800 # Node ID 2338a92e97826da02ecdc5a677f83129821e7890 # Parent 743b895259e06cdf802a31e8d4aab0001084d938 Fix spacing between ylabel and y-axis (bug #38461) * libinterp/interp-core/txt-eng-ft.cc: Add comment about how get_extent calculates the x and y extents differently. * libinterp/interpfcn/graphics.cc(update_ylabel_position): Add padding to x-extent because it is caluclated differently than y-extent which already includes some padding. diff -r 743b895259e0 -r 2338a92e9782 libinterp/interp-core/txt-eng-ft.cc --- a/libinterp/interp-core/txt-eng-ft.cc Tue Mar 05 18:01:24 2013 -0500 +++ b/libinterp/interp-core/txt-eng-ft.cc Wed Mar 06 10:56:12 2013 -0800 @@ -564,6 +564,11 @@ return pixels; } +// Note: +// x-extent accurately measures width of glyphs. +// y-extent is overly large because it is measured from baseline-to-baseline. +// Calling routines, such as ylabel, may need to account for this mismatch. + Matrix ft_render::get_extent (text_element *elt, double rotation) { diff -r 743b895259e0 -r 2338a92e9782 libinterp/interpfcn/graphics.cc --- a/libinterp/interpfcn/graphics.cc Tue Mar 05 18:01:24 2013 -0500 +++ b/libinterp/interpfcn/graphics.cc Wed Mar 06 10:56:12 2013 -0800 @@ -5194,11 +5194,20 @@ graphics_xform xform = get_transform (); Matrix ext (1, 2, 0.0); + + // The underlying get_extents() from FreeType produces mismatched values. + // x-extent accurately measures the width of the glyphs. + // y-extent instead measures from baseline-to-baseline. + // Pad x-extent (+4) so that it approximately matches y-extent. + // This keeps ylabels about the same distance from y-axis as + // xlabels are from x-axis. + // ALWAYS use an even number for padding or horizontal alignment + // will be off. ext = get_ticklabel_extents (get_ytick ().matrix_value (), get_yticklabel ().all_strings (), get_ylim ().matrix_value ()); - double wmax = ext(0), hmax = ext(1), angle = 0; + double wmax = ext(0)+4, hmax = ext(1), angle = 0; ColumnVector p = graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick);