Bug 283106 - Button text vertical alignment is off with Oxygen theme.
Summary: Button text vertical alignment is off with Oxygen theme.
Status: RESOLVED INTENTIONAL
Alias: None
Product: Oxygen
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-30 16:51 UTC by Alistair Buxton
Modified: 2011-10-03 22:31 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot showing the problem. (17.90 KB, image/png)
2011-09-30 16:51 UTC, Alistair Buxton
Details
My understanding of the problem. (12.75 KB, image/png)
2011-10-03 22:31 UTC, Alistair Buxton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alistair Buxton 2011-09-30 16:51:53 UTC
Created attachment 64103 [details]
Screenshot showing the problem.

Version:           unspecified (using KDE 4.7.1) 
OS:                Linux

When Oxygen theme is in use, the button captions/labels and incorrectly aligned vertically. By default they are too close to the bottom of the button. The problem gets worse as the font gets smaller.

Reproducible: Always

Steps to Reproduce:
Install KDE.

Actual Results:  
The vertical alignment of button text is inconsistent.

Expected Results:  
The ratio of the distance from the top of a button to the top of a capital letter in the button caption to the distance between the bottom of a capital letter in the caption and the bottom of the button should, at the very least, always be the same. And preferably it should equal 1.
Comment 1 Hugo Pereira Da Costa 2011-10-03 10:32:06 UTC
Can you tell me which font size you are using.
I don't have the issue you mention: http://i.imgur.com/3WHjt.png
Comment 2 Christoph Feck 2011-10-03 17:19:18 UTC
First, centering is subjective, and I would agree with the reporter (even on the screen shot from comment #1). Second, it isn't just the font height, but also the font's baseline and other attributes that affect centering. Third, it looks like those attributes are computed differently for each Qt or freetype version, so centering could look different even with the same font.
Comment 3 Christoph Feck 2011-10-03 17:26:13 UTC
I maybe should add that it is possible to customize the vertical text shift from within the style (see Skulpture implementation), but I consider this a hack and really would prefer a solution within Qt or freetype, so that it works with all text, and not just that rendered via style calls.

Independed of the issues mentioned in comment #2, the default text position should be "mathematically" correct, i.e. the bounding box of the text should be correctly centered within the frame. To check that, you could add debug code to render those bounding boxes together with each drawItemText call.
Comment 4 Hugo Pereira Da Costa 2011-10-03 18:01:58 UTC
@Christoph (comment #3)
That was my plan, but ... there are complications.
Oxygen buttons themselves  (the plain slab part) are not centered inside their rect, because of the top/bottom asymetric shadows.

So, possibilities: 
1) I center label with respect to the button bounding rect (which I think is what is coded now) and you end-up with text disalign with respect to the slab.

2) I center label with respect to the button "slab" (inside the shadow), but then text is misaligned with respect to e.g. neighbor labels, or text entries, etc.

3) I make the button slab centered in their bounding rect (in which case 1 and 2 become equivalent), but then loose pixels at the top of them all, and people already complained about this. (besides, this will break all other types of alignment with respect to neighbor raised frames).

All in all, since their is no overlap, I'm inclined to double-check that 1/ is indeed what's implemented (using your way), and if yes, close as wontfix, (sorry).
Comment 5 Hugo Pereira Da Costa 2011-10-03 18:04:38 UTC
ok. So in fact, double-checking was easy enough.
See: http://i.imgur.com/coxva.png

In the label on the left, the text is naturally centered wrt its bounding rect (that's Qt's internal).

Since text in the button is aligned with labels, it must be centered too.

... wont fix.
(believe me: I did spend hours on getting the alignment, if not "right", at least: as good as I could).
Comment 6 Alistair Buxton 2011-10-03 19:41:54 UTC
FWIW the font is Ubuntu. It's The Kubuntu installer. I think it is 10pt but it is hard to know.

I don't understand what your screenshot is supposed to demonstrate. That the vertical alignment is correct with one specific font/size?

In my screenshot, the button icons are correctly aligned, so why can't the text also be?

This isn't just a problem that I have with Oxygen - it happens with nearly every KDE theme. I reported it against Oxygen purely because it is the default theme. The only theme that doesn't seem to have this problem is QTCurve.
Comment 7 Hugo Pereira Da Costa 2011-10-03 20:18:59 UTC
@Alistair,
the point with my screenshot is that the button text is vertically aligned with the "label" text on the left of the first button. As it should (right?)
This is true (this vertical alignment), with all font sizes I've tried.
And means that the text positioning is actually right. The thing which is  not "right" is the button frame positioning itself, which is off center because of its shadow, and which I can't center better without adding more empty pixels "outside" of the buttons -at the top-, a thing that people already complained about.

Hence my won't fix. Can't make everybody happy here ...
Also, if you compare "oxygen-demo" (buttons tab) with "oxygen-demo -style qtcurve", you'll see that the icons are as much off center as the text, with respect to QtCurve. At least that's my observation with the font-size I'm using (8pt)

Hoping these explanations are clearer,

Hugo
Comment 8 Hugo Pereira Da Costa 2011-10-03 20:20:22 UTC
PS: the reason why it works with QtCurve and not with Oxygen is because the buttons shadows are symetric top/bottom, so that the button frame is centered.
Comment 9 Alistair Buxton 2011-10-03 22:31:52 UTC
Created attachment 64183 [details]
My understanding of the problem.

I counted the pixels and you are correct. WRT the shadows, both the icons and the text are perfectly centred in my screenshot.

You are right to say that the text of a label should be aligned with the text of a button. However, if you were to change the background of that label, the resulting coloured rectangular area should be the same height as the face of the button, not including the shadows. I say this assuming that the button is supposed to look like a raised area lit from behind and slightly above the viewer, causing the larger shadow at the bottom.

I assume from your explanation of frames that this is not the case, in which case I consider the height of labels to be another bug. An incredibly hard to fix bug, but a bug none the less.

See attached diagram, which is exaggerated for clarity. Is it an accurate reflection of what is happening here?