| Index: ui/gfx/font_list.cc
|
| diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc
|
| index 920204bf7a74dcc0c7bd58e73242846852b989d0..b461aa9b28b0eb7f06fb65931bf2f9f9b4c4bb0d 100644
|
| --- a/ui/gfx/font_list.cc
|
| +++ b/ui/gfx/font_list.cc
|
| @@ -106,6 +106,27 @@ const Font& FontList::GetPrimaryFont() const {
|
| return impl_->GetPrimaryFont();
|
| }
|
|
|
| +gfx::FontList FontList::GetLargestFontListWithHeightBound(int height) const {
|
| + gfx::FontList font_list(*this);
|
| + for (int font_size = font_list.GetFontSize(); font_size > 1; --font_size) {
|
| + const int internal_leading =
|
| + font_list.GetBaseline() - font_list.GetCapHeight();
|
| + // Some platforms don't support getting the cap height, and simply return
|
| + // the entire font ascent from GetCapHeight(). Centering the ascent makes
|
| + // the font look too low, so if GetCapHeight() returns the ascent, center
|
| + // the entire font height instead.
|
| + const int space =
|
| + height - ((internal_leading != 0) ?
|
| + font_list.GetCapHeight() : font_list.GetHeight());
|
| + const int y_offset = space / 2 - internal_leading;
|
| + const int space_at_bottom = height - (y_offset + font_list.GetHeight());
|
| + if ((y_offset >= 0) && (space_at_bottom >= 0))
|
| + break;
|
| + font_list = font_list.DeriveWithSizeDelta(-1);
|
| + }
|
| + return font_list;
|
| +}
|
| +
|
| FontList::FontList(FontListImpl* impl) : impl_(impl) {}
|
|
|
| // static
|
|
|