Menu

#124 text cursor does not appear at mouse cursor

v1.0_(example)
open
nobody
None
5
2017-08-12
2013-05-14
Adam Dingle
No

I'm running Xournal built from git master on Ubuntu 13.10. I have GTK 3.8.1.

I'm using Xournal to add text to a PDF. When I select the text tool and click on the PDF, the text cursor doesn't appear right at the mouse cursor - instead it's about 10 pixels below or so. So I actually need to click about 10 pixels above where I actually want the text to be. I can do that, but it's a bit annoying.

Otherwise Xournal is a nice tool!

Discussion

  • qwach

    qwach - 2013-11-29

    I can confirm this, definitely a bit annoying.

     
  • László Monda

    László Monda - 2016-02-17

    Agreed! I use Xournal to fill out forms and this is the most annoying bug by far.

     
  • Dirk Fieldhouse

    Dirk Fieldhouse - 2017-08-12

    In src/xo_paint.c, look at the routine start_text (lines 561 ff). It seems that lines 573 ff below

    if (item==NULL) {
    item = g_new(struct Item, 1);
    item->text = NULL;
    item->canvas_item = NULL;
    item->bbox.left = pt[0];
    item->bbox.top = pt[1];
    item->bbox.right = ui.cur_page->width;
    item->bbox.bottom = pt[1]+100.;

    should be changed to

    if (item==NULL) {
    item = g_new(struct Item, 1);
    item->text = NULL;
    item->canvas_item = NULL;
    item->bbox.left = pt[0];
    item->bbox.top = pt[1] - ui.font_size;
    item->bbox.right = ui.cur_page->width;
    item->bbox.bottom = pt[1]+100.; // what's this 100. ? Should be named or documented.

    Perhaps someone who has a build environment for the program would like to try it.

     
    • Denis Auroux

      Denis Auroux - 2017-08-12

      Shifting item->bbox.top is indeed the right way to deal with this, but
      given that the mouse cursor and the text cursor don't have the same size
      (the mouse cursor has a fixed size regardless of the font, the text
      cursor has a font-dependent size), I am not sure if one should shift by
      the font ascender size, the font nominal size, or the size of the mouse
      cursor.

      I imagine that most people want the bottom of the mouse cursor to be the
      baseline of text characters. The font size is the total height of the
      character block including space for descenders, so presumably your shift
      is too large (makes the text appear higher than the mouse cursor, more
      visibly so on very large fonts) -- but probably better than no shift.

      The bbox right and bottom coordinates are placeholders just in case,
      they get adjusted later on as the text is edited so these initial values
      serve no real purpose; the +100 is just any value that might be a
      reasonable size for a blank text edit box, you could have taken
      ui.font_size or twice that if you prefer -- it won't make a difference.

      Denis

       
  • Jim

    Jim - 2017-08-12

    This has been an issue I've also found a bit annoying (this is not a complaint, thanks to Denis for making xournal available to everyone!) so I've been playing around a bit.

    As Denis says, subtracting ui.font_size is too much, the baseline is now above where the bottom of the text cursor was when I clicked. I would like to try adding the descender size back in, but I don't see any easy way to get that. (Is there an easy way?)

    I tried the brute force and ignorence way of multiplying ui.font_size by a constant, but the required multiplication factor is not a constant, as changing font sizes quickly demonstrates. (For what it is worth, I found
    item->bbox.top = pt[1] - ui.font_size;
    to be about right for Sans 10 on my system.

    Unfortunately, there is yet more to the problem. If I zoom to 100%, carefully align the bottom of the text cursor to a horizontal rule on a page, and insert text, then do the same thing after zooming to 200%, the baselines of the two texts are not aligned. Printing out the value of pt[1] shows me different values depending on my zoom level, regardless of how careful I am. I don't know if this is because the reference point of my cursor is not at its lower vertical pixel or whether it is something more nefarious. (I played around for a few minutes to see if I could find a reference point for the text cursor, but I had no luck.)

    Dirk, you didn't say what system you are on, but (at least on my system) there is nothing difficult about building xournal. So if you want to play around with this, perhaps there is no reason for that to stop you.

     

    Last edit: Jim 2017-08-12

Log in to post a comment.