Merge lp:~azzar1/unity/lp-886478 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3926
Proposed branch: lp:~azzar1/unity/lp-886478
Merge into: lp:unity
Diff against target: 120 lines (+49/-2)
3 files modified
launcher/SwitcherView.cpp (+2/-1)
unity-shared/StaticCairoText.cpp (+42/-1)
unity-shared/StaticCairoText.h (+5/-0)
To merge this branch: bzr merge lp:~azzar1/unity/lp-886478
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+244453@code.launchpad.net

Commit message

Remove FontSettings.*.
Add the possibility to specify the font size and the font weight without chaning the default font name.
Fix lp 886478.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Very nice. LGTM and working here.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Notsure FontSettings should be removed. Marking as WIP.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

Should be fine now!

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherView.cpp'
2--- launcher/SwitcherView.cpp 2014-09-04 22:11:18 +0000
3+++ launcher/SwitcherView.cpp 2015-02-13 17:19:50 +0000
4@@ -81,7 +81,8 @@
5 text_view_->SetMaximumWidth(tile_size * TEXT_TILE_MULTIPLIER);
6 text_view_->SetLines(-1);
7 text_view_->SetTextColor(nux::color::White);
8- text_view_->SetFont("Ubuntu Bold 10");
9+ text_view_->SetFontSize(10);
10+ text_view_->SetFontWeight(PANGO_WEIGHT_BOLD);
11 text_view_->SetScale(scale);
12
13 icon_size.changed.connect(sigc::mem_fun(this, &SwitcherView::OnIconSizeChanged));
14
15=== modified file 'unity-shared/StaticCairoText.cpp'
16--- unity-shared/StaticCairoText.cpp 2014-10-15 05:26:03 +0000
17+++ unity-shared/StaticCairoText.cpp 2015-02-13 17:19:50 +0000
18@@ -30,7 +30,6 @@
19 #include <Nux/TextureArea.h>
20 #include <NuxGraphics/CairoGraphics.h>
21
22-#include <pango/pango.h>
23 #include <pango/pangocairo.h>
24
25 #include <UnityCore/GLibWrapper.h>
26@@ -95,6 +94,8 @@
27 UnderlineState underline_;
28
29 std::string font_;
30+ int font_size_ = -1;
31+ PangoWeight font_weight_ = (PangoWeight) -1;
32
33 std::list<BaseTexturePtr> textures2D_;
34
35@@ -418,6 +419,32 @@
36 }
37 }
38
39+void StaticCairoText::SetFontSize(int font_size)
40+{
41+ if (pimpl->font_size_ != font_size)
42+ {
43+ pimpl->font_size_ = font_size;
44+ pimpl->need_new_extent_cache_ = true;
45+ Size s = GetTextExtents();
46+ SetMinimumHeight(s.height);
47+ NeedRedraw();
48+ sigFontChanged.emit(this);
49+ }
50+}
51+
52+void StaticCairoText::SetFontWeight(PangoWeight font_weight)
53+{
54+ if (pimpl->font_weight_ != font_weight)
55+ {
56+ pimpl->font_weight_ = font_weight;
57+ pimpl->need_new_extent_cache_ = true;
58+ Size s = GetTextExtents();
59+ SetMinimumHeight(s.height);
60+ NeedRedraw();
61+ sigFontChanged.emit(this);
62+ }
63+}
64+
65 std::string StaticCairoText::GetFont()
66 {
67 return pimpl->font_;
68@@ -559,6 +586,13 @@
69
70 layout = pango_cairo_create_layout(cr);
71 desc = pango_font_description_from_string(font.c_str());
72+
73+ if (font_size_ > 0)
74+ pango_font_description_set_size(desc, font_size_ * PANGO_SCALE);
75+
76+ if (font_weight_ > 0)
77+ pango_font_description_set_weight(desc, font_weight_);
78+
79 pango_layout_set_font_description(layout, desc);
80 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
81 pango_layout_set_ellipsize(layout, GetPangoEllipsizeMode());
82@@ -709,6 +743,13 @@
83
84
85 desc = pango_font_description_from_string(font.c_str());
86+
87+ if (font_size_ > 0)
88+ pango_font_description_set_size(desc, font_size_ * PANGO_SCALE);
89+
90+ if (font_weight_ > 0)
91+ pango_font_description_set_weight(desc, font_weight_);
92+
93 pango_layout_set_font_description(layout, desc);
94 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
95 pango_layout_set_ellipsize(layout, GetPangoEllipsizeMode());
96
97=== modified file 'unity-shared/StaticCairoText.h'
98--- unity-shared/StaticCairoText.h 2014-02-25 04:59:37 +0000
99+++ unity-shared/StaticCairoText.h 2015-02-13 17:19:50 +0000
100@@ -21,6 +21,7 @@
101 #ifndef UNITYSHARED_STATICCAIROTEXT_H
102 #define UNITYSHARED_STATICCAIROTEXT_H
103
104+#include <pango/pango.h>
105 #include <string>
106
107 #include <Nux/Nux.h>
108@@ -82,8 +83,12 @@
109 void SetTextEllipsize(EllipsizeState state);
110 void SetTextAlignment(AlignState state);
111 void SetTextVerticalAlignment(AlignState state);
112+
113 void SetFont(std::string const& font);
114+ void SetFontSize(int);
115+ void SetFontWeight(PangoWeight);
116 std::string GetFont();
117+
118 void SetUnderline(UnderlineState underline);
119 void SetLines(int maximum_lines);
120 void SetLineSpacing(float line_spacing);