#4 Alignment of vertical axis labels wrong if rotated


For my application I do not like the vertical axis labels aligned vertically, so I tried using gtk_databox_ruler_set_text_orientation to turn them round. This works, but the labels are all in the wrong place.

Looking at the code for v0.9.2.0, I think the problem is in lines 1438 and 1440 of gtkdatabox_ruler.c where the Y offset is calculated from the X size:

        if (ruler->priv->text_orientation == GTK_ORIENTATION_HORIZONTAL) /* if ticks are present, then draw a little higher */
            y_loc=pos - logical_rect.width*2/3; /* horizontal text y alignment */
        if (ruler->priv->text_orientation == GTK_ORIENTATION_HORIZONTAL & !ruler->priv->draw_ticks) /* if ticks aren't present, draw a little lower */
            y_loc=pos - logical_rect.width/3;

If text is horizontal, then Y offsets should be based on logical_rect.height, not width!


  • Brent Baccala

    Brent Baccala - 2016-10-10
    • status: open --> closed
  • Brent Baccala

    Brent Baccala - 2016-10-10

    Patch accepted in commit 1b6c1f

    As Robert Pearce realized, logical_rect is reported in coordinates prior to applying the rotation matrix (see https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html), so for vertical text, y_loc should be computed using logical_rect.width, while for horizontal text, y_loc should be computed using logical_rect.height.

    This entire section of code could use a careful review.


Log in to post a comment.