Lens button set narrow width which is needed

Bug #856277 reported by Mitsuya Shibata
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Unity
Fix Released
High
Andrea Azzarone
unity (Ubuntu)
High
Andrea Azzarone

Bug Description

Lens button width is narrow rather than is needed, therefore parts
of button label are shortened and/or become unreadable in specific
text.

How to reproduce(easy):
1. Set locale to ja_JP.UTF-8 by language-selector
2. Open application lens by Super+A
3. Open "Filter results" ("結果の絞り込み" in Japanese)
4. Check label of top-left bottun

Expected result: "すべて" ("All" in English)
Actual result: "..."

How to reproduce(by recompile unity):
1. Replace _("All") to _("XXXXX") at 2 places
   in plugins/unityshell/src/FilterGenreWidget.cpp
2. Recompile unity
3. Open application lens by Super+A
4. Open "Filter results"
5. Check label of top-left bottun

Expected result:
"XXXXX" (Because there is enough space, shouldn't shorten label)
Actual result: "XXX..."

And if you set more long label, **always** is shortened "about two
characters". For example, "XXXXXYYYYY"(10 chars) is rendered as
"XXXXXYY...".

Tanaka and Akabe reported by Japanese(LP: #852948), and they
attached screenshot.
https://bugs.launchpad.net/ubuntu-jp-improvement/+bug/852948/+attachment/2424959/+files/dash-files-dots-en.png
https://bugs.launchpad.net/ubuntu-jp-improvement/+bug/852948/+attachment/2424960/+files/dash-musics-dots-en.png

Related branches

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

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.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

How to fix(simple way, but workaround):
1. Set nux default font "Ubuntu 11" (nux.diff).
This fix broader label problem as like "All" button. But cann't fix
narrow button as like MultiButton at "Size" in file lens.

2. To set cairo canvas width, dosn't cut off side margin (unity.diff).
Narrow button has not enough space to render. If set cairo canvas
width with cutted of side margin, label width match or over canvas
width, almost label is shortened.

The way is very simple. but has two problems.

1. Font in nux is hard corded. Couldn't follow up changing UI font.
2. Width is calculated excess, and label little over separater line.

I attached patch fo this way.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Screenshot for probrem 2 in comment #2.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

How to fix(more correct way):
Nux cannot get system value via gtk(nux::GetSysFont can use this
purpose?). Unity needs to notify font name to nux. nux:StaticText
has method SetFont, but this instance lives only in
nux::Button::RebuildLayout. RebuildLayout is called at nux::Button
label is changed.

Additionaly above, MultiButton is too narrow for all language.
It is proper to say that look nicely in English. However there
is no space to translate it.

Example in music lense, "90s" in English is translated to "90年代" in
Japanese. Translator needs over double space to compare to English.

Summed up above, we needs followings:
* nux::Button should have member font_string_ and SetFont method for
  label layout.
* In Unity, call nux::Button::SetFont at appropriate time. I think
  that unity::FilterBasicButton::InitTheme is good.
* MultiButton shuld not use one line to get space for all languages.
  It seems to make two raw button is nicely.

tags: added: patch
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "nux.diff" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-sponsors please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

Revision history for this message
Omer Akram (om26er) wrote : Re: Lens button set narraw width which is needed

Since I don't read/write japanese I have really hard times understanding this bug report. Can you highlight certain parts in the interface which are wrong and how they should look?

Changed in nux:
status: New → Incomplete
Changed in unity (Ubuntu):
status: New → Incomplete
Changed in unity:
status: New → Incomplete
Revision history for this message
Koichi Akabe (vbkaisetsu) wrote :

Non-English users use other fonts and translated texts' size are different with English's one.
So labels are too small to show texts in some envionments.

For example, "All" is translated to "すべて" in Japanese environment. But "すべて" uses more space than "All", so it is replaced to "..." and we can't read it.

Unity should get the size of texts and apply it to the size of labels.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi om26er,

My apologize for inconvenience bug report.
I attached illustrated explanation.

Left side is current state, right side is state after apply unity.diff and nux.diff.

Neil J. Patel (njpatel)
Changed in unity:
status: Incomplete → Confirmed
Changed in unity (Ubuntu):
status: Incomplete → Confirmed
Changed in unity:
milestone: none → 4.26.0
importance: Undecided → High
Changed in unity (Ubuntu):
importance: Undecided → High
Changed in nux:
status: Incomplete → Confirmed
Ingo Gerth (igerth)
summary: - Lens button set narraw width which is needed
+ Lens button set narrow width which is needed
Didier Roche (didrocks)
Changed in nux (Ubuntu):
status: New → Confirmed
David Barth (dbarth)
Changed in unity:
milestone: 4.26.0 → 4.28.0
Omer Akram (om26er)
Changed in unity:
milestone: 4.28.0 → 4.30.0
Omer Akram (om26er)
Changed in unity:
milestone: 4.30.0 → none
Changed in nux:
importance: Undecided → High
Changed in nux (Ubuntu):
importance: Undecided → High
Andrea Azzarone (azzar1)
Changed in nux:
status: Confirmed → Invalid
Changed in unity:
assignee: nobody → Andrea Azzarone (andyrock)
Changed in unity (Ubuntu):
assignee: nobody → Andrea Azzarone (andyrock)
Changed in unity:
milestone: none → 6.6
Changed in unity (Ubuntu):
status: Confirmed → Invalid
Andrea Azzarone (azzar1)
Changed in unity:
status: Confirmed → In Progress
Changed in nux (Ubuntu):
status: Confirmed → In Progress
status: In Progress → Invalid
Changed in unity (Ubuntu):
status: Invalid → Confirmed
status: Confirmed → In Progress
Changed in nux:
importance: High → Undecided
Omer Akram (om26er)
no longer affects: nux
no longer affects: nux (Ubuntu)
Andrea Azzarone (azzar1)
Changed in unity:
status: In Progress → Fix Committed
Changed in unity (Ubuntu):
status: In Progress → Fix Committed
Changed in unity:
milestone: 6.6 → 7.0
Omer Akram (om26er)
no longer affects: unity/6.0
Changed in unity:
milestone: 7.0 → 6.6
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

The fix for this has caused a regression in the font size in the Dash filter buttons.
Possibly requires more thought into the layout of the filters.

Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (9.2 KiB)

This bug was fixed in the package unity - 6.6.0-0ubuntu1

---------------
unity (6.6.0-0ubuntu1) quantal-proposed; urgency=low

  * New upstream release.
    - Fixes non-escaped character sequences in dash previews (LP: #1039020)
    - Updated background layer for preview cover-art and details panels
      to be 10% low-light
    - Expand a PlacesGroup if it is the only category that contains results
      (LP: #950710)
    - Update unity autopilot tests to match autopilot API
    - Updated the convert files to fix some typos in the key names
    - Add gmodule dependency
    - Activate proper result if the categories aren't displayed in-order
      (LP: #1040101)
    - Refactor device launcher icons (LP: #713423)
    - LauncherController: make the controller enable the launcher struts,
      based on hide-mode option (LP: #1044005)
    - Launcher: make always possible to drag an icon to the bottom or top
      of its sub list (LP: #1043968)
    - Don't desat bfb/hud icon in DNDReset (LP: #1043963)
    - Progressively adjust the speed of the minimize animation. First
      time it is used is slower, then speeds up the more it is used.
      (LP: #1017510)
    - Implement new ordering of categories for home lens. (LP: #1043915)
    - UnityWindow now implements ScaleWindowInterface (LP: #876017)
    - Launcher: restore an icon position after that the dragging has been
      cancelled (LP: #955561)
    - LauncherDragWindow: cancel drag on window mapped/unmapped
      (LP: #1044723)
    - Now there is a check of an override color in RefreshColor (which is
      called when a PropertyNotify event happens). Also added a check in
      FullySaturateColor to a void division by zero. (LP: #975350)
    - Queue redraw after cover-art texture is updated from a url/file source.
      (LP: #1043947)
    - Fixed ability to delete glib::Source wrapper during its callback
      (LP: #1044823)
    - Close preview when dash is hidden. (LP: #1045298)
    - LauncherModel: rewrite the Reordering functions to keep the icon
      priority deltas (LP: #761155)
    - Make sure we can pass extra hints when activating preview actions.
      (LP: #1046352)
    - UnityWindow: scale window code improved (LP: #1033935)
    - The mouse will now cause the HUD buttons to change selection
      (LP: #1042692)
    - "Alt+Space" shortcut to reveal the window menu is not hardcoded, but a
       Compiz key option. " (Hold)" should also be translated. Made all
       Compiz plug-in names and all Compiz plug-in option names in
       unityshell.cpp static constants.
    - remove unity --reset, it's not anymore really needed now that we are
      in stable days of unity and we moved to gsettings
    - Removed the variables 'oldPrev' and 'oldNext' which got assigned the
      value NULL, but then were never used
    - Fixed the size of the previews to 770x380 pixels. (LP: #1045243)
    - UnityWindow: use smart pointers, use static close_icon (with dynamic
      state) and PanelStyle context (LP: #1033935) (LP: #1045127)
      (LP: #1046124) (LP: #1046126)
    - Remove everything in the #ifndef USE_MODERN_COMPIZ_GL ifdefs and remove
      the ifdefs alltogether. unity now requires compiz...

Read more...

Changed in unity (Ubuntu):
status: Fix Committed → Fix Released
Changed in unity:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers