octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI font and cursor location


From: Michael Goffioul
Subject: Re: GUI font and cursor location
Date: Sat, 28 Jul 2012 09:47:27 +0100

On Fri, Jul 27, 2012 at 6:53 PM, Doug Stewart <address@hidden> wrote:
This mostly for the GUI developers.

 This is about the issue of font spacing in qterminal

What I did(method of trouble shooting):
   I got debug working for the qterminal, and then set the default font to 
   values 8,9,10,11,12,13 (in line 56 of QUnixTerminalImpl.cpp)  and watched what the values were of 
-  _fontWidth (line 171 in TerminalView.cpp)
-   fw  ( about line 172 in TerminalView.cpp)
-  _fontHeight ( line 164 in TerminalView.cpp)

and saw this result
 Font size               _fontWidth      fw    _fontHeight
     8                        7                        6         13
     9                        8                        7         15
     10                      8                        8         17
     11                      9                        9         18
     12                     10                      10        19
     13                     11                      10        22


See that _fontWidth anf fw are different for some values.

  My conclution:
    
   I think the method used is wrong because:
line 171 of TerminalView is
  _fontWidth = qRound((double)fm.width(REPCHAR)/(double)strlen(REPCHAR));
     where REPCHAR is "abcdefgh ... xyzABCD...1234 ... +? etc" all the chars available.
  With this aproach _fontWidth is an integer which is used as a pixel spacing for each letter on the screen and for the curser position. But this is wrong. What should be done is _fontWidth should be a double and the calculation for the pixel location should be done using doubles until it is absoluty needed to have an integer for the pixel location. This will reduce the error.

I don't think this is the intended behavior. The idea is to compute a fixed cell width for any character (in a terminal window, all characters are vertically and horizontally aligned in a fixed grid). In order to do that, you have to used a fixed pixel width/height. If you are experiencing mis-alignment, I don't think it's due to _fontWidth/_fontHeight being integers.

The fact that _fontWidth and fw are different is due to the fact that you're using a non-monospace font (otherwise they would be equal). Non-monospace fonts are not suited for rendering in a terminal.

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]