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

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: Add a lost comment and modify a render text unittest to not test black because of test env font con… Created 4 years, 7 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 ddd172306721b1f8825d4921e1d3672058e48445..2bf381da901a7b6da84306537604f33f2e35c315 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -78,6 +78,10 @@ using content::WebContents;
// things work on other platforms.
namespace {
+const int kOmniboxLargeFontSizeDelta = 9;
+const int kOmniboxNormalFontSizeDelta = 1;
+const int kOmniboxSmallFontSizeDelta = 0;
+const int kOmniboxSmallMaterialFontSizeDelta = -1;
// TODO(shess): This is ugly, find a better way. Using it right now
// so that I can crib from gtk and still be able to see that I'm using
@@ -550,7 +554,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,
@@ -1105,32 +1109,42 @@ void OmniboxViewMac::FocusLocation(bool select_all) {
}
// static
-NSFont* OmniboxViewMac::GetFieldFont(int style) {
- // This value should be kept in sync with InstantPage::InitializeFonts.
+NSFont* OmniboxViewMac::GetNormalFieldFont() {
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() {
+ 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() {
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() {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (!ui::MaterialDesignController::IsModeMaterial()) {
- return rb.GetFontList(ui::ResourceBundle::SmallFont)
- .Derive(1, style)
- .GetPrimaryFont()
+ return rb
+ .GetFontWithDelta(kOmniboxSmallFontSizeDelta, gfx::Font::NORMAL,
+ gfx::Font::Weight::NORMAL)
.GetNativeFont();
}
- return rb.GetFontListWithDelta(-2, gfx::Font::NORMAL)
- .Derive(1, style)
- .GetPrimaryFont()
+
+ return rb
+ .GetFontWithDelta(kOmniboxSmallMaterialFontSizeDelta, gfx::Font::NORMAL,
+ gfx::Font::Weight::NORMAL)
.GetNativeFont();
}
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698