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

Unified Diff: chrome/browser/dom_ui/options/font_settings_utils_win.cc

Issue 6277022: dom-ui settings: Eliminate duplicate font names in WinChrome.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 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: chrome/browser/dom_ui/options/font_settings_utils_win.cc
===================================================================
--- chrome/browser/dom_ui/options/font_settings_utils_win.cc (revision 72546)
+++ chrome/browser/dom_ui/options/font_settings_utils_win.cc (working copy)
@@ -1,9 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/dom_ui/options/font_settings_utils.h"
+#include <set>
+#include <string>
#include <windows.h>
#include "base/values.h"
@@ -12,22 +14,20 @@
NEWTEXTMETRICEXW *physical_font,
DWORD font_type,
LPARAM lparam) {
- ListValue* font_list = reinterpret_cast<ListValue*>(lparam);
- if (font_list) {
+ std::set<std::wstring>* font_names =
+ reinterpret_cast<std::set<std::wstring>*>(lparam);
+ if (font_names) {
const LOGFONTW& lf = logical_font->elfLogFont;
if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@') {
- ListValue* font_item = new ListValue();
std::wstring face_name(lf.lfFaceName);
- font_item->Append(Value::CreateStringValue(face_name));
- font_item->Append(Value::CreateStringValue(face_name));
- font_list->Append(font_item);
+ font_names->insert(face_name);
}
}
return 1;
}
ListValue* FontSettingsUtilities::GetFontsList() {
- ListValue* font_list = new ListValue;
+ std::set<std::wstring> font_names;
LOGFONTW logfont;
memset(&logfont, 0, sizeof(logfont));
@@ -35,9 +35,17 @@
HDC hdc = ::GetDC(NULL);
::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc,
- (LPARAM)font_list, 0);
+ (LPARAM)&font_names, 0);
::ReleaseDC(NULL, hdc);
+ ListValue* font_list = new ListValue;
+ std::set<std::wstring>::iterator iter;
+ for (iter = font_names.begin(); iter != font_names.end(); iter++) {
+ ListValue* font_item = new ListValue();
+ font_item->Append(Value::CreateStringValue(*iter));
James Hawkins 2011/01/27 01:15:51 Why Append() twice?
csilv 2011/01/27 01:18:23 The font_item is a list that contains two items, a
+ font_item->Append(Value::CreateStringValue(*iter));
+ 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