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

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

Issue 19666006: Supports FontList in Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« ui/gfx/render_text.h ('K') | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 258e90b6acb8f276dd872c5d21b27209974c6dd1..6b6f8c9d3b1f130474d0660a8828ddd3ef5801b0 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -270,13 +270,21 @@ void Textfield::SetCursorEnabled(bool enabled) {
native_wrapper_->SetCursorEnabled(enabled);
}
-void Textfield::SetFont(const gfx::Font& font) {
- font_ = font;
+void Textfield::SetFontList(const gfx::FontList& font_list) {
+ font_list_ = font_list;
if (native_wrapper_)
native_wrapper_->UpdateFont();
PreferredSizeChanged();
}
+const gfx::Font& Textfield::GetPrimaryFont() const {
+ return font_list_.GetPrimaryFont();
+}
+
+void Textfield::SetFont(const gfx::Font& font) {
+ SetFontList(gfx::FontList(font));
+}
+
void Textfield::SetHorizontalMargins(int left, int right) {
margins_.Set(margins_.top(), left, margins_.bottom(), right);
horizontal_margins_were_set_ = true;
@@ -424,7 +432,7 @@ void Textfield::Layout() {
int Textfield::GetBaseline() const {
gfx::Insets insets = GetTextInsets();
const int baseline = native_wrapper_ ?
- native_wrapper_->GetTextfieldBaseline() : font_.GetBaseline();
+ native_wrapper_->GetTextfieldBaseline() : font_list_.GetBaseline();
return insets.top() + baseline;
}
@@ -437,9 +445,11 @@ gfx::Size Textfield::GetPreferredSize() {
// use GetFontHeight() to get the height of the first font in the list to
// guide textfield's height.
const int font_height = native_wrapper_ ? native_wrapper_->GetFontHeight() :
- font_.GetHeight();
- return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) +
- insets.width(), font_height + insets.height());
+ font_list_.GetHeight();
+ return gfx::Size(
+ GetPrimaryFont().GetExpectedTextWidth(default_width_in_chars_)
+ + insets.width(),
+ font_height + insets.height());
}
void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) {
« ui/gfx/render_text.h ('K') | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698