Chromium Code Reviews| 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..547a56dd20d900f0e57d037e38e2a800a3221310 100644 |
| --- a/content/common/font_list_mac.mm |
| +++ b/content/common/font_list_mac.mm |
| @@ -16,17 +16,33 @@ |
| 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]; |
| 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 keysSortedByValueUsingComparator:^(NSString* localized1, |
| + NSString* localized2) { |
| + return [localized1 compare:localized2 options:NSCaseInsensitiveSearch]; |
|
Avi (use Gerrit)
2016/11/04 16:33:40
This isn't a localized sort, but rather a sort on
|
| + }]; |
| + |
| + 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; |
| } |