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

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: Add a lost comment and modify a render text unittest to not test black because of test env font con… Created 4 years, 7 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
« no previous file with comments | « ui/views/controls/styled_label.h ('k') | ui/views/controls/styled_label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/styled_label.cc
diff --git a/ui/views/controls/styled_label.cc b/ui/views/controls/styled_label.cc
index f46c93c046f5b9de5d231fcad4c2ad1fceddc17f..18e2bb95b92321fd3038ea45fe935677f57824dd 100644
--- a/ui/views/controls/styled_label.cc
+++ b/ui/views/controls/styled_label.cc
@@ -54,9 +54,10 @@ std::unique_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 @@ std::unique_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) {}
@@ -276,8 +278,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,
« no previous file with comments | « ui/views/controls/styled_label.h ('k') | ui/views/controls/styled_label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698