[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GUI font and cursor location
From: |
Mike Miller |
Subject: |
Re: GUI font and cursor location |
Date: |
Mon, 30 Jul 2012 08:48:02 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Jul 30, 2012 at 09:14:11AM +0100, Michael Goffioul wrote:
> On Mon, Jul 30, 2012 at 1:33 AM, Mike Miller <address@hidden> wrote:
> >
> > 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.
Yep, I agree with that. And you've seen on my screenshot that the
characters do have equal width. I can produces lines of arbitrary
characters and they are fixed width.
> 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.
Yes, I've applied your patch and added a little more.
With all the fonts I've tested I get a non-integer average font width.
With a point size of 16, the total width of repChar and average width
are:
Courier (actually Nimbus Mono L on my system): len=845, avg=12.803
Droid Sans Mono: len=831, avg=12.5909
FreeMono: len=831, avg=12.5909
Inconsolata: len=703, avg=10.6515
Liberation Mono: len=831, avg=12.5909
Ubuntu Mono: len=692, avg=10.4848
I added the following extra debug in main right after yours:
bool fixed = true;
for (int i = 0; i < repChar.length(); i++) {
if (fm.width(repChar[i]) != fm.width("m")) {
fixed = false;
qDebug("fm.width(\"%c\") != fm.width(\"m\")", repChar[i].toAscii());
}
}
if (fixed)
qDebug("All chars in repChar have equal width");
qDebug("fm.width(\"m\") = %d", fm.width("m"));
qDebug("fm.width(\"mm\") = %d", fm.width("mm"));
qDebug("fm.width(\"mmmmmmmm\") = %d", fm.width("mmmmmmmm"));
All of the fonts report equal width when testing a single character at a
time. However, the width of two or more m's is not N times the width of
one. The width of a single m is 13 for Nimbus Mono, Droid Sans Mono,
FreeMono, and Liberation Mono. 8 m's is 102 for Nimbus, 101 for the
rest. Inconsolata reports 11 for a single m, 85 for 8 m's. And Ubuntu
Mono reports 10 for a single m, 84 for 8 m's. This is the only one that
has a larger width for multiple characters, which is why I see the
characters being truncated by the cursor in that font.
Which version of Qt do you have in Fedora? I have 4.8.2.
That's about all I have time for until later this evening. I just did
some quick searching and found a few links indicating this might be a
feature of 4.8:
https://git.reviewboard.kde.org/r/102899/
https://bugreports.qt-project.org/browse/QTBUG-22040
I also see in the QFont API doc in 4.8 that it mentions supporting
"font engines that support fractional font metrics".
https://qt-project.org/doc/qt-4.8/qfont.html#StyleStrategy-enum
--
mike
- Re: GUI font and cursor location, (continued)
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/29
- Re: GUI font and cursor location, Doug Stewart, 2012/07/29
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/29
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/29
- Re: GUI font and cursor location, Doug Stewart, 2012/07/29
- Re: GUI font and cursor location, Mike Miller, 2012/07/29
- Message not available
- Message not available
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/29
- Re: GUI font and cursor location, Doug Stewart, 2012/07/29
- Re: GUI font and cursor location, Mike Miller, 2012/07/29
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/30
- Re: GUI font and cursor location,
Mike Miller <=
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/30
- Re: GUI font and cursor location, Mike Miller, 2012/07/30
- Re: GUI font and cursor location, Ben Abbott, 2012/07/30
- Re: GUI font and cursor location, Mike Miller, 2012/07/30
- Re: GUI font and cursor location, Doug Stewart, 2012/07/30
- Re: GUI font and cursor location, Mike Miller, 2012/07/30
- Re: GUI font and cursor location, Michael Goffioul, 2012/07/31
- Re: GUI font and cursor location, Doug Stewart, 2012/07/29