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

Unified Diff: ui/views/examples/text_example.cc

Issue 2898613002: Revert of Support finer grained font weights on Mac. (Closed)
Patch Set: Created 3 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/examples/text_example.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/examples/text_example.cc
diff --git a/ui/views/examples/text_example.cc b/ui/views/examples/text_example.cc
index 6869b07604692bcc1b5603707437f1207ebd1d1b..05efef15f7b556d74f04bd8ca778ee32bc7f62ac 100644
--- a/ui/views/examples/text_example.cc
+++ b/ui/views/examples/text_example.cc
@@ -50,17 +50,6 @@
const char* kElideBehaviors[] = { "Elide", "No Elide", "Fade", };
const char* kPrefixOptions[] = { "Default", "Show", "Hide", };
const char* kHorizontalAligments[] = { "Default", "Left", "Center", "Right", };
-constexpr const char* kWeightLabels[] = {
- "Thin", "Extra Light", "Light", "Normal", "Medium",
- "Semibold", "Bold", "Extra Bold", "Black",
-};
-constexpr gfx::Font::Weight kFontWeights[]{
- gfx::Font::Weight::THIN, gfx::Font::Weight::EXTRA_LIGHT,
- gfx::Font::Weight::LIGHT, gfx::Font::Weight::NORMAL,
- gfx::Font::Weight::MEDIUM, gfx::Font::Weight::SEMIBOLD,
- gfx::Font::Weight::BOLD, gfx::Font::Weight::EXTRA_BOLD,
- gfx::Font::Weight::BLACK,
-};
// Toggles bit |flag| on |flags| based on state of |checkbox|.
void SetFlagFromCheckbox(Checkbox* checkbox, int* flags, int flag) {
@@ -98,23 +87,16 @@
void set_elide(gfx::ElideBehavior elide) { elide_ = elide; }
int GetStyle() const { return font_list_.GetFontStyle(); }
- void SetStyle(int style) {
- base_font_ = base_font_.DeriveWithStyle(style);
- font_list_ = font_list_.DeriveWithStyle(style);
- }
+ void SetStyle(int style) { font_list_ = font_list_.DeriveWithStyle(style); }
gfx::Font::Weight GetWeight() const { return font_list_.GetFontWeight(); }
void SetWeight(gfx::Font::Weight weight) {
- font_list_ = base_font_.DeriveWithWeight(weight);
+ font_list_ = font_list_.DeriveWithWeight(weight);
}
private:
// The font used for drawing the text.
gfx::FontList font_list_;
-
- // The font without any bold attributes. Mac font APIs struggle to derive UI
- // fonts from a base font that isn't NORMAL or BOLD.
- gfx::FontList base_font_;
// The text to draw.
base::string16 text_;
@@ -144,7 +126,7 @@
Combobox* TextExample::AddCombobox(GridLayout* layout,
const char* name,
- const char* const* strings,
+ const char** strings,
int count) {
layout->StartRow(0, 0);
layout->AddView(new Label(base::ASCIIToUTF16(name)));
@@ -181,13 +163,11 @@
arraysize(kPrefixOptions));
text_cb_ = AddCombobox(layout, "Example Text", kTextExamples,
arraysize(kTextExamples));
- weight_cb_ = AddCombobox(layout, "Font Weight", kWeightLabels,
- arraysize(kWeightLabels));
- weight_cb_->SelectValue(base::ASCIIToUTF16("Normal"));
layout->StartRow(0, 0);
multiline_checkbox_ = AddCheckbox(layout, "Multiline");
break_checkbox_ = AddCheckbox(layout, "Character Break");
+ bold_checkbox_ = AddCheckbox(layout, "Bold");
italic_checkbox_ = AddCheckbox(layout, "Italic");
underline_checkbox_ = AddCheckbox(layout, "Underline");
@@ -211,6 +191,8 @@
SetFlagFromCheckbox(underline_checkbox_, &style, gfx::Font::UNDERLINE);
text_view_->set_flags(flags);
text_view_->SetStyle(style);
+ text_view_->SetWeight(bold_checkbox_->checked() ? gfx::Font::Weight::BOLD
+ : gfx::Font::Weight::NORMAL);
text_view_->SchedulePaint();
}
@@ -272,8 +254,6 @@
flags |= gfx::Canvas::HIDE_PREFIX;
break;
}
- } else if (combobox == weight_cb_) {
- text_view_->SetWeight(kFontWeights[combobox->selected_index()]);
}
text_view_->set_flags(flags);
text_view_->SchedulePaint();
« no previous file with comments | « ui/views/examples/text_example.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698