Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/common/font_list.h" | 5 #include "content/common/font_list.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/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { | 15 std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { |
| 16 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 16 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 17 std::unique_ptr<base::ListValue> font_list(new base::ListValue); | 17 std::unique_ptr<base::ListValue> font_list(new base::ListValue); |
| 18 NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease]; | 18 NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease]; |
| 19 NSArray* fonts = [fontManager availableFontFamilies]; | 19 NSArray* fonts = [fontManager availableFontFamilies]; |
| 20 for (NSString* family_name in fonts) { | 20 NSArray* sortedFonts = [fonts sortedArrayUsingSelector:@selector(compare:)]; |
| 21 for (NSString* family_name in sortedFonts) { | |
| 21 NSString* localized_family_name = | 22 NSString* localized_family_name = |
| 22 [fontManager localizedNameForFamily:family_name face:nil]; | 23 [fontManager localizedNameForFamily:family_name face:nil]; |
|
Avi (use Gerrit)
2016/11/04 05:31:53
You're sorting based on the family name above, yet
| |
| 23 base::ListValue* font_item = new base::ListValue(); | 24 base::ListValue* font_item = new base::ListValue(); |
| 24 base::string16 family = base::SysNSStringToUTF16(family_name); | 25 base::string16 family = base::SysNSStringToUTF16(family_name); |
| 25 font_item->Append(new base::StringValue(family)); | 26 font_item->Append(new base::StringValue(family)); |
| 26 base::string16 loc_family = base::SysNSStringToUTF16(localized_family_name); | 27 base::string16 loc_family = base::SysNSStringToUTF16(localized_family_name); |
| 27 font_item->Append(new base::StringValue(loc_family)); | 28 font_item->Append(new base::StringValue(loc_family)); |
| 28 font_list->Append(font_item); | 29 font_list->Append(font_item); |
| 29 } | 30 } |
| 30 return font_list; | 31 return font_list; |
|
Avi (use Gerrit)
2016/11/04 05:31:53
Perhaps sort the list at this point, with a locali
| |
| 31 } | 32 } |
| 32 | 33 |
| 33 } // namespace content | 34 } // namespace content |
| OLD | NEW |