Skip to content

Commit

Permalink
[cros] Adjust default font sizes for new hand hinted fonts.
Browse files Browse the repository at this point in the history
BUG=chromium-os:8658
TEST=Manual.

Review URL: http://codereview.chromium.org/5180002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66999 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
nkostylev@chromium.org committed Nov 22, 2010
1 parent 9b51153 commit 068ea4c
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 26 deletions.
24 changes: 20 additions & 4 deletions app/resource_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
#include "gfx/font.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace {

// Font sizes relative to base font.
#if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI)
const int kSmallFontSizeDelta = -3;
const int kMediumFontSizeDelta = 2;
const int kLargeFontSizeDelta = 7;
#else
const int kSmallFontSizeDelta = -2;
const int kMediumFontSizeDelta = 3;
const int kLargeFontSizeDelta = 8;
#endif

} // namespace

ResourceBundle* ResourceBundle::g_shared_instance_ = NULL;

/* static */
Expand Down Expand Up @@ -175,17 +190,18 @@ void ResourceBundle::LoadFontsIfNecessary() {
base_font_->DeriveFont(0, base_font_->GetStyle() | gfx::Font::BOLD);

small_font_.reset(new gfx::Font());
*small_font_ = base_font_->DeriveFont(-2);
*small_font_ = base_font_->DeriveFont(kSmallFontSizeDelta);

medium_font_.reset(new gfx::Font());
*medium_font_ = base_font_->DeriveFont(3);
*medium_font_ = base_font_->DeriveFont(kMediumFontSizeDelta);

medium_bold_font_.reset(new gfx::Font());
*medium_bold_font_ =
base_font_->DeriveFont(3, base_font_->GetStyle() | gfx::Font::BOLD);
base_font_->DeriveFont(kMediumFontSizeDelta,
base_font_->GetStyle() | gfx::Font::BOLD);

large_font_.reset(new gfx::Font());
*large_font_ = base_font_->DeriveFont(8);
*large_font_ = base_font_->DeriveFont(kLargeFontSizeDelta);
}
}

Expand Down
6 changes: 6 additions & 0 deletions build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,10 @@
#error Please add support for your compiler in build/build_config.h
#endif

#if defined(OS_CHROMEOS)
// Single define to trigger whether CrOS fonts have BCI on.
// In that case font sizes/deltas should be adjusted.
//define CROS_FONTS_USING_BCI
#endif

#endif // BUILD_BUILD_CONFIG_H_
10 changes: 9 additions & 1 deletion chrome/browser/chromeos/frame/bubble_frame_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ static const int kTitleTopPadding = 10;
static const int kTitleContentPadding = 10;
static const int kHorizontalPadding = 10;

// Title font size correction.
#if defined(CROS_FONTS_USING_BCI)
static const int kTitleFontSizeDelta = 0;
#else
static const int kTitleFontSizeDelta = 1;
#endif

} // namespace

