Button label centering with GTK+2
raananb
raanan at barzel.org
Thu May 22 03:57:42 PDT 2008
Some further experimentation (see http://erbarzel.club.fr/Fonts.jpg)
Three buttons in FreeSans font:
"Get pictures" is in size 8
"Folder" 10
"Sort by date" 12
Two buttons in Sans font:
"Select All" 10
"Rename" 12
None is in bold.
My conclusion is that (1) the fonts have a preset margin which shows up when
the button is not tall enough to accomodate the font and it margins: the
upper margin is rendered and the rest is drawn in whatever is left and (2)
the rendering engine does not try to center the text by reducing these
margins when the button cannot accomodate the font and its margins.
The first thing is a given, probably resulting from ages of font design
which incorporates spacing in each letter block. This could probably be done
away with today, when spacing could be left to the computer to compute, but
is not likely to happen any time soon.
The second could be improved, by disregarding the margins when they
interfere.
I guess that in the meantime, size selection is the only way to solve the
issue.
Julian Smart wrote:
>
> If I add this to the end of the frame constructor in the minimal sample
> in wxWidgets 2.8 (today's SVN):
>
> wxFont font(*wxNORMAL_FONT);
> font.SetWeight(wxBOLD);
>
> wxPanel* panel = new wxPanel(this, wxID_ANY);
> wxButton* button = new wxButton(panel, wxID_OK, wxT("Hello"),
> wxPoint(10, 10), wxSize(200, -1));
> button->SetFont(font);
>
> I get a bold button correctly centred in both orientations (Debian Etch,
> Gnome).
>
> Perhaps you could try the above, and if you still get the off-centre
> label then that could indicate a difference either in GTK+ or in version
> of wxGTK, or maybe related to the version of desktop environment or theme.
>
> I'd suggest simply not using bold. It may make the user think it's the
> default button.
>
> Regards,
>
> Julian
>
> raananb wrote:
>> Packages are identified as
>> Thanks.
>> Installed packages:
>>
>> gtk2-engines 1:2.14.1-0ubuntu1
>> gtk2-engines-murrine 0.53.1-1ubuntu1
>> gtk2-engines-pixbuf 2.12.9-3ubuntu4
>>
>> apt-get update + apt-get upgrade did not provide a newer library.
>>
>> Does this provide any useful information?
>>
>> Where do I go from here?
>>
>>
>> Igor Korot wrote:
>>
>>> What GTK version do you use? Is upgrading GTK help?
>>>
>>> Maybe it's a GTK bug/limitation...
>>>
>>> Thank you.
>>>
>>> -----Original Message-----
>>>
>>>> From: Vadim Zeitlin <vadim at wxwidgets.org>
>>>> Sent: May 21, 2008 5:49 AM
>>>> To: wx-users at lists.wxwidgets.org
>>>> Subject: Re[2]: Button label centering with GTK+2
>>>>
>>>> On Tue, 20 May 2008 14:25:41 -0700 (PDT) raananb <raanan at barzel.org>
>>>>
>> wrote:
>>
>>>> r> Tried different sequences, but no improvement. I did notice that the
>>>>
>> problem
>>
>>>> r> is present with the larger font even if it is normal (not bold).
>>>>
>>>> Sorry, you've already tried everything I could think of. I really don't
>>>> know why doesn't gtk_button_set_alignment() work and have no other
>>>> ideas
>>>> about how to fix it unfortunately.
>>>>
>>>> Regards,
>>>> VZ
>>>>
>>>> --
>>>> TT-Solutions: wxWidgets consultancy and technical support
>>>> http://www.tt-solutions.com/
>>>>
>>>> _______________________________________________
>>>> wx-users mailing list
>>>> wx-users at lists.wxwidgets.org
>>>> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>>>>
>>> _______________________________________________
>>> wx-users mailing list
>>> wx-users at lists.wxwidgets.org
>>> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>>>
>>>
>>>
>>
>>
>
>
> --
> Julian Smart, Anthemion Software Ltd.
> 28/5 Gillespie Crescent, Edinburgh, Midlothian, EH10 4HU
> www.anthemion.co.uk | +44 (0)131 229 5306
> Tools for writers: www.writerscafe.co.uk
> wxWidgets RAD: www.anthemion.co.uk/dialogblocks
>
> _______________________________________________
> wx-users mailing list
> wx-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>
>
--
View this message in context: http://www.nabble.com/Button-label-centering-with-GTK%2B2-tp17316490p17401834.html
Sent from the wxWidgets - Users mailing list archive at Nabble.com.
More information about the wx-users
mailing list