Comment 1 for bug 856277

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote : Re: Lens button set narraw width which is needed

Short conclusion of reason:
If default UI font is not "Ubuntu 10", UI is broken.

Following is long long details (please correct me if I'm wrong):
First of all, Unity button(unity::FilterBasicButton) has 2 labels.
1. Calculated label: It is member of nux::Button wich is inherited
   by FilterBasicButton, and this label is used to calculate box
   size by nux::StaticText.
2. Displayed label: It is member of unity::FilterBasicButton, and
   rendered via unity::DashStyle::Button.

nux::StaticText calculate box size by font
(nux::StaticText::_font_string) and Pango/Cairo renderer (see
nux::StaticText::GetTextSize). Then to redraw label
(nux::StaticText::UpdateTextRendering), set minimum/maximum box size
calculated it by nux::Area::SetMinMaxSize.

nux::StaticText::_font_string is setted default value at "Ubuntu 10".
And _font_string is not changed in instance liftime (i.e. always use
"Ubuntu 10").

This size is refered by calling nux::Area::GetGeometry
at unity::FilterBasicButton::InitTheme. And it is used to set cairo
image size at cairo_image_surface_create().

unity::DashStyle::Button is rendered its label at
unity::DashStyle::Impl::Text. At the time, unity get font from
GtkSettings (in my environment "Ubuntu 11") and use it to layout.

Impl::Text method calculates label width and set margin below steps.
1. Get cairo width by cairo_image_surface_get_width(), and save to "w".
   i.e. width base "Ubuntu 10"
2. Cut side margin: w -= 2*horizMargin
3. Set canvas width: pango_layout_set_width(layout, w * PANGO_SCALE);
4. Centering and draw label with system font ("Ubuntu 11").

However label width with Ubuntu 11 is wider than Ubuntu 10,
therefore button label is shorten.

Why do not reproduce in "All":
"All" is very narrow text, therefore error is small relatively, and
unity can render it.