namespace chromeos {
Expand All @@ -44,7 +51,8 @@ BubbleFrameView::BubbleFrameView(views::Window* frame,
if (frame_->GetDelegate()->ShouldShowWindowTitle()) {
title_ = new views::Label(frame_->GetDelegate()->GetWindowTitle());
title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
title_->SetFont(title_->font().DeriveFont(1, gfx::Font::BOLD));
title_->SetFont(title_->font().DeriveFont(kFontSizeCorrectionDelta,
gfx::Font::BOLD));
AddChildView(title_);
}

Expand Down
10 changes: 7 additions & 3 deletions chrome/browser/chromeos/input_method/candidate_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ const SkColor kAnnotationColor = SkColorSetRGB(0x88, 0x88, 0x88);

// We'll use a bigger font size, so Chinese characters are more readable
// in the candidate window.
const int kFontSizeDelta = 2; // Two size bigger.
#if defined(CROS_FONTS_USING_BCI)
const int kFontSizeDelta = 1;
#else
const int kFontSizeDelta = 2;
#endif

// The minimum width of candidate labels in the vertical candidate
// window. We use this value to prevent the candidate window from being
Expand Down Expand Up @@ -1264,8 +1268,8 @@ void CandidateWindowController::Impl::OnConnectionChange(
}
}

CandidateWindowController::CandidateWindowController() :
impl_(new CandidateWindowController::Impl) {
CandidateWindowController::CandidateWindowController()
: impl_(new CandidateWindowController::Impl) {
}

CandidateWindowController::~CandidateWindowController() {
Expand Down
12 changes: 10 additions & 2 deletions chrome/browser/chromeos/login/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ views::Painter* CreateBackgroundPainter();
// |size| is not empty. Otherwise the whole monitor is occupied.
gfx::Rect CalculateScreenBounds(const gfx::Size& size);

// Corrects font size for NativeButton control.
// Corrects font size for Label control.
void CorrectLabelFontSize(views::Label* label);

// Corrects font size for MenuButton control.
Expand Down Expand Up @@ -110,8 +110,16 @@ class WideButton : public views::NativeButton {

} // namespace login

// Font size correction in points for login/oobe textfields/buttons/title.
// Font size correction in points for login/oobe controls.
#if defined(CROS_FONTS_USING_BCI)
const int kFontSizeCorrectionDelta = 1;
const int kUnselectedUsernameFontDelta = 0;
const int kWelcomeTitleFontDelta = 5;
#else
const int kFontSizeCorrectionDelta = 2;
const int kUnselectedUsernameFontDelta = 1;
const int kWelcomeTitleFontDelta = 5;
#endif

// New pod sizes.
const int kNewUserPodFullWidth = 372;
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/chromeos/login/network_selection_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ const int kPaddingColumnWidth = 55;
const int kMediumPaddingColumnWidth = 20;
const int kControlPaddingRow = 15;

// Size to add to the welcome title font.
const int kWelcomeTitleFontDelta = 5;

// Fixed size for language/keyboard/network controls height.
const int kSelectionBoxHeight = 29;

Expand Down
7 changes: 4 additions & 3 deletions chrome/browser/chromeos/login/user_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ const int kUserNameGap = 4;

// Approximate height of controls window, this constant is used in new user
// case to make border window size close to existing users.
#if defined(CROS_FONTS_USING_BCI)
const int kControlsHeight = 31;
#else
const int kControlsHeight = 28;

// Delta for the unselected username font.
const int kUnselectedUsernameFontDelta = 1;
#endif

// Widget that notifies window manager about clicking on itself.
// Doesn't send anything if user is selected.
Expand Down
8 changes: 7 additions & 1 deletion chrome/browser/chromeos/status/clock_menu_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ namespace chromeos {
// when the timer goes off.
const int kTimerSlopSeconds = 1;

#if defined(CROS_FONTS_USING_BCI)
const int kFontSizeDelta = 0;
#else
const int kFontSizeDelta = 1;
#endif

ClockMenuButton::ClockMenuButton(StatusAreaHost* host)
: StatusAreaButton(this),
host_(host) {
Expand All @@ -34,7 +40,7 @@ ClockMenuButton::ClockMenuButton(StatusAreaHost* host)
set_border(NULL);
set_use_menu_button_paint(true);
SetFont(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont).DeriveFont(1));
ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta));
SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
SetShowMultipleIconStates(false);
set_alignment(TextButton::ALIGN_CENTER);
Expand Down
8 changes: 7 additions & 1 deletion chrome/browser/chromeos/status/input_method_menu_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ PrefService* GetPrefService(chromeos::StatusAreaHost* host) {
return NULL;
}

#if defined(CROS_FONTS_USING_BCI)
const int kFontSizeDelta = 0;
#else
const int kFontSizeDelta = 1;
#endif

} // namespace

namespace chromeos {
Expand All @@ -42,7 +48,7 @@ InputMethodMenuButton::InputMethodMenuButton(StatusAreaHost* host)
set_border(NULL);
set_use_menu_button_paint(true);
SetFont(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont).DeriveFont(1));
ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta));
SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
SetDisabledColor(0x00FFFFFF); // White with 00% Alpha (invisible)
SetShowMultipleIconStates(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ const int kIconVerticalPadding = 2;
const int kTextVerticalPadding = 3;
// The size delta between the font used for the edit and the result rows. Passed
// to gfx::Font::DeriveFont.
#if !defined(OS_CHROMEOS)
const int kEditFontAdjust = -1;
#else
#if defined(OS_CHROMEOS) && !defined(CROS_FONTS_USING_BCI)
// Don't adjust font on chromeos as it becomes too small.
const int kEditFontAdjust = 0;
#else
const int kEditFontAdjust = -1;
#endif

// Horizontal padding between the buttons on the opt in promo.
Expand Down
10 changes: 9 additions & 1 deletion chrome/browser/ui/views/extensions/extension_install_prompt2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ const int kPermissionLabelWidth =
kPermissionBoxBorderWidth * 2 -
kPermissionBoxHorizontalPadding * 2;

// Heading font size correction.
#if defined(CROS_FONTS_USING_BCI)
const int kHeadingFontSizeDelta = 0;
#else
const int kHeadingFontSizeDelta = 1;
#endif

} // namespace


