Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: ui/views/controls/styled_label.cc

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for review issues. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/styled_label.cc
diff --git a/ui/views/controls/styled_label.cc b/ui/views/controls/styled_label.cc
index 3909e7f021bacf5b929563543e47e026fe6de421..ec10c44ac48c5df2ee095ad005bbe3b601dc4bc3 100644
--- a/ui/views/controls/styled_label.cc
+++ b/ui/views/controls/styled_label.cc
@@ -54,9 +54,10 @@ scoped_ptr<Label> CreateLabelRange(
if (!style_info.tooltip.empty())
result->SetTooltipText(style_info.tooltip);
- if (style_info.font_style != gfx::Font::NORMAL) {
- result->SetFontList(
- result->font_list().DeriveWithStyle(style_info.font_style));
+ if (style_info.font_style != gfx::Font::NORMAL ||
+ style_info.weight != gfx::Font::Weight::NORMAL) {
+ result->SetFontList(result->font_list().Derive(0, style_info.font_style,
+ style_info.weight));
}
return result;
@@ -69,6 +70,7 @@ scoped_ptr<Label> CreateLabelRange(
StyledLabel::RangeStyleInfo::RangeStyleInfo()
: font_style(gfx::Font::NORMAL),
+ weight(gfx::Font::Weight::NORMAL),
color(SK_ColorTRANSPARENT),
disable_line_wrapping(false),
is_link(false) {}
@@ -275,8 +277,9 @@ gfx::Size StyledLabel::CalculateAndDoLayout(int width, bool dry_run) {
// style may differ from the base font. The font specified by the range
// should be used when eliding text.
if (position >= range.start()) {
- text_font_list = text_font_list.DeriveWithStyle(
- current_range->style_info.font_style);
+ text_font_list =
+ text_font_list.Derive(0, current_range->style_info.font_style,
+ current_range->style_info.weight);
}
gfx::ElideRectangleText(remaining_string,
text_font_list,

Powered by Google App Engine
This is Rietveld 408576698