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: Mon, 30 Jul 2012 09:14:11 +0100

On Mon, Jul 30, 2012 at 1:33 AM, Mike Miller <address@hidden> wrote:
> > What is weird is that you guys are observing the issue for any monospace
> > font. Mike, could you add further debug lines in TerminalView.cpp to check
> > what's the value of _fontWidth and fw, as well as 'fm.width("m")', when you
> > use the Inconsolata font as shown in your screenshot.
> >
> > I'm not against Doug's patch, actually it should be completely transparent
> > when you use a monospace font (as _fontWidth will be an integer value
> > anyway).
> >
>
> OK we might be getting closer to the problem. When  we made _fontWidth a
> double it was not close to an integer.
> Ubuntu 10.04 and Ubuntu 12.04

Yes, I'm seeing that the result before rounding is not near an even
integer. The _fixedFont loop is saying that all characters in REPCHAR
have the same width, but the width of the entire string is apparently
not the sum of its parts...

This is my debug after setting the font to Inconsolata 16.

_fontWidth = 11 (before round = 10.651515)
fm.width(REPCHAR) = 703
strlen(REPCHAR) = 66
fw = 11
fm.width("m") = 11
fm.width("l") = 11
_fixedFont = true

There's something fishy here. In a monospace font, the width of a string should be the sum of the width of its characters. For your information, in general the width of a string is a complex stuff: obviously it depends on the width of individual chars, but also on additional information (iirc called "kerning"). Basically one character (e.g. 'b'), when preceded by another specific char (e.g. 'i'), can be slightly offset to the left to make it look better. In a monospace font, all characters should have the same width and there should be no kerning.

In attachment, I provided a patch I apply on qterminal/main.cpp to allow easy change of the font (on the command line) and give some debug information at startup. You might find it useful.

I've tested the average font width (_fontWidth) with the mono fonts I have and I invariably get (for REPCHAR) a total width of 858, which is exactly 66*13. The only exception is FreeeMono. Would you mind experimenting with repChar (see my patch) to determine whether the non-constant font metrics is coming form a specific character or is general to the font? I'm really puzzled about your issue; I've tested it on my F16 and F17 boxes and I can't reproduce it.

Michael.

Attachment: qterminal.diff
Description: Binary data


reply via email to

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