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

Side by Side Diff: content/common/font_list_win.cc

Issue 7044012: Support getting the font list in Pepper. This currently only works out of (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
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 "content/common/font_list.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
viettrungluu 2011/05/18 20:40:43 I suppose there's no longer a need to include <str
9 #include <windows.h> 9 #include <windows.h>
viettrungluu 2011/05/18 20:40:43 Is this include order really kosher?
10 10
11 #include "base/string16.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 13
13 static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW *logical_font, 14 namespace content {
14 NEWTEXTMETRICEXW *physical_font, 15
16 static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* logical_font,
17 NEWTEXTMETRICEXW* physical_font,
15 DWORD font_type, 18 DWORD font_type,
16 LPARAM lparam) { 19 LPARAM lparam) {
17 std::set<std::wstring>* font_names = 20 std::set<string16>* font_names =
18 reinterpret_cast<std::set<std::wstring>*>(lparam); 21 reinterpret_cast<std::set<string16>*>(lparam);
19 if (font_names) { 22 if (font_names) {
20 const LOGFONTW& lf = logical_font->elfLogFont; 23 const LOGFONTW& lf = logical_font->elfLogFont;
21 if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@') { 24 if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@') {
22 std::wstring face_name(lf.lfFaceName); 25 string16 face_name(lf.lfFaceName);
23 font_names->insert(face_name); 26 font_names->insert(face_name);
24 } 27 }
25 } 28 }
26 return 1; 29 return 1;
27 } 30 }
28 31
29 ListValue* FontSettingsUtilities::GetFontsList() { 32 ListValue* GetFontList_SlowBlocking() {
30 std::set<std::wstring> font_names; 33 std::set<string16> font_names;
31 34
32 LOGFONTW logfont; 35 LOGFONTW logfont;
33 memset(&logfont, 0, sizeof(logfont)); 36 memset(&logfont, 0, sizeof(logfont));
34 logfont.lfCharSet = DEFAULT_CHARSET; 37 logfont.lfCharSet = DEFAULT_CHARSET;
35 38
36 HDC hdc = ::GetDC(NULL); 39 HDC hdc = ::GetDC(NULL);
37 ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc, 40 ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc,
38 (LPARAM)&font_names, 0); 41 (LPARAM)&font_names, 0);
39 ::ReleaseDC(NULL, hdc); 42 ::ReleaseDC(NULL, hdc);
40 43
41 ListValue* font_list = new ListValue; 44 ListValue* font_list = new ListValue;
42 std::set<std::wstring>::iterator iter; 45 std::set<string16>::iterator iter;
43 for (iter = font_names.begin(); iter != font_names.end(); iter++) { 46 for (iter = font_names.begin(); iter != font_names.end(); iter++) {
44 ListValue* font_item = new ListValue(); 47 ListValue* font_item = new ListValue();
45 font_item->Append(Value::CreateStringValue(*iter)); 48 font_item->Append(Value::CreateStringValue(*iter));
46 font_item->Append(Value::CreateStringValue(*iter)); 49 font_item->Append(Value::CreateStringValue(*iter));
47 font_list->Append(font_item); 50 font_list->Append(font_item);
48 } 51 }
49 return font_list; 52 return font_list;
50 } 53 }
51 54
52 void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) { 55 } // namespace content
53 // nothing to do for Windows.
54 }
55
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698