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

Side by Side Diff: chrome/browser/ui/webui/options/font_settings_utils_mac.mm

Issue 7204026: Changed fontlist to list all avalilable fonts. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Just adds Osaka Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/common/font_list_mac.mm » ('j') | content/common/font_list_mac.mm » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/options/font_settings_utils.h" 5 #include "chrome/browser/ui/webui/options/font_settings_utils.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsautorelease_pool.h" 9 #include "base/mac/scoped_nsautorelease_pool.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 14
15 static void ValidateFontFamily(PrefService* prefs, 15 static void ValidateFontFamily(PrefService* prefs,
16 const char* family_pref_name) { 16 const char* family_pref_name) {
17 // The native font settings dialog saved fonts by the font name, rather 17 // The native font settings dialog saved fonts by the font name, rather
18 // than the family name. This worked for the old dialog since 18 // than the family name. This worked for the old dialog since
19 // -[NSFont fontWithName:size] accepted a font or family name, but the 19 // -[NSFont fontWithName:size] accepted a font or family name, but the
20 // behavior was technically wrong. Since we really need the family name for 20 // behavior was technically wrong. Since we really need the family name for
21 // the dom-ui options window, we will fix the saved preference if necessary. 21 // the dom-ui options window, we will fix the saved preference if necessary.
22 NSString *family_name = 22 NSString *pref_value =
23 base::SysUTF8ToNSString(prefs->GetString(family_pref_name)); 23 base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
24 NSFont *font = [NSFont fontWithName:family_name 24 NSFont *font = [NSFont fontWithName:pref_value
25 size:[NSFont systemFontSize]]; 25 size:[NSFont systemFontSize]];
26 NSString* familyName = [font familyName];
brettw 2011/06/24 20:56:26 Local variables should be lower_case_with_undersco
27 NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
csilv 2011/06/24 20:51:30 Use scoped_nsobject instead of autorelease.
26 if (font && 28 if (font &&
27 [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) { 29 [familyName caseInsensitiveCompare:pref_value] != NSOrderedSame &&
28 std::string new_family_name = base::SysNSStringToUTF8([font familyName]); 30 // The condition below is for Osaka-Mono which exceptionally stores font
brettw 2011/06/24 20:56:26 I'd probably not put the comment in the middle of
29 prefs->SetString(family_pref_name, new_family_name); 31 // name instead of font family name. See GetFontList_SlowBlocking
32 // in font_list_mac.mm for more info.
33 [fontManager fontNamed:familyName hasTraits:NSFixedPitchFontMask] ==
34 [fontManager fontNamed:pref_value hasTraits:NSFixedPitchFontMask]) {
35 std::string new_pref_value = base::SysNSStringToUTF8(familyName);
36 prefs->SetString(family_pref_name, new_pref_value);
30 } 37 }
31 } 38 }
32 39
33 // static 40 // static
34 void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) { 41 void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) {
35 ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily); 42 ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily);
36 ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily); 43 ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily);
37 ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily); 44 ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily);
38 } 45 }
OLDNEW
« no previous file with comments | « no previous file | content/common/font_list_mac.mm » ('j') | content/common/font_list_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698