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

Unified Diff: content/common/font_list_mac.mm

Issue 2472283002: In chrome://settings/fonts, fonts are not alphabetically ordered. (Closed)
Patch Set: Change sort Created 4 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/font_list_mac.mm
diff --git a/content/common/font_list_mac.mm b/content/common/font_list_mac.mm
index 8c7d889b853a9674ecd536dabeb2ac0a672260db..a1b46212a718ecd29fa595c6a349c3eb02fc52f0 100644
--- a/content/common/font_list_mac.mm
+++ b/content/common/font_list_mac.mm
@@ -16,17 +16,30 @@
base::mac::ScopedNSAutoreleasePool autorelease_pool;
std::unique_ptr<base::ListValue> font_list(new base::ListValue);
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
+ NSMutableDictionary* fonts_dict =
+ [[[NSMutableDictionary alloc] init] autorelease];
Avi (use Gerrit) 2016/11/04 19:59:55 Nit: you can use the convenience constructor: NSM
NSArray* fonts = [fontManager availableFontFamilies];
+
for (NSString* family_name in fonts) {
NSString* localized_family_name =
[fontManager localizedNameForFamily:family_name face:nil];
+ fonts_dict[family_name] = localized_family_name;
+ }
+
+ // Sort family names based on localized names.
+ NSArray* sortedFonts = [fonts_dict
+ keysSortedByValueUsingSelector:@selector(localizedStandardCompare:)];
+
+ for (NSString* family_name in sortedFonts) {
+ NSString* localized_family_name = fonts_dict[family_name];
base::ListValue* font_item = new base::ListValue();
base::string16 family = base::SysNSStringToUTF16(family_name);
- font_item->Append(new base::StringValue(family));
base::string16 loc_family = base::SysNSStringToUTF16(localized_family_name);
+ font_item->Append(new base::StringValue(family));
font_item->Append(new base::StringValue(loc_family));
font_list->Append(font_item);
}
+
return font_list;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698