| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "app/resource_bundle.h" | 5 #include "app/resource_bundle.h" |
| 6 | 6 |
| 7 #include "app/gfx/codec/png_codec.h" | 7 #include "app/gfx/codec/png_codec.h" |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 return empty_bitmap; | 140 return empty_bitmap; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ResourceBundle::LoadFontsIfNecessary() { | 144 void ResourceBundle::LoadFontsIfNecessary() { |
| 145 AutoLock lock_scope(lock_); | 145 AutoLock lock_scope(lock_); |
| 146 if (!base_font_.get()) { | 146 if (!base_font_.get()) { |
| 147 base_font_.reset(new gfx::Font()); | 147 base_font_.reset(new gfx::Font()); |
| 148 | 148 |
| 149 bold_font_.reset(new gfx::Font()); |
| 150 *bold_font_ = |
| 151 base_font_->DeriveFont(0, base_font_->style() | gfx::Font::BOLD); |
| 152 |
| 149 small_font_.reset(new gfx::Font()); | 153 small_font_.reset(new gfx::Font()); |
| 150 *small_font_ = base_font_->DeriveFont(-2); | 154 *small_font_ = base_font_->DeriveFont(-2); |
| 151 | 155 |
| 152 medium_font_.reset(new gfx::Font()); | 156 medium_font_.reset(new gfx::Font()); |
| 153 *medium_font_ = base_font_->DeriveFont(3); | 157 *medium_font_ = base_font_->DeriveFont(3); |
| 154 | 158 |
| 155 medium_bold_font_.reset(new gfx::Font()); | 159 medium_bold_font_.reset(new gfx::Font()); |
| 156 *medium_bold_font_ = | 160 *medium_bold_font_ = |
| 157 base_font_->DeriveFont(3, base_font_->style() | gfx::Font::BOLD); | 161 base_font_->DeriveFont(3, base_font_->style() | gfx::Font::BOLD); |
| 158 | 162 |
| 159 large_font_.reset(new gfx::Font()); | 163 large_font_.reset(new gfx::Font()); |
| 160 *large_font_ = base_font_->DeriveFont(8); | 164 *large_font_ = base_font_->DeriveFont(8); |
| 161 } | 165 } |
| 162 } | 166 } |
| 163 | 167 |
| 164 const gfx::Font& ResourceBundle::GetFont(FontStyle style) { | 168 const gfx::Font& ResourceBundle::GetFont(FontStyle style) { |
| 165 LoadFontsIfNecessary(); | 169 LoadFontsIfNecessary(); |
| 166 switch (style) { | 170 switch (style) { |
| 171 case BoldFont: |
| 172 return *bold_font_; |
| 167 case SmallFont: | 173 case SmallFont: |
| 168 return *small_font_; | 174 return *small_font_; |
| 169 case MediumFont: | 175 case MediumFont: |
| 170 return *medium_font_; | 176 return *medium_font_; |
| 171 case MediumBoldFont: | 177 case MediumBoldFont: |
| 172 return *medium_bold_font_; | 178 return *medium_bold_font_; |
| 173 case LargeFont: | 179 case LargeFont: |
| 174 return *large_font_; | 180 return *large_font_; |
| 175 default: | 181 default: |
| 176 return *base_font_; | 182 return *base_font_; |
| 177 } | 183 } |
| 178 } | 184 } |
| OLD | NEW |