Mercurial > octave-nkf
diff libinterp/interpfcn/graphics.cc @ 16201:2338a92e9782
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.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 06 Mar 2013 10:56:12 -0800 |
parents | 1ac3c906990a |
children | 92f8bfae9b13 |
line wrap: on
line diff
--- 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);