Expand Down Expand Up @@ -131,7 +138,8 @@ InstallDialogContent2::InstallDialogContent2(
heading_ = new views::Label(
l10n_util::GetStringF(IDS_EXTENSION_INSTALL_PROMPT_HEADING,
UTF8ToWide(extension->name())));
heading_->SetFont(heading_->font().DeriveFont(1, gfx::Font::BOLD));
heading_->SetFont(heading_->font().DeriveFont(kHeadingFontSizeDelta,
gfx::Font::BOLD));
heading_->SetMultiLine(true);
heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(heading_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class InstalledBubbleContent : public views::View,
heading_ = new views::Label(
l10n_util::GetStringF(IDS_EXTENSION_INSTALLED_HEADING,
UTF8ToWide(extension->name())));
heading_->SetFont(font.DeriveFont(3, gfx::Font::NORMAL));
heading_->SetFont(rb.GetFont(ResourceBundle::MediumFont));
heading_->SetMultiLine(true);
heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(heading_);
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ui/views/location_bar/location_bar_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ void LocationBarView::Init() {
ResourceBundle::BaseFont);
} else {
// Use a larger version of the system font.
font_ = font_.DeriveFont(3);
font_ = ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::MediumFont);
}

// If this makes the font too big, try to make it smaller so it will fit.
Expand Down
14 changes: 12 additions & 2 deletions chrome/browser/ui/views/sad_tab_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ static const SkColor kLinkColor = SK_ColorWHITE;
static const SkColor kBackgroundColor = SkColorSetRGB(35, 48, 64);
static const SkColor kBackgroundEndColor = SkColorSetRGB(35, 48, 64);

// Font size correction.
#if defined(CROS_FONTS_USING_BCI)
static const int kTitleFontSizeDelta = 1;
static const int kMessageFontSizeDelta = 0;
#else
static const int kTitleFontSizeDelta = 2;
static const int kMessageFontSizeDelta = 1;
#endif

// static
SkBitmap* SadTabView::sad_tab_bitmap_ = NULL;
gfx::Font* SadTabView::title_font_ = NULL;
Expand Down Expand Up @@ -134,9 +143,10 @@ void SadTabView::InitClass() {
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
title_font_ = new gfx::Font(
rb.GetFont(ResourceBundle::BaseFont).DeriveFont(2, gfx::Font::BOLD));
rb.GetFont(ResourceBundle::BaseFont).DeriveFont(kTitleFontSizeDelta,
gfx::Font::BOLD));
message_font_ = new gfx::Font(
rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1));
rb.GetFont(ResourceBundle::BaseFont).DeriveFont(kMessageFontSizeDelta));
sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB);

title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE);
Expand Down

0 comments on commit 068ea4c

Please sign in to comment.