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

Unified Diff: chrome/browser/ui/webui/options/font_settings_utils_mac.mm

Issue 7248065: Changed fontlist to list Osaka-Mono Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | content/common/font_list_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/font_settings_utils_mac.mm
diff --git a/chrome/browser/ui/webui/options/font_settings_utils_mac.mm b/chrome/browser/ui/webui/options/font_settings_utils_mac.mm
index 6dae847e2fbeb58d7cf66ddc2a28915be2219be0..3817dc45e0a593b613302c7179e5975945bac2aa 100644
--- a/chrome/browser/ui/webui/options/font_settings_utils_mac.mm
+++ b/chrome/browser/ui/webui/options/font_settings_utils_mac.mm
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/mac/scoped_nsobject.h"
#include "base/prefs/pref_service.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
@@ -21,14 +22,22 @@ static void ValidateFontFamily(PrefService* prefs,
// -[NSFont fontWithName:size] accepted a font or family name, but the
// behavior was technically wrong. Since we really need the family name for
// the dom-ui options window, we will fix the saved preference if necessary.
- NSString *family_name =
+ NSString *pref_value =
base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
- NSFont *font = [NSFont fontWithName:family_name
+ NSFont *font = [NSFont fontWithName:pref_value
size:[NSFont systemFontSize]];
+ NSString* family_name = [font familyName];
+ base::scoped_nsobject<NSFontManager> font_manager(
+ [[NSFontManager alloc] init]);
+ // The fixed pitch check is for Osaka-Mono which exceptionally stores font
+ // name instead of font family name. See GetFontList_SlowBlocking
+ // in font_list_mac.mm for more info.
if (font &&
- [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) {
- std::string new_family_name = base::SysNSStringToUTF8([font familyName]);
- prefs->SetString(family_pref_name, new_family_name);
+ [family_name caseInsensitiveCompare:pref_value] != NSOrderedSame &&
+ [font_manager fontNamed:family_name hasTraits:NSFixedPitchFontMask] ==
+ [font_manager fontNamed:pref_value hasTraits:NSFixedPitchFontMask]) {
+ std::string new_pref_value = base::SysNSStringToUTF8(family_name);
+ prefs->SetString(family_pref_name, new_pref_value);
}
}
« no previous file with comments | « no previous file | content/common/font_list_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698