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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A tiny fix for the ResourceBundle... Created 4 years, 9 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
Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index 479d8e911f92699003cec4eeb628c987b3418d51..afa6ad25d3735b952b455d3e9455a6ad6ee80ff4 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -517,7 +517,7 @@ void OmniboxViewMac::EmphasizeURLComponents() {
void OmniboxViewMac::ApplyTextStyle(
NSMutableAttributedString* attributedString) {
[attributedString addAttribute:NSFontAttributeName
- value:GetFieldFont(gfx::Font::NORMAL)
+ value:GetNormalFieldFont()
range:NSMakeRange(0, [attributedString length])];
// Make a paragraph style locking in the standard line height as the maximum,
@@ -1072,26 +1072,41 @@ void OmniboxViewMac::FocusLocation(bool select_all) {
}
// static
-NSFont* OmniboxViewMac::GetFieldFont(int style) {
+NSFont* OmniboxViewMac::GetNormalFieldFont() {
// This value should be kept in sync with InstantPage::InitializeFonts.
tapted 2016/03/29 20:13:46 InstantPage::InitializeFonts doesn't seem to exist
Mikus 2016/03/30 13:58:24 Done.
+ const int kOmniboxNormalFontSizeDelta = 1;
msw 2016/03/29 19:18:14 nit: these probably belong in a file-local anon na
Mikus 2016/03/30 13:58:24 Done.
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return rb.GetFontList(ui::ResourceBundle::BaseFont).Derive(1, style)
- .GetPrimaryFont().GetNativeFont();
+ return rb
+ .GetFontWithDelta(kOmniboxNormalFontSizeDelta, gfx::Font::NORMAL,
+ gfx::Font::Weight::NORMAL)
+ .GetNativeFont();
+}
+
+NSFont* OmniboxViewMac::GetBoldFieldFont() {
+ // This value should be kept in sync with InstantPage::InitializeFonts.
+ const int kOmniboxNormalFontSizeDelta = 1;
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ return rb
+ .GetFontWithDelta(kOmniboxNormalFontSizeDelta, gfx::Font::NORMAL,
+ gfx::Font::Weight::BOLD)
+ .GetNativeFont();
}
-NSFont* OmniboxViewMac::GetLargeFont(int style) {
+NSFont* OmniboxViewMac::GetLargeFont() {
+ const int kOmniboxLargeFontSizeDelta = 9;
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return rb.GetFontList(ui::ResourceBundle::LargeFont)
- .Derive(1, style)
- .GetPrimaryFont()
+ return rb
+ .GetFontWithDelta(kOmniboxLargeFontSizeDelta, gfx::Font::NORMAL,
+ gfx::Font::Weight::NORMAL)
.GetNativeFont();
}
-NSFont* OmniboxViewMac::GetSmallFont(int style) {
+NSFont* OmniboxViewMac::GetSmallFont() {
+ const int kOmniboxSmallFontSizeDelta = 0;
msw 2016/03/29 19:18:14 ha! the old code was getting the small font (-1 de
tapted 2016/03/29 20:13:46 Yeah although it's common for code to use rb.GetFo
Mikus 2016/03/30 13:58:24 Acknowledged.
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return rb.GetFontList(ui::ResourceBundle::SmallFont)
- .Derive(1, style)
- .GetPrimaryFont()
+ return rb
+ .GetFontWithDelta(kOmniboxSmallFontSizeDelta, gfx::Font::NORMAL,
+ gfx::Font::Weight::NORMAL)
.GetNativeFont();
}

Powered by Google App Engine
This is Rietveld 408576698