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

Unified Diff: content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc

Issue 12600019: Add Pepper TrueType font API plumbing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
Index: content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..94fd04a5ad601d0ab5b7ac39eab02857e20af606
--- /dev/null
+++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 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 "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
+
+#include <windows.h>
+#include <set>
+
+#include "base/utf_string_conversions.h"
+#include "base/win/scoped_hdc.h"
+
+namespace content {
+
+namespace {
+
+static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* logical_font,
+ NEWTEXTMETRICEXW* physical_font,
+ DWORD font_type,
+ LPARAM lparam) {
+ std::set<std::string>* font_name_set =
+ reinterpret_cast<std::set<std::string>*>(lparam);
+ if (font_name_set) {
+ const LOGFONTW& lf = logical_font->elfLogFont;
+ if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@' &&
+ lf.lfOutPrecision == OUT_STROKE_PRECIS) { // Outline fonts only.
+ std::string face_name(UTF16ToUTF8(lf.lfFaceName));
+ font_name_set->insert(face_name);
+ }
+ }
+ return 1;
+}
+
+} // namespace
+
+std::vector<std::string> GetFontFamilies_SlowBlocking() {
+ std::set<std::string> font_name_set;
+ LOGFONTW logfont;
+ memset(&logfont, 0, sizeof(logfont));
+ logfont.lfCharSet = DEFAULT_CHARSET;
+ base::win::ScopedCreateDC hdc(::GetDC(NULL));
+ ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc,
+ (LPARAM)&font_name_set, 0);
+
+ std::vector<std::string> font_families;
+ std::set<std::string>::iterator iter = font_name_set.begin();
+ for (; iter != font_name_set.end(); ++iter)
+ font_families.push_back(*iter);
dmichael (off chromium) 2013/03/12 18:07:58 ditto, could use vector constructor (BTW, The Win
bbudge 2013/03/13 01:26:50 This is copy/paste/tweak from Brett's font_list st
+
+ return font_families;